Allow to run additional resolve from KtFileAnnotationList
This commit is contained in:
committed by
Nikolay Krasko
parent
0aa8d89b16
commit
5cd23daf4e
@@ -225,6 +225,10 @@ public class ResolveElementCache(
|
|||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (element is KtFileAnnotationList) {
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +283,16 @@ public class ResolveElementCache(
|
|||||||
resolveSession.trace
|
resolveSession.trace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is KtFileAnnotationList -> {
|
||||||
|
val annotationEntry = resolveElement.annotationEntries.firstOrNull()
|
||||||
|
if (annotationEntry != null) {
|
||||||
|
annotationAdditionalResolve(resolveSession, annotationEntry)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolveSession.trace
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is KtAnnotationEntry -> annotationAdditionalResolve(resolveSession, resolveElement)
|
is KtAnnotationEntry -> annotationAdditionalResolve(resolveSession, resolveElement)
|
||||||
|
|
||||||
is KtClass -> constructorAdditionalResolve(resolveSession, resolveElement, file)
|
is KtClass -> constructorAdditionalResolve(resolveSession, resolveElement, file)
|
||||||
|
|||||||
@@ -278,4 +278,26 @@ class C(param1: String = "", param2: Int = 0) {
|
|||||||
val context = annotationEntry.analyze(BodyResolveMode.PARTIAL)
|
val context = annotationEntry.analyze(BodyResolveMode.PARTIAL)
|
||||||
assert(context[BindingContext.ANNOTATION, annotationEntry] != null)
|
assert(context[BindingContext.ANNOTATION, annotationEntry] != null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun testFileAnnotationList() {
|
||||||
|
val file = myFixture.configureByText("Test.kt", """
|
||||||
|
@file:Suppress("Some")
|
||||||
|
@file:JvmName("Hi")
|
||||||
|
""") as KtFile
|
||||||
|
|
||||||
|
val fileAnnotationList = file.fileAnnotationList!!
|
||||||
|
val context = fileAnnotationList.analyze(BodyResolveMode.PARTIAL)
|
||||||
|
assert(context[BindingContext.ANNOTATION, fileAnnotationList.annotationEntries[0]] != null)
|
||||||
|
assert(context[BindingContext.ANNOTATION, fileAnnotationList.annotationEntries[1]] != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun testIncompleteFileAnnotationList() {
|
||||||
|
val file = myFixture.configureByText("Test.kt", """
|
||||||
|
@file
|
||||||
|
import some.hello
|
||||||
|
""") as KtFile
|
||||||
|
|
||||||
|
val fileAnnotationList = file.fileAnnotationList!!
|
||||||
|
fileAnnotationList.analyze(BodyResolveMode.PARTIAL)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user