Introduce AnnotationDescriptor.fqName
Could be used instead of ".annotationClass.fqName" to avoid the unneeded resolution of the annotation class descriptor
This commit is contained in:
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtModifierListOwner
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
interface AnnotationBasedExtension {
|
||||
@@ -45,14 +44,14 @@ interface AnnotationBasedExtension {
|
||||
visitedAnnotations: MutableSet<String> = hashSetOf(),
|
||||
allowMetaAnnotations: Boolean = true
|
||||
): Boolean {
|
||||
val annotationType = annotationClass ?: return false
|
||||
val annotationFqName = annotationType.fqNameSafe.asString()
|
||||
val annotationFqName = fqName?.asString() ?: return false
|
||||
if (annotationFqName in visitedAnnotations) return false // Prevent infinite recursion
|
||||
if (annotationFqName in getAnnotationFqNames(modifierListOwner)) return true
|
||||
|
||||
visitedAnnotations.add(annotationFqName)
|
||||
|
||||
if (allowMetaAnnotations) {
|
||||
val annotationType = annotationClass ?: return false
|
||||
for (metaAnnotation in annotationType.annotations) {
|
||||
if (metaAnnotation.isASpecialAnnotation(modifierListOwner, visitedAnnotations, allowMetaAnnotations = true)) {
|
||||
return true
|
||||
@@ -64,4 +63,4 @@ interface AnnotationBasedExtension {
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getImplicitReceivers
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
@@ -81,7 +80,7 @@ object DslScopeViolationCallChecker : CallChecker {
|
||||
}
|
||||
|
||||
private fun Annotations.extractDslMarkerFqNames() =
|
||||
filter(AnnotationDescriptor::isDslMarker).map { it.annotationClass!!.fqNameSafe }
|
||||
filter(AnnotationDescriptor::isDslMarker).map { it.fqName!! }
|
||||
|
||||
private fun AnnotationDescriptor.isDslMarker(): Boolean {
|
||||
val classDescriptor = annotationClass ?: return false
|
||||
|
||||
Reference in New Issue
Block a user