[Analysis API] Add IGNORE_SELF dangling file resolution mode

In the 'IGNORE_SELF' mode, dangling files don't have their own
declarations in providers. As a result, all references there resolve to
declarations of the original file. It is conceptually similar to that we
had in on-air resolve, however, now it's possible to work with the whole
content of the in-memory 'FirFile'.

As it can be seen in 'ProjectStructureProvider.kt'
(KtFile.danglingFileResolutionMode), the 'IGNORE_SELF' mode is
automatically applied for non-physical files with an original file being
set. For other scenarios, now there is a new 'analyzeCopy()' function
that allows to pass the analysis mode explicitly.
This commit is contained in:
Yan Zhulanow
2023-11-22 18:21:18 +09:00
committed by Space Team
parent ae6b690d4f
commit 452d22e14f
84 changed files with 1394 additions and 50 deletions
@@ -0,0 +1,9 @@
class Foo<Value> {
fun foo() {
call<V<caret>alue>()
}
}
fun <T> call(): T? {
return null
}
@@ -0,0 +1,2 @@
Resolved to:
0: Value [classTypeParameter.kt]
@@ -0,0 +1,9 @@
class Foo {
companion object
}
fun test() {
consume(F<caret>oo)
}
private fun consume(obj: Any) {}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) companion object [companionObject.kt]
@@ -0,0 +1,7 @@
fun <Value> foo() {
call<V<caret>alue>()
}
fun <T> call(): T? {
return null
}
@@ -0,0 +1,2 @@
Resolved to:
0: Value [fake.kt]
@@ -0,0 +1,9 @@
class Foo {
private fun foo() {
class Local {
fun call() {}
}
Lo<caret>cal().call()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: Foo.foo.Local) constructor() [fake.kt]
@@ -0,0 +1,6 @@
class Foo {
private fun foo() {
val name = "Foo"
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: Foo.foo) val name: kotlin.String [fake.kt]
@@ -0,0 +1,9 @@
class Outer {
val foo: String = "foo"
inner class Inner {
fun test() {
f<caret>oo
}
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Outer) val foo: kotlin.String [outerClassProperty.kt]
@@ -0,0 +1,7 @@
class Foo(name: String) {
private val userName: String
init {
userName = n<caret>ame
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: name: kotlin.String [primaryConstructorParameter.kt]
@@ -0,0 +1,9 @@
class Foo {
private class Bar {
fun call() {}
}
private fun foo() {
B<caret>ar().call()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo.Bar) constructor() [privateClass.kt]
@@ -0,0 +1,7 @@
class Foo() {
private fun call() {}
private fun foo() {
c<caret>all()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) private fun call() [privateFunction.kt]
@@ -0,0 +1,5 @@
class Foo(private val name: String) {
private fun foo() {
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) private val name: kotlin.String [privateProperty.kt]
@@ -0,0 +1,7 @@
class Foo() {
fun call() {}
private fun foo() {
c<caret>all()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) fun call() [publicFunction.kt]
@@ -0,0 +1,5 @@
class Foo(val name: String) {
private fun foo() {
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) val name: kotlin.String [publicProperty.kt]
@@ -0,0 +1,3 @@
var x: Int = 0
get() = f<caret>ield + 1
set(value) { field = value - 1 }
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: x) field
@@ -0,0 +1,5 @@
fun foo() {
c<caret>all()
}
fun call() {}
@@ -0,0 +1,2 @@
Resolved to:
0: (in ROOT) fun call() [topLevelFunction.kt]
@@ -0,0 +1,3 @@
fun foo(abc: Int) {
a<caret>bc
}
@@ -0,0 +1,2 @@
Resolved to:
0: abc: kotlin.Int [fake.kt]
@@ -0,0 +1,9 @@
class Foo<Value> {
fun foo() {
call<V<caret>alue>()
}
}
fun <T> call(): T? {
return null
}
@@ -0,0 +1,2 @@
Resolved to:
0: Value [fake.kt]
@@ -0,0 +1,9 @@
class Foo {
companion object
}
fun test() {
consume(F<caret>oo)
}
private fun consume(obj: Any) {}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) companion object [fake.kt]
@@ -0,0 +1,7 @@
fun <Value> foo() {
call<V<caret>alue>()
}
fun <T> call(): T? {
return null
}
@@ -0,0 +1,2 @@
Resolved to:
0: Value [fake.kt]
@@ -0,0 +1,9 @@
class Foo {
private fun foo() {
class Local {
fun call() {}
}
Lo<caret>cal().call()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: Foo.foo.Local) constructor() [fake.kt]
@@ -0,0 +1,6 @@
class Foo {
private fun foo() {
val name = "Foo"
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: Foo.foo) val name: kotlin.String [fake.kt]
@@ -0,0 +1,9 @@
class Outer {
val foo: String = "foo"
inner class Inner {
fun test() {
f<caret>oo
}
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Outer) val foo: kotlin.String [fake.kt]
@@ -0,0 +1,7 @@
class Foo(name: String) {
private val userName: String
init {
userName = n<caret>ame
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: name: kotlin.String [fake.kt]
@@ -0,0 +1,9 @@
class Foo {
private class Bar {
fun call() {}
}
private fun foo() {
B<caret>ar().call()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo.Bar) constructor() [fake.kt]
@@ -0,0 +1,7 @@
class Foo() {
private fun call() {}
private fun foo() {
c<caret>all()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) private fun call() [fake.kt]
@@ -0,0 +1,5 @@
class Foo(private val name: String) {
private fun foo() {
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) private val name: kotlin.String [fake.kt]
@@ -0,0 +1,7 @@
class Foo() {
fun call() {}
private fun foo() {
c<caret>all()
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) fun call() [fake.kt]
@@ -0,0 +1,5 @@
class Foo(val name: String) {
private fun foo() {
nam<caret>e.length
}
}
@@ -0,0 +1,2 @@
Resolved to:
0: (in Foo) val name: kotlin.String [fake.kt]
@@ -0,0 +1,3 @@
var x: Int = 0
get() = f<caret>ield + 1
set(value) { field = value - 1 }
@@ -0,0 +1,2 @@
Resolved to:
0: (in <local>: x) field
@@ -0,0 +1,5 @@
fun foo() {
c<caret>all()
}
fun call() {}
@@ -0,0 +1,2 @@
Resolved to:
0: (in ROOT) fun call() [fake.kt]
@@ -0,0 +1,3 @@
fun foo(abc: Int) {
a<caret>bc
}
@@ -0,0 +1,2 @@
Resolved to:
0: abc: kotlin.Int [fake.kt]