diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index bfee2ac0ac5..29a0eac902b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -225,6 +225,10 @@ public class ResolveElementCache( return element } + if (element is KtFileAnnotationList) { + return element + } + return null } @@ -279,6 +283,16 @@ public class ResolveElementCache( resolveSession.trace } + is KtFileAnnotationList -> { + val annotationEntry = resolveElement.annotationEntries.firstOrNull() + if (annotationEntry != null) { + annotationAdditionalResolve(resolveSession, annotationEntry) + } + else { + resolveSession.trace + } + } + is KtAnnotationEntry -> annotationAdditionalResolve(resolveSession, resolveElement) is KtClass -> constructorAdditionalResolve(resolveSession, resolveElement, file) diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt index d894c559391..1a311bcd2f2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -278,4 +278,26 @@ class C(param1: String = "", param2: Int = 0) { val context = annotationEntry.analyze(BodyResolveMode.PARTIAL) 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) + } }