Skip to content

Commit

Permalink
(WIP) fix for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Nov 27, 2024
1 parent aa6621d commit 8f4117e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.sonarsource.kotlin.api.frontend

import com.intellij.openapi.editor.Document
import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiErrorElement
import com.intellij.psi.PsiFile
Expand All @@ -45,11 +46,10 @@ data class KotlinSyntaxStructure(val ktFile: KtFile, val document: Document, val
fun of(content: String, environment: Environment, inputFile: InputFile): KotlinSyntaxStructure {

val psiFile: KtFile = if (environment.k2session != null) {
// FIXME quick hack
val inputFilePath = FileUtil.toSystemIndependentName(inputFile.file().path)
environment.k2session!!.modulesWithFiles.values.first()
.find {
// FIXME fails on Windows?
it.virtualFile.path == inputFile.uri().path
it.virtualFile.path == inputFilePath
} as KtFile
} else
environment.ktPsiFactory.createFile(inputFile.uri().path, normalizeEol(content))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class KotlinVerifier(private val check: AbstractCheck) {
)
val converter = { content: String ->
val inputFile = TestInputFileBuilder("moduleKey", filePath.fileName.pathString)
// .setModuleBaseDir(filePath.parent) // otherwise projectKey "moduleKey" leaks into absolutePath
.setModuleBaseDir(filePath.parent) // otherwise projectKey "moduleKey" leaks into absolutePath
.setCharset(StandardCharsets.UTF_8)
.initMetadata(content).build()

Expand Down

0 comments on commit 8f4117e

Please sign in to comment.