Skip to content

Commit

Permalink
fix: don't use extension function from kotlin intellij lib (#465)
Browse files Browse the repository at this point in the history
* fix: don't use extension function from kotlin intellij lib

The Kotlin library is not available on all Jetbrains IDEs, e.g. in PyCharm or Goland. This results in ClassNotFoundExceptions when using (extension) functions that are provided there.

Previously, we by accident referenced an extension function provided by the Kotlin library. This commit fixes this by defining a similar extension function `virtualFile.toPsiFile(project)` in the plugin code using `PsiManager.getInstance(project).findFile(virtualFile)`.

* docs: update CHANGELOG.md

* chore: update some codeowner references
  • Loading branch information
bastiandoetsch authored Jan 15, 2024
1 parent d3a0a0f commit 525333f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ workflows:
name: Scan repository for secrets
context:
- snyk-bot-slack
channel: hammerhead-alerts
channel: dx-local-alerts
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Snyk Changelog

## [2.6.1]
### Fixed
- don't use kotlin library on non-kotlin IDEs

## [2.6.0]
### Fixed
- fix threading and UI incompatibilities with 2023.3

## [2.5.8]
### Added
- support for IntelliJ 2023.3 platform
Expand Down
4 changes: 2 additions & 2 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: snyk-intellij-plugin
annotations:
github.com/project-slug: snyk/snyk-intellij-plugin
github.com/team-slug: snyk/hammerhead
github.com/team-slug: snyk/ide
spec:
type: ide-plugin
lifecycle: "-"
owner: hammerhead
owner: ide
4 changes: 4 additions & 0 deletions src/main/kotlin/io/snyk/plugin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,7 @@ fun getArch(): String {
)
return archMap[value] ?: value
}

fun VirtualFile.toPsiFile(project: Project): PsiFile? {
return PsiManager.getInstance(project).findFile(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Iconable
import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.idea.core.util.toPsiFile
import io.snyk.plugin.toPsiFile
import snyk.common.RelativePathHelper
import javax.swing.Icon

Expand Down

0 comments on commit 525333f

Please sign in to comment.