HL API: render local fqNames in reference resolve tests
This commit is contained in:
committed by
teamcityserver
parent
77fcb12af8
commit
91ecaa32e3
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Annotation) constructor()
|
||||
@@ -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 = ...)
|
||||
+1
-1
@@ -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 = ...)
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_FIR
|
||||
package t
|
||||
|
||||
class A {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.A) constructor()
|
||||
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.A) constructor()
|
||||
+1
-1
@@ -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)
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor(s: kotlin.String)
|
||||
0: (in JavaClass) constructor(s: kotlin.String)
|
||||
+1
-1
@@ -2,7 +2,7 @@ package test
|
||||
|
||||
class Conflict
|
||||
|
||||
fun test() {
|
||||
fun testFoo() {
|
||||
class Conflict
|
||||
|
||||
<caret>Conflict()
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
+1
-1
@@ -2,7 +2,7 @@ package test
|
||||
|
||||
class Conflict
|
||||
|
||||
fun test() {
|
||||
fun testFoo() {
|
||||
class Conflict
|
||||
|
||||
<caret>Conflict
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: class Conflict
|
||||
0: (in <local>: testFoo) class Conflict
|
||||
Vendored
+1
-3
@@ -10,6 +10,4 @@ fun test() {
|
||||
class Conflict
|
||||
|
||||
<caret>Conflict
|
||||
}
|
||||
|
||||
// REF: companion object of (test).Conflict
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: class Conflict
|
||||
0: (in <local>: test) class Conflict
|
||||
idea/idea-frontend-fir/testData/referenceResolve/TopLevelCompanionObjectVsLocalClassConstructor2.txt
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
+1
-3
@@ -2,10 +2,8 @@ package test
|
||||
|
||||
object Conflict
|
||||
|
||||
fun test() {
|
||||
fun testFoo() {
|
||||
class Conflict
|
||||
|
||||
<caret>Conflict()
|
||||
}
|
||||
|
||||
// REF: (in test.test).Conflict
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
+1
-1
@@ -4,7 +4,7 @@ object Conflict {
|
||||
operator fun invoke() {}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
fun testFoo() {
|
||||
class Conflict
|
||||
|
||||
<caret>Conflict()
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor()
|
||||
0: (in test.Conflict) constructor()
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: class Conflict
|
||||
0: (in <local>: test) class Conflict
|
||||
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: value-parameter x: A
|
||||
0: value-parameter x: A
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor(a: kotlin.Int)
|
||||
0: (in A) constructor(a: kotlin.Int)
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
Resolved to:
|
||||
0: constructor(b: kotlin.String)
|
||||
0: (in A) constructor(b: kotlin.String)
|
||||
+21
-11
@@ -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 "<local>: " + parents.joinToString(separator = ".") { (it as? KtNamedSymbol)?.name?.asString() ?: "<no name>" }
|
||||
}
|
||||
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val UNRESOLVED_REFERENCE by directive(
|
||||
|
||||
Reference in New Issue
Block a user