Kapt: Support inherited annotations
(cherry picked from commit 02a3e6b)
This commit is contained in:
committed by
Yan Zhulanow
parent
9d340e1b83
commit
8c4fb0a709
+4
-8
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.asJava.findFacadeClass
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.java.model.elements.JeTypeElement
|
||||
import org.jetbrains.kotlin.java.model.internal.getAnnotationsWithInherited
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -190,14 +191,9 @@ internal class AnalysisContext(annotationsMap: MutableMap<String, MutableList<Ps
|
||||
fun analyzeDeclaration(declaration: PsiElement) {
|
||||
if (declaration !is PsiModifierListOwner) return
|
||||
|
||||
//TODO support inherited annotations
|
||||
|
||||
val annotations = declaration.modifierList?.annotations
|
||||
if (annotations != null) {
|
||||
for (annotation in annotations) {
|
||||
val fqName = annotation.qualifiedName ?: continue
|
||||
mutableAnnotationsMap.getOrPut(fqName, { mutableListOf() }).add(declaration)
|
||||
}
|
||||
for (annotation in declaration.getAnnotationsWithInherited()) {
|
||||
val fqName = annotation.qualifiedName ?: return
|
||||
mutableAnnotationsMap.getOrPut(fqName, { mutableListOf() }).add(declaration)
|
||||
}
|
||||
|
||||
if (declaration is PsiClass) {
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class KotlinElements(val javaPsiFacade: JavaPsiFacade, val scope: GlobalSearchSc
|
||||
override fun isDeprecated(e: Element?): Boolean {
|
||||
val deprecated = ((e as? JeElement)?.psi as? PsiDocCommentOwner)?.isDeprecated ?: false
|
||||
if (deprecated) return true
|
||||
return (e as? JeAnnotationOwner)?.annotationOwner?.findAnnotation("java.lang.Deprecated") != null
|
||||
return (e as? JeAnnotationOwner)?.psi?.modifierList?.findAnnotation("java.lang.Deprecated") != null
|
||||
}
|
||||
|
||||
override fun getAllMembers(type: TypeElement) = (type as? JeTypeElement)?.getAllMembers() ?: emptyList()
|
||||
|
||||
Reference in New Issue
Block a user