[LL API] Ignore annotation arguments in 'ContextCollector'

This commit is contained in:
Yan Zhulanow
2023-08-04 18:09:39 +09:00
committed by Space Team
parent 4fbbe9f274
commit b76a388e35
@@ -193,8 +193,6 @@ private class ContextCollectorVisitor(
} }
override fun visitFile(file: FirFile) { override fun visitFile(file: FirFile) {
file.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
context.withFile(file, holder) { context.withFile(file, holder) {
withInterceptor { withInterceptor {
super.visitFile(file) super.visitFile(file)
@@ -203,19 +201,25 @@ private class ContextCollectorVisitor(
} }
override fun visitAnnotationCall(annotationCall: FirAnnotationCall) { override fun visitAnnotationCall(annotationCall: FirAnnotationCall) {
dumpContext(annotationCall.psi, ContextKind.SELF)
context.forAnnotation { context.forAnnotation {
super.visitAnnotationCall(annotationCall) dumpContext(annotationCall.psi, ContextKind.BODY)
// Technically, annotation arguments might contain arbitrary expressions.
// However, such cases are very rare, as it's currently forbidden in Kotlin.
// Here we ignore declarations that might be inside such expressions, avoiding unnecessary tree traversal.
} }
} }
override fun visitRegularClass(regularClass: FirRegularClass) = withProcessor { override fun visitRegularClass(regularClass: FirRegularClass) = withProcessor {
dumpContext(regularClass.psi, ContextKind.SELF) dumpContext(regularClass.psi, ContextKind.SELF)
regularClass.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
processSignatureAnnotations(regularClass) processSignatureAnnotations(regularClass)
context.withContainingClass(regularClass) { context.withContainingClass(regularClass) {
regularClass.lazyResolveToPhase(FirResolvePhase.STATUS)
processList(regularClass.typeParameters) processList(regularClass.typeParameters)
context.withRegularClass(regularClass, holder) { context.withRegularClass(regularClass, holder) {
@@ -237,11 +241,11 @@ private class ContextCollectorVisitor(
override fun visitConstructor(constructor: FirConstructor) = withProcessor { override fun visitConstructor(constructor: FirConstructor) = withProcessor {
dumpContext(constructor.psi, ContextKind.SELF) dumpContext(constructor.psi, ContextKind.SELF)
constructor.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
processSignatureAnnotations(constructor) processSignatureAnnotations(constructor)
context.withConstructor(constructor) { context.withConstructor(constructor) {
constructor.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
val owningClass = context.containerIfAny as? FirRegularClass val owningClass = context.containerIfAny as? FirRegularClass
context.forConstructorParameters(constructor, owningClass, holder) { context.forConstructorParameters(constructor, owningClass, holder) {
processList(constructor.valueParameters) processList(constructor.valueParameters)
@@ -253,7 +257,6 @@ private class ContextCollectorVisitor(
dumpContext(constructor.psi, ContextKind.BODY) dumpContext(constructor.psi, ContextKind.BODY)
onActive { onActive {
constructor.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE)
process(constructor.body) process(constructor.body)
} }
} }
@@ -305,8 +308,6 @@ private class ContextCollectorVisitor(
override fun visitProperty(property: FirProperty) = withProcessor { override fun visitProperty(property: FirProperty) = withProcessor {
dumpContext(property.psi, ContextKind.SELF) dumpContext(property.psi, ContextKind.SELF)
property.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
processSignatureAnnotations(property) processSignatureAnnotations(property)
onActive { onActive {
@@ -369,8 +370,6 @@ private class ContextCollectorVisitor(
override fun visitAnonymousInitializer(anonymousInitializer: FirAnonymousInitializer) = withProcessor { override fun visitAnonymousInitializer(anonymousInitializer: FirAnonymousInitializer) = withProcessor {
dumpContext(anonymousInitializer.psi, ContextKind.SELF) dumpContext(anonymousInitializer.psi, ContextKind.SELF)
anonymousInitializer.lazyResolveToPhase(FirResolvePhase.ANNOTATIONS_ARGUMENTS_MAPPING)
processSignatureAnnotations(anonymousInitializer) processSignatureAnnotations(anonymousInitializer)
context.withAnonymousInitializer(anonymousInitializer, session) { context.withAnonymousInitializer(anonymousInitializer, session) {