Additional resolve for annotation on top level classes
This commit is contained in:
@@ -90,9 +90,18 @@ public abstract class ElementResolver protected constructor(
|
|||||||
javaClass<JetTypeParameter>(),
|
javaClass<JetTypeParameter>(),
|
||||||
javaClass<JetTypeConstraint>(),
|
javaClass<JetTypeConstraint>(),
|
||||||
javaClass<JetPackageDirective>(),
|
javaClass<JetPackageDirective>(),
|
||||||
javaClass<JetCodeFragment>()) as JetElement? ?: return null
|
javaClass<JetCodeFragment>()) as JetElement?
|
||||||
|
|
||||||
when (elementOfAdditionalResolve) {
|
when (elementOfAdditionalResolve) {
|
||||||
|
null -> {
|
||||||
|
// Case of JetAnnotationEntry on top level class
|
||||||
|
if (element is JetAnnotationEntry) {
|
||||||
|
return element
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
is JetPackageDirective -> return element
|
is JetPackageDirective -> return element
|
||||||
|
|
||||||
is JetParameter -> {
|
is JetParameter -> {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ MyAnnotation("f", "s") fun test1() {}
|
|||||||
|
|
||||||
MyAnnotation("f", "s") class Test1() {}
|
MyAnnotation("f", "s") class Test1() {}
|
||||||
|
|
||||||
|
MyAnnotation("f", "s") val test3 = 1
|
||||||
|
|
||||||
annotation class MyAnnotation(val first: String, val second: String)
|
annotation class MyAnnotation(val first: String, val second: String)
|
||||||
|
|
||||||
// ANNOTATION: MyAnnotation
|
// ANNOTATION: MyAnnotation
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
|
|||||||
import org.jetbrains.kotlin.idea.test.JetLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.JetLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
|
|
||||||
public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() {
|
public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() {
|
||||||
@@ -167,4 +168,17 @@ class C(param1: String = "", param2: Int = 0) {
|
|||||||
assert(bindingContext1 === bindingContext2)
|
assert(bindingContext1 === bindingContext2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun testAnnotationEntry() {
|
||||||
|
val file = myFixture.configureByText("Test.kt", """
|
||||||
|
annotation class A
|
||||||
|
A class B {}
|
||||||
|
""") as JetFile
|
||||||
|
|
||||||
|
val klass = file.getDeclarations()[1] as JetClass
|
||||||
|
val annotationEntry = klass.getAnnotationEntries().single()
|
||||||
|
|
||||||
|
val context = annotationEntry.analyze(BodyResolveMode.PARTIAL)
|
||||||
|
assert(context[BindingContext.ANNOTATION, annotationEntry] != null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user