diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/diagnostics/WhenMissingCase.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/diagnostics/WhenMissingCase.kt index 93bd7685288..6eed35eda23 100644 --- a/compiler/frontend.common/src/org/jetbrains/kotlin/diagnostics/WhenMissingCase.kt +++ b/compiler/frontend.common/src/org/jetbrains/kotlin/diagnostics/WhenMissingCase.kt @@ -51,7 +51,7 @@ sealed class WhenMissingCase { } class EnumCheckIsMissing(val callableId: CallableId) : WhenMissingCase() { - override val branchConditionText: String = callableId.asFqNameForDebugInfo().toString() + override val branchConditionText: String = callableId.asSingleFqName().toString() override fun toString(): String { return callableId.callableName.identifier diff --git a/core/compiler.common/src/org/jetbrains/kotlin/name/CallableId.kt b/core/compiler.common/src/org/jetbrains/kotlin/name/CallableId.kt index 1df905d3b46..181d529f772 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/name/CallableId.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/name/CallableId.kt @@ -54,7 +54,10 @@ data class CallableId( fun asFqNameForDebugInfo(): FqName { if (pathToLocal != null) return pathToLocal.child(callableName) + return asSingleFqName() + } + fun asSingleFqName(): FqName { return classId?.asSingleFqName()?.child(callableName) ?: packageName.child(callableName) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt index bdd6521c83f..653192cb87a 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt @@ -172,7 +172,7 @@ fun FqName.quoteSegmentsIfNeeded(): String { fun FqName.quoteIfNeeded() = FqName(quoteSegmentsIfNeeded()) fun CallableId.asFqNameWithRootPrefixIfNeeded() = - asFqNameForDebugInfo().withRootPrefixIfNeeded() + asSingleFqName().withRootPrefixIfNeeded() fun FqName.withRootPrefixIfNeeded(targetElement: KtElement? = null) = if (canAddRootPrefix() && targetElement?.canAddRootPrefix() != false) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt index ba1bee6f26c..c3c21009cd2 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt @@ -370,7 +370,7 @@ private fun addCallableImportIfRequired(targetFile: KtFile, nameToImport: Callab } private fun alreadyHasImport(file: KtFile, nameToImport: CallableId): Boolean { - if (file.importDirectives.any { it.importPath?.fqName == nameToImport.asFqNameForDebugInfo() }) return true + if (file.importDirectives.any { it.importPath?.fqName == nameToImport.asSingleFqName() }) return true withAllowedResolve { analyse(file) { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirIdeDeserializedDeclarationSourceProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirIdeDeserializedDeclarationSourceProvider.kt index d577529a841..93483be1703 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirIdeDeserializedDeclarationSourceProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/fir/FirIdeDeserializedDeclarationSourceProvider.kt @@ -42,7 +42,7 @@ object FirIdeDeserializedDeclarationSourceProvider { ): PsiElement? { val candidates = if (function.isTopLevel) { KotlinTopLevelFunctionFqnNameIndex.getInstance().get( - function.symbol.callableId.asFqNameForDebugInfo().asString(), + function.symbol.callableId.asSingleFqName().asString(), project, function.scope(project) ).filter(KtNamedFunction::isCompiled) @@ -58,7 +58,7 @@ object FirIdeDeserializedDeclarationSourceProvider { private fun provideSourceForProperty(property: FirProperty, project: Project): PsiElement? { val candidates = if (property.isTopLevel) { KotlinTopLevelFunctionFqnNameIndex.getInstance().get( - property.symbol.callableId.asFqNameForDebugInfo().asString(), + property.symbol.callableId.asSingleFqName().asString(), project, property.scope(project) ) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt index f21b0fc109a..201e8c1e3e1 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt @@ -24,7 +24,7 @@ fun addImportToFile( allUnder: Boolean = false, alias: Name? = null ) { - addImportToFile(project, file, callableId.asFqNameForDebugInfo(), allUnder, alias) + addImportToFile(project, file, callableId.asSingleFqName(), allUnder, alias) } /** diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddWhenRemainingBranchesFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddWhenRemainingBranchesFix.kt index 40c89afbf57..b1a3545103e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddWhenRemainingBranchesFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddWhenRemainingBranchesFix.kt @@ -100,7 +100,7 @@ class AddWhenRemainingBranchesFix( } else { "is " } + case.classId.asSingleFqName().quoteIfNeeded().asString() - is WhenMissingCase.EnumCheckIsMissing -> case.callableId.asFqNameForDebugInfo().quoteIfNeeded().asString() + is WhenMissingCase.EnumCheckIsMissing -> case.callableId.asSingleFqName().quoteIfNeeded().asString() } val entry = psiFactory.createWhenEntry("$branchConditionText -> TODO()") if (elseBranch != null) {