Skip to content

Commit 8cedf8c

Browse files
committed
make sure it update only the extension
1 parent 7993558 commit 8cedf8c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main/kotlin/com/github/adrienpessu/sarifviewer/toolWindow/SarifViewerWindowFactory.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,16 @@ class SarifViewerWindowFactory : ToolWindowFactory {
586586
private fun findPath(project: Project, path: String): VirtualFile? {
587587
val fileName = path.substring(path.lastIndexOf('/')+1)
588588
val pathOnly = path.substring(0, path.lastIndexOf('/')+1)
589-
val decompiledFileName = fileName.replace(".scala",".java").replace(".kt",".java")
589+
590+
val lastDot = fileName.lastIndexOf('.')
591+
val decompiledFileName = if (lastDot != -1) {
592+
val nameWithoutExt = fileName.substring(0, lastDot)
593+
val ext = fileName.substring(lastDot + 1)
594+
when (ext) {
595+
"scala", "kt" -> "$nameWithoutExt.java"
596+
else -> fileName
597+
}
598+
} else fileName
590599
val collection : MutableCollection<VirtualFile> = FilenameIndex.getVirtualFilesByName(fileName, GlobalSearchScope.allScope(project))
591600
// during decompilation original file ext is lost
592601
collection.addAll(FilenameIndex.getVirtualFilesByName(decompiledFileName, GlobalSearchScope.allScope(project)))

0 commit comments

Comments
 (0)