ClsStubBuilder: fix stub builder in case of java types annotated with special annotations

This commit is contained in:
Pavel V. Talanov
2015-05-18 18:30:14 +03:00
parent 09e7e0da4d
commit 5b14d5be28
6 changed files with 76 additions and 2 deletions
@@ -21,6 +21,7 @@ import com.intellij.psi.stubs.StubElement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
@@ -43,7 +44,10 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
fun createTypeReferenceStub(parent: StubElement<out PsiElement>, typeProto: Type) {
val typeReference = KotlinPlaceHolderStubImpl<JetTypeReference>(parent, JetStubElementTypes.TYPE_REFERENCE)
val typeAnnotations = c.components.annotationLoader.loadTypeAnnotations(typeProto, c.nameResolver)
val typeAnnotations = c.components.annotationLoader.loadTypeAnnotations(typeProto, c.nameResolver).filterNot {
val isTopLevelClass = !it.isNestedClass()
isTopLevelClass && it.asSingleFqName() in JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES
}
if (typeAnnotations.isNotEmpty()) {
createAnnotationStubs(typeAnnotations, typeReference, needWrappingAnnotationEntries = true)
}