don't try to resolve declaration to descriptor if we don't have any annotations
This commit is contained in:
+4
-2
@@ -93,6 +93,9 @@ class KtLightModifierList(
|
|||||||
internal fun computeAnnotations(lightElement: PsiModifierList,
|
internal fun computeAnnotations(lightElement: PsiModifierList,
|
||||||
delegate: PsiAnnotationOwner): CachedValue<Array<out PsiAnnotation>> {
|
delegate: PsiAnnotationOwner): CachedValue<Array<out PsiAnnotation>> {
|
||||||
fun doCompute(): Array<PsiAnnotation> {
|
fun doCompute(): Array<PsiAnnotation> {
|
||||||
|
val delegateAnnotations = delegate.annotations
|
||||||
|
if (delegateAnnotations.isEmpty()) return emptyArray()
|
||||||
|
|
||||||
val lightOwner = lightElement.parent as? KtLightElement<*, *>
|
val lightOwner = lightElement.parent as? KtLightElement<*, *>
|
||||||
val declaration = lightOwner?.kotlinOrigin as? KtDeclaration
|
val declaration = lightOwner?.kotlinOrigin as? KtDeclaration
|
||||||
if (declaration != null && !declaration.isValid) return PsiAnnotation.EMPTY_ARRAY
|
if (declaration != null && !declaration.isValid) return PsiAnnotation.EMPTY_ARRAY
|
||||||
@@ -105,8 +108,7 @@ internal fun computeAnnotations(lightElement: PsiModifierList,
|
|||||||
}
|
}
|
||||||
val ktAnnotations = annotatedDescriptor?.annotations?.getAllAnnotations() ?: emptyList()
|
val ktAnnotations = annotatedDescriptor?.annotations?.getAllAnnotations() ?: emptyList()
|
||||||
var nextIndex = 0
|
var nextIndex = 0
|
||||||
val result = delegate
|
val result = delegateAnnotations
|
||||||
.annotations
|
|
||||||
.map { clsAnnotation ->
|
.map { clsAnnotation ->
|
||||||
val currentIndex = ktAnnotations.indexOfFirst(nextIndex) {
|
val currentIndex = ktAnnotations.indexOfFirst(nextIndex) {
|
||||||
it.annotation.type.constructor.declarationDescriptor?.fqNameUnsafe?.asString() == clsAnnotation.qualifiedName
|
it.annotation.type.constructor.declarationDescriptor?.fqNameUnsafe?.asString() == clsAnnotation.qualifiedName
|
||||||
|
|||||||
Reference in New Issue
Block a user