diff --git a/compiler/frontend/src/org/jetbrains/kotlin/incremental/KotlinLookupLocation.kt b/compiler/frontend/src/org/jetbrains/kotlin/incremental/KotlinLookupLocation.kt index 1729e06e712..248972b9d9f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/incremental/KotlinLookupLocation.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/incremental/KotlinLookupLocation.kt @@ -32,7 +32,7 @@ class KotlinLookupLocation(val element: KtElement) : LookupLocation { if (containingJetFile.doNotAnalyze != null) return null return object : LocationInfo { - override val filePath = containingJetFile.virtualFile.path + override val filePath = containingJetFile.virtualFilePath override val position: Position get() = getLineAndColumnInPsiFile(containingJetFile, element.textRange).let { Position(it.line, it.column) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt index d8c6271c43d..1d0d30e4677 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt @@ -50,6 +50,9 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) : @Volatile private var hasTopLeveCallables: Boolean? = null + @Volatile + private var pathCached: String? = null + val importList: KtImportList? get() = findChildByTypeOrClass(KtStubElementTypes.IMPORT_LIST, KtImportList::class.java) @@ -104,6 +107,15 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) : return result } + val virtualFilePath + get(): String { + pathCached?.let { return it } + + return virtualFile.path.also { + pathCached = it + } + } + val isScriptByTree: Boolean get() = script != null @@ -170,6 +182,7 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) : super.clearCaches() isScript = null hasTopLeveCallables = null + pathCached = null } fun isScript(): Boolean = stub?.isScript() ?: isScriptByTree