diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt index 2c5323152ba..514a7eaf95f 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/ContextCollector.kt @@ -335,18 +335,34 @@ private class ContextCollectorVisitor( else -> true } - override fun visitScript(script: FirScript) { - context.withScript(script, holder) { - withInterceptor { - super.visitScript(script) + override fun visitScript(script: FirScript) = withProcessor(script) { + dumpContext(script, ContextKind.SELF) + + processSignatureAnnotations(script) + + onActiveBody { + context.withScript(script, holder) { + dumpContext(script, ContextKind.BODY) + + onActive { + withInterceptor { + processChildren(script) + } + } } } } - override fun visitFile(file: FirFile) { + override fun visitFile(file: FirFile) = withProcessor(file) { context.withFile(file, holder) { - withInterceptor { - super.visitFile(file) + dumpContext(file, ContextKind.SELF) + + processFileHeader(file) + + onActive { + withInterceptor { + processChildren(file) + } } } } @@ -417,6 +433,13 @@ private class ContextCollectorVisitor( } } + @OptIn(PrivateForInline::class) + private fun Processor.processFileHeader(file: FirFile) { + process(file.packageDirective) + processList(file.imports) + process(file.annotationsContainer) + } + /** * Same as [processClassHeader], but for anonymous objects. * diff --git a/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.copy.txt deleted file mode 100644 index 75ab16fd0a0..00000000000 --- a/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.copy.txt +++ /dev/null @@ -1,23 +0,0 @@ -Tower Data Context: - Element 0 - Scope: FirDefaultStarImportingScope - Element 1 - Scope: FirExplicitStarImportingScope - Element 2 - Scope: FirDefaultSimpleImportingScope - Element 3 - Scope: FirDefaultSimpleImportingScope - Element 4 - Scope: FirPackageMemberScope - Element 5 - Scope: FirExplicitSimpleImportingScope - -FILE: [ResolvedTo(IMPORTS)] fileAnnotation.kt - @FILE:R|Anno|[Types]() - [ResolvedTo(STATUS)] annotations container - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public? [ResolvedTo(RAW_FIR)] constructor(): R|Anno| { - LAZY_super - } - - } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.txt b/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.txt index da945e8114b..6e658c8a28a 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.txt @@ -13,10 +13,10 @@ Tower Data Context: Scope: FirExplicitSimpleImportingScope FILE: [ResolvedTo(IMPORTS)] fileAnnotation.kt - @FILE:R|Anno|[Types]() - [ResolvedTo(STATUS)] annotations container - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public [ResolvedTo(STATUS)] constructor(): R|Anno| { + @FILE:Anno[Unresolved]() + [ResolvedTo(RAW_FIR)] annotations container + @Target[Unresolved](LAZY_EXPRESSION) public final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + public? [ResolvedTo(RAW_FIR)] constructor(): R|Anno| { LAZY_super } diff --git a/analysis/low-level-api-fir/testData/contextCollector/fileImport.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/fileImport.copy.txt deleted file mode 100644 index fa335999d10..00000000000 --- a/analysis/low-level-api-fir/testData/contextCollector/fileImport.copy.txt +++ /dev/null @@ -1,24 +0,0 @@ -Tower Data Context: - Element 0 - Scope: FirDefaultStarImportingScope - Element 1 - Scope: FirExplicitStarImportingScope - Element 2 - Scope: FirDefaultSimpleImportingScope - Element 3 - Scope: FirDefaultSimpleImportingScope - Element 4 - Scope: FirPackageMemberScope - Element 5 - Scope: FirExplicitSimpleImportingScope - Import name:Anno - Qualified name: foo.Anno - Is all under: false - -FILE: [ResolvedTo(IMPORTS)] fileImport.kt - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| { - LAZY_super - } - - } diff --git a/analysis/low-level-api-fir/testData/contextCollector/fileImport.txt b/analysis/low-level-api-fir/testData/contextCollector/fileImport.txt index 5919feee0f3..5a26b9f9d9b 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/fileImport.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/fileImport.txt @@ -16,8 +16,8 @@ Tower Data Context: Is all under: false FILE: [ResolvedTo(IMPORTS)] fileImport.kt - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public [ResolvedTo(STATUS)] constructor(): R|foo/Anno| { + @Target[Unresolved](LAZY_EXPRESSION) public final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| { LAZY_super } diff --git a/analysis/low-level-api-fir/testData/contextCollector/filePackage.copy.txt b/analysis/low-level-api-fir/testData/contextCollector/filePackage.copy.txt deleted file mode 100644 index 6cab121921f..00000000000 --- a/analysis/low-level-api-fir/testData/contextCollector/filePackage.copy.txt +++ /dev/null @@ -1,21 +0,0 @@ -Tower Data Context: - Element 0 - Scope: FirDefaultStarImportingScope - Element 1 - Scope: FirExplicitStarImportingScope - Element 2 - Scope: FirDefaultSimpleImportingScope - Element 3 - Scope: FirDefaultSimpleImportingScope - Element 4 - Scope: FirPackageMemberScope - Element 5 - Scope: FirExplicitSimpleImportingScope - -FILE: [ResolvedTo(IMPORTS)] filePackage.kt - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| { - LAZY_super - } - - } diff --git a/analysis/low-level-api-fir/testData/contextCollector/filePackage.txt b/analysis/low-level-api-fir/testData/contextCollector/filePackage.txt index 82e08295fbd..f3d0c08365a 100644 --- a/analysis/low-level-api-fir/testData/contextCollector/filePackage.txt +++ b/analysis/low-level-api-fir/testData/contextCollector/filePackage.txt @@ -13,9 +13,9 @@ Tower Data Context: Scope: FirExplicitSimpleImportingScope FILE: [ResolvedTo(IMPORTS)] filePackage.kt - @R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { - public [ResolvedTo(STATUS)] constructor(): R|foo/Anno| { + @Target[Unresolved](LAZY_EXPRESSION) public final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| { LAZY_super } - } + } \ No newline at end of file