diff --git a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationForClass.txt b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationForClass.txt index 74737df7591..8e739eef099 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationForClass.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationForClass.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Annotation) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFile.txt b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFile.txt index e8f51cd6daa..fb9b52f0f65 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFile.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFile.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(message: kotlin.String, replaceWith: kotlin.ReplaceWith = ..., level: kotlin.DeprecationLevel = ...) +0: (in kotlin.Deprecated) constructor(message: kotlin.String, replaceWith: kotlin.ReplaceWith = ..., level: kotlin.DeprecationLevel = ...) \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFileWithImport.txt b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFileWithImport.txt index e8f51cd6daa..fb9b52f0f65 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFileWithImport.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/AnnotationOnFileWithImport.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(message: kotlin.String, replaceWith: kotlin.ReplaceWith = ..., level: kotlin.DeprecationLevel = ...) +0: (in kotlin.Deprecated) constructor(message: kotlin.String, replaceWith: kotlin.ReplaceWith = ..., level: kotlin.DeprecationLevel = ...) \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/ClassObjectClassLiteralReferenceWithField.kt b/idea/idea-frontend-fir/testData/referenceResolve/ClassObjectClassLiteralReferenceWithField.kt index 24a73ac63f6..5950e1439e2 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/ClassObjectClassLiteralReferenceWithField.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/ClassObjectClassLiteralReferenceWithField.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR package t class A { diff --git a/idea/idea-frontend-fir/testData/referenceResolve/InObjectClassObject.txt b/idea/idea-frontend-fir/testData/referenceResolve/InObjectClassObject.txt index 74737df7591..60c8b5e1d71 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/InObjectClassObject.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/InObjectClassObject.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.A) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/InSecondClassObject.txt b/idea/idea-frontend-fir/testData/referenceResolve/InSecondClassObject.txt index 74737df7591..60c8b5e1d71 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/InSecondClassObject.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/InSecondClassObject.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.A) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/JavaAnnotationParameter.txt b/idea/idea-frontend-fir/testData/referenceResolve/JavaAnnotationParameter.txt index f2c40c032f1..3ab070deae1 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/JavaAnnotationParameter.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/JavaAnnotationParameter.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(value: java.lang.annotation.RetentionPolicy) +0: (in java.lang.annotation.Retention) constructor(value: java.lang.annotation.RetentionPolicy) \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/JavaConstructorNotNullParameter.txt b/idea/idea-frontend-fir/testData/referenceResolve/JavaConstructorNotNullParameter.txt index bc6d4937367..f56c1a3aa65 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/JavaConstructorNotNullParameter.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/JavaConstructorNotNullParameter.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(s: kotlin.String) +0: (in JavaClass) constructor(s: kotlin.String) \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.kt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.kt index 15f38f51657..bce001839de 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.kt @@ -2,7 +2,7 @@ package test class Conflict -fun test() { +fun testFoo() { class Conflict Conflict() diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor2.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor2.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor2.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassConstructor2.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.kt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.kt index bcfd753bfec..413cbca32ee 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.kt @@ -2,7 +2,7 @@ package test class Conflict -fun test() { +fun testFoo() { class Conflict Conflict diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.txt index e3082cc5f53..de9dda22292 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelClassVsLocalClassQualifier.txt @@ -1,2 +1,2 @@ Resolved to: -0: class Conflict +0: (in : testFoo) class Conflict \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.kt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.kt index 3627509ac7c..0e5d71673c0 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.kt @@ -10,6 +10,4 @@ fun test() { class Conflict Conflict -} - -// REF: companion object of (test).Conflict \ No newline at end of file +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.txt index e3082cc5f53..0c4af2db10d 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor.txt @@ -1,2 +1,2 @@ Resolved to: -0: class Conflict +0: (in : test) class Conflict \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor2.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor2.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor2.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor2.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassQualifier.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassQualifier.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassQualifier.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassQualifier.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.kt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.kt index a2d44fe887c..592732ca4fc 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.kt @@ -2,10 +2,8 @@ package test object Conflict -fun test() { +fun testFoo() { class Conflict Conflict() } - -// REF: (in test.test).Conflict \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.kt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.kt index 6f88bb7f09a..085e17d47cb 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.kt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.kt @@ -4,7 +4,7 @@ object Conflict { operator fun invoke() {} } -fun test() { +fun testFoo() { class Conflict Conflict() diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.txt index 74737df7591..78a53ae24c7 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassConstructor2.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor() +0: (in test.Conflict) constructor() \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassQualifier.txt b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassQualifier.txt index e3082cc5f53..0c4af2db10d 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassQualifier.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/TopLevelObjectVsLocalClassQualifier.txt @@ -1,2 +1,2 @@ Resolved to: -0: class Conflict +0: (in : test) class Conflict \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/ValueParameter.txt b/idea/idea-frontend-fir/testData/referenceResolve/ValueParameter.txt index f5d72e57f8a..1e795a29ef0 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/ValueParameter.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/ValueParameter.txt @@ -1,2 +1,2 @@ Resolved to: -0: value-parameter x: A +0: value-parameter x: A \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toPrimary.txt b/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toPrimary.txt index 765109b8b9d..ba2d12b0247 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toPrimary.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toPrimary.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(a: kotlin.Int) +0: (in A) constructor(a: kotlin.Int) \ No newline at end of file diff --git a/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toSecondary.txt b/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toSecondary.txt index 0f77ba803c0..37f8a5fada8 100644 --- a/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toSecondary.txt +++ b/idea/idea-frontend-fir/testData/referenceResolve/constructorDelegatingReference/toSecondary.txt @@ -1,2 +1,2 @@ Resolved to: -0: constructor(b: kotlin.String) +0: (in A) constructor(b: kotlin.String) \ No newline at end of file diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/fir/frontend/api/AbstractReferenceResolveTest.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/fir/frontend/api/AbstractReferenceResolveTest.kt index 581b04e3374..b0abf343595 100644 --- a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/fir/frontend/api/AbstractReferenceResolveTest.kt +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/fir/frontend/api/AbstractReferenceResolveTest.kt @@ -13,10 +13,9 @@ import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.analyse import org.jetbrains.kotlin.idea.frontend.api.components.KtDeclarationRendererOptions import org.jetbrains.kotlin.idea.frontend.api.components.RendererModifier -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassLikeSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtConstructorSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.* +import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtNamedSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind import org.jetbrains.kotlin.idea.references.KtReference import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile @@ -86,7 +85,7 @@ abstract class AbstractReferenceResolveTest : AbstractHLApiSingleModuleTest() { private fun KtAnalysisSession.renderResolveResult(symbol: KtSymbol): String { return buildString { - symbolFqName(symbol)?.let { fqName -> + symbolContainerFqName(symbol)?.let { fqName -> append("(in $fqName) ") } append(symbol.render(renderingOptions)) @@ -94,12 +93,23 @@ abstract class AbstractReferenceResolveTest : AbstractHLApiSingleModuleTest() { } @Suppress("unused")// KtAnalysisSession receiver - private fun KtAnalysisSession.symbolFqName(symbol: KtSymbol): String? = when (symbol) { - is KtCallableSymbol -> symbol.callableIdIfNonLocal?.asSingleFqName()?.parent() - is KtClassLikeSymbol -> symbol.classIdIfNonLocal?.asSingleFqName()?.parent() - is KtConstructorSymbol -> symbol.containingClassIdIfNonLocal?.asSingleFqName() - else -> null - }?.let { if (it == FqName.ROOT) "ROOT" else it.asString()} + private fun KtAnalysisSession.symbolContainerFqName(symbol: KtSymbol): String? { + if (symbol is KtPackageSymbol || symbol is KtValueParameterSymbol) return null + val nonLocalFqName = when (symbol) { + is KtConstructorSymbol -> symbol.containingClassIdIfNonLocal?.asSingleFqName() + is KtCallableSymbol -> symbol.callableIdIfNonLocal?.asSingleFqName()?.parent() + is KtClassLikeSymbol -> symbol.classIdIfNonLocal?.asSingleFqName()?.parent() + else -> null + } + when (nonLocalFqName) { + null -> Unit + FqName.ROOT -> return "ROOT" + else -> return nonLocalFqName.asString() + } + val container = (symbol as? KtSymbolWithKind)?.getContainingSymbol() ?: return null + val parents = generateSequence(container) { it.getContainingSymbol() } + return ": " + parents.joinToString(separator = ".") { (it as? KtNamedSymbol)?.name?.asString() ?: "" } + } private object Directives : SimpleDirectivesContainer() { val UNRESOLVED_REFERENCE by directive(