From 525333f95b84b5a178061ddda01bcd820d6f343f Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Mon, 15 Jan 2024 10:49:55 -0500 Subject: [PATCH] fix: don't use extension function from kotlin intellij lib (#465) * 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 --- .circleci/config.yml | 2 +- CHANGELOG.md | 9 +++++++++ catalog-info.yaml | 4 ++-- src/main/kotlin/io/snyk/plugin/Utils.kt | 4 ++++ .../kotlin/io/snyk/plugin/snykcode/core/SnykCodeFile.kt | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bb84cd73d..038514cf7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,4 +11,4 @@ workflows: name: Scan repository for secrets context: - snyk-bot-slack - channel: hammerhead-alerts + channel: dx-local-alerts diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd050a3c..1a22e02fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/catalog-info.yaml b/catalog-info.yaml index c61d1f7d5..3d3afa065 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -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 diff --git a/src/main/kotlin/io/snyk/plugin/Utils.kt b/src/main/kotlin/io/snyk/plugin/Utils.kt index 401eac264..3e995e1cd 100644 --- a/src/main/kotlin/io/snyk/plugin/Utils.kt +++ b/src/main/kotlin/io/snyk/plugin/Utils.kt @@ -399,3 +399,7 @@ fun getArch(): String { ) return archMap[value] ?: value } + +fun VirtualFile.toPsiFile(project: Project): PsiFile? { + return PsiManager.getInstance(project).findFile(this) +} diff --git a/src/main/kotlin/io/snyk/plugin/snykcode/core/SnykCodeFile.kt b/src/main/kotlin/io/snyk/plugin/snykcode/core/SnykCodeFile.kt index e9c4f74f2..eed5b36ae 100644 --- a/src/main/kotlin/io/snyk/plugin/snykcode/core/SnykCodeFile.kt +++ b/src/main/kotlin/io/snyk/plugin/snykcode/core/SnykCodeFile.kt @@ -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