From 8832865e9a133f7dc4f7a76d2b45563deec0b1ed Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Thu, 31 Aug 2023 23:01:56 +0200 Subject: [PATCH] [LL FIR] simplify FileStructureElement invalidation We can avoid complex reanalyze-base logic and just directly drop outdated data from FileStructureCache ^KT-60611 --- .../fir/file/structure/FileElementFactory.kt | 52 +----- .../api/fir/file/structure/FileStructure.kt | 67 ++++---- .../fir/file/structure/FileStructureCache.kt | 2 + .../file/structure/FileStructureElement.kt | 157 +++--------------- .../LLFirDeclarationModificationService.kt | 20 ++- .../testdata/fileStructure/annonymousClass.kt | 2 +- ...daInsideSuperCallAndExplicitConstructor.kt | 8 +- ...daInsideSuperCallAndImplicitConstructor.kt | 6 +- ...InsideSuperCallFromSecondaryConstructor.kt | 10 +- ...SuperCallFromSingleSecondaryConstructor.kt | 8 +- .../testdata/fileStructure/class.kt | 6 +- .../testdata/fileStructure/class2.kt | 8 +- .../fileStructure/classMemberProperty.kt | 8 +- .../classMemberPropertyScript.kts | 8 +- .../testdata/fileStructure/classScript.kts | 6 +- .../fileStructure/constructorParameter.kt | 2 +- .../fileStructure/constructorParameter2.kt | 2 +- .../constructorParameterWithAnnotations.kt | 4 +- .../testdata/fileStructure/constructors.kt | 6 +- .../fileStructure/constructorsScript.kts | 6 +- .../danglingAnnotationClassLevel.kt | 10 +- .../danglingAnnotationClassLevelScript.kts | 10 +- .../danglingAnnotationTopLevel.kt | 2 +- .../declarationsInPropertyInit.kt | 6 +- .../declarationsInPropertyInitScript.kts | 6 +- .../testdata/fileStructure/enum.kt | 4 +- .../testdata/fileStructure/enumClass.kt | 14 +- .../fileStructure/enumClassScript.kts | 14 +- .../fileStructure/enumClassWithBody.kt | 10 +- .../fileStructure/enumClassWithBodyScript.kts | 10 +- .../testdata/fileStructure/funWithoutTypes.kt | 2 +- .../fileStructure/functionValueParameter.kt | 6 +- .../fileStructure/functionWithImplicitType.kt | 4 +- .../testdata/fileStructure/functionalType.kt | 2 +- .../testdata/fileStructure/initBlock.kt | 4 +- .../fileStructure/initBlockScript.kts | 4 +- .../testdata/fileStructure/lambda.kt | 6 +- .../fileStructure/lambdaInImplicitFunBody.kt | 8 +- .../lambdaInImplicitPropertyBody.kt | 10 +- .../lambdasInWithBodyFunction.kt | 8 +- .../testdata/fileStructure/localClass.kt | 6 +- .../testdata/fileStructure/localClass2.kt | 2 +- .../fileStructure/localClassScript.kts | 6 +- .../localDeclarationsInAccessor.kt | 6 +- .../testdata/fileStructure/localFun.kt | 6 +- .../testdata/fileStructure/localFunScript.kts | 6 +- .../localFunctionWithImplicitType.kt | 2 +- .../testdata/fileStructure/localProperty.kt | 12 +- .../fileStructure/localPropertyScript.kts | 12 +- .../fileStructure/localUnitFunction.kt | 2 +- .../testdata/fileStructure/memberFunctions.kt | 6 +- .../fileStructure/memberProperties.kt | 6 +- .../testdata/fileStructure/memberTypeAlias.kt | 4 +- .../fileStructure/memberTypeAliasScript.kts | 4 +- .../fileStructure/multipleTopLevelClasses.kt | 8 +- ...tipleTopLevelFunctionsWithImplicitTypes.kt | 8 +- .../multipleTopLevelUnitFunctions.kt | 8 +- .../testdata/fileStructure/nestedClases.kt | 8 +- .../fileStructure/nestedClasesWithFun.kt | 8 +- .../testdata/fileStructure/nestedClasses.kt | 12 +- .../fileStructure/nestedClassesScript.kts | 12 +- .../fileStructure/propertyAccessors.kt | 6 +- .../fileStructure/propertyAccessorsScript.kts | 6 +- .../propertyWithGetterAndSetter.kt | 2 +- .../fileStructure/propertyWithSetter.kt | 10 +- .../qualifiedCallInsideSuperCall.kt | 26 +-- .../testdata/fileStructure/script.kts | 12 +- .../fileStructure/secondaryConstructor.kt | 4 +- .../fileStructure/superCallAnnotation.kt | 6 +- .../fileStructure/superCallAnnotation2.kt | 6 +- .../testdata/fileStructure/superClassCall.kt | 16 +- .../fileStructure/superClassCallScript.kts | 16 +- .../testdata/fileStructure/superType.kt | 8 +- .../topLevelExpressionBodyFunWithType.kt | 2 +- ...opLevelExpressionBodyFunWithTypeScript.kts | 2 +- .../topLevelExpressionBodyFunWithoutType.kt | 2 +- ...evelExpressionBodyFunWithoutTypeScript.kts | 2 +- .../fileStructure/topLevelFunWithType.kt | 2 +- .../topLevelFunWithTypeScript.kts | 2 +- .../fileStructure/topLevelProperty.kt | 6 +- .../fileStructure/topLevelPropertyScript.kts | 6 +- .../testdata/fileStructure/topLevelUnitFun.kt | 2 +- .../fileStructure/topLevelUnitFunScript.kts | 2 +- .../testdata/fileStructure/typeAlias.kt | 2 +- .../testdata/fileStructure/withoutName.kt | 18 +- .../fileStructure/withoutNameScript.kts | 18 +- .../AbstractFirContextCollectionTest.kt | 8 +- .../structure/AbstractFileStructureTest.kt | 13 +- 88 files changed, 370 insertions(+), 507 deletions(-) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileElementFactory.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileElementFactory.kt index 167a939b072..d57ee8fda0d 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileElementFactory.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileElementFactory.kt @@ -6,9 +6,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure import com.intellij.psi.PsiElement -import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.KtFakeSourceElementKind -import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirInternals import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents import org.jetbrains.kotlin.analysis.low.level.api.fir.api.collectDesignationWithFile import org.jetbrains.kotlin.analysis.low.level.api.fir.api.targets.LLFirClassWithSpecificMembersResolveTarget @@ -22,48 +20,16 @@ import org.jetbrains.kotlin.psi.psiUtil.isContractDescriptionCallPsiCheck internal object FileElementFactory { fun createFileStructureElement( firDeclaration: FirDeclaration, - ktDeclaration: KtDeclaration, firFile: FirFile, moduleComponents: LLFirModuleResolveComponents, ): FileStructureElement = when { - ktDeclaration is KtNamedFunction && ktDeclaration.isReanalyzableContainer() -> ReanalyzableFunctionStructureElement( - firFile, - ktDeclaration, - (firDeclaration as FirSimpleFunction).symbol, - ktDeclaration.modificationStamp, - moduleComponents, - ) - - ktDeclaration is KtProperty && - (ktDeclaration.isReanalyzableContainer() || ktDeclaration.accessors.any { it.isReanalyzableContainer() }) - -> ReanalyzablePropertyStructureElement( - firFile, - ktDeclaration, - (firDeclaration as FirProperty).symbol, - ktDeclaration.modificationStamp, - moduleComponents, - ) - - ktDeclaration is KtClassOrObject && ktDeclaration !is KtEnumEntry -> { - lazyResolveClassWithGeneratedMembers(firDeclaration as FirRegularClass, moduleComponents) - NonReanalyzableClassDeclarationStructureElement( - firFile, - firDeclaration, - ktDeclaration, - moduleComponents, - ) + firDeclaration is FirRegularClass -> { + lazyResolveClassWithGeneratedMembers(firDeclaration, moduleComponents) + ClassDeclarationStructureElement(firFile, firDeclaration, moduleComponents) } - ktDeclaration is KtScript -> RootScriptStructureElement(firFile, firDeclaration as FirScript, ktDeclaration, moduleComponents) - - else -> { - NonReanalyzableNonClassDeclarationStructureElement( - firFile, - firDeclaration, - ktDeclaration, - moduleComponents, - ) - } + firDeclaration is FirScript -> RootScriptStructureElement(firFile, firDeclaration, moduleComponents) + else -> DeclarationStructureElement(firFile, firDeclaration, moduleComponents) } private fun lazyResolveClassWithGeneratedMembers(firClass: FirRegularClass, moduleComponents: LLFirModuleResolveComponents) { @@ -149,14 +115,6 @@ private fun isInsideContract(body: KtExpression, child: PsiElement): Boolean { return firstStatement.isAncestor(child) } -@TestOnly -internal fun KtDeclaration.isReanalyzableContainer(): Boolean = when (this) { - is KtNamedFunction -> isReanalyzableContainer() - is KtPropertyAccessor -> isReanalyzableContainer() - is KtProperty -> isReanalyzableContainer() - else -> error("Unknown declaration type: ${this::class.simpleName}") -} - private fun KtNamedFunction.isReanalyzableContainer(): Boolean = hasBlockBody() || typeReference != null private fun KtPropertyAccessor.isReanalyzableContainer(): Boolean = isSetter || hasBlockBody() || property.typeReference != null diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructure.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructure.kt index baff67ec23c..84a04c0c73b 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructure.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructure.kt @@ -10,25 +10,25 @@ import com.intellij.psi.PsiErrorElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirModuleResolveComponents import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter +import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.canBePartOfParentDeclaration import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.getNonLocalContainingOrThisDeclaration +import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries import org.jetbrains.kotlin.analysis.low.level.api.fir.util.findSourceByTraversingWholeTree import org.jetbrains.kotlin.analysis.low.level.api.fir.util.findSourceNonLocalFirDeclaration import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic +import org.jetbrains.kotlin.fir.correspondingProperty import org.jetbrains.kotlin.fir.declarations.FirDanglingModifierList import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor import org.jetbrains.kotlin.fir.resolve.providers.firProvider import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.isAncestor -import java.util.concurrent.ConcurrentHashMap -import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.canBePartOfParentDeclaration -import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment -import org.jetbrains.kotlin.fir.correspondingProperty -import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment import org.jetbrains.kotlin.utils.exceptions.withPsiEntry +import java.util.concurrent.ConcurrentHashMap internal class FileStructure private constructor( private val ktFile: KtFile, @@ -49,7 +49,24 @@ internal class FileStructure private constructor( private val structureElements = ConcurrentHashMap() + /** + * Must be called only under write-lock. + * + * This method is responsible for "invalidation" of re-analyzable declarations. + * + * @see LLFirDeclarationModificationService + */ + fun invalidateElement(element: KtElement) { + val container = getContainerKtElement(element) + structureElements.remove(container) + } + fun getStructureElementFor(element: KtElement): FileStructureElement { + val container = getContainerKtElement(element) + return structureElements.getOrPut(container) { createStructureElement(container) } + } + + private fun getContainerKtElement(element: KtElement): KtElement { val declaration = getStructureKtElement(element) val container: KtElement if (declaration != null) { @@ -63,7 +80,7 @@ internal class FileStructure private constructor( } } - return getStructureElementForDeclaration(container) + return container } private fun getStructureKtElement(element: KtElement): KtDeclaration? { @@ -89,31 +106,6 @@ internal class FileStructure private constructor( return false } - private fun getStructureElementForDeclaration(declaration: KtElement): FileStructureElement { - val elementFromCache = structureElements[declaration] - if (elementFromCache == null) { - val newElement = createStructureElement(declaration) - return structureElements.putIfAbsent(declaration, newElement) ?: newElement - } - - if (elementFromCache !is ReanalyzableStructureElement<*, *> || elementFromCache.isUpToDate()) { - return elementFromCache - } - - val reanalyzedElement = elementFromCache.reanalyze() - return structureElements.merge(declaration, reanalyzedElement) { _, oldElement -> - if (oldElement === elementFromCache) { - reanalyzedElement - } else { - // Another thread already reanalyzed the declaration - oldElement - } - } ?: errorWithFirSpecificEntries( - "${reanalyzedElement::class.simpleName} for ${declaration::class.simpleName} is gone", - psi = declaration, - ) - } - fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): Collection { // TODO, KT-60799: Add a new FileStructure for file diagnostics firFile.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) @@ -144,9 +136,7 @@ internal class FileStructure private constructor( override fun visitDeclaration(dcl: KtDeclaration) { val structureElement = getStructureElementFor(dcl) structureElements += structureElement - if (structureElement !is ReanalyzableStructureElement<*, *>) { - dcl.acceptChildren(this) - } + dcl.acceptChildren(this) } override fun visitModifierList(list: KtModifierList) { @@ -175,20 +165,19 @@ internal class FileStructure private constructor( return FileElementFactory.createFileStructureElement( firDeclaration = firDeclaration, - ktDeclaration = declaration, firFile = firFile, moduleComponents = moduleComponents ) } - private fun createDanglingModifierListStructure(container: KtElement): FileStructureElement { + private fun createDanglingModifierListStructure(container: KtModifierList): FileStructureElement { val firDanglingModifierList = container.findSourceByTraversingWholeTree( moduleComponents.firFileBuilder, firFile, ) as? FirDanglingModifierList ?: errorWithFirSpecificEntries("No dangling modifier found", psi = container) firDanglingModifierList.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) - return DanglingTopLevelModifierListStructureElement(firFile, firDanglingModifierList, moduleComponents, container.containingKtFile) + return DeclarationStructureElement(firFile, firDanglingModifierList, moduleComponents) } private fun createStructureElement(container: KtElement): FileStructureElement = when { @@ -196,7 +185,7 @@ internal class FileStructure private constructor( val firCodeFragment = firFile.codeFragment firCodeFragment.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) - ReanalyzableCodeFragmentStructureElement(firFile, container, firCodeFragment.symbol, moduleComponents) + DeclarationStructureElement(firFile, firCodeFragment, moduleComponents) } container is KtFile -> { val firFile = moduleComponents.firFileBuilder.buildRawFirFileWithCaching(ktFile) @@ -210,7 +199,7 @@ internal class FileStructure private constructor( ) } - RootStructureElement(firFile, container, moduleComponents) + RootStructureElement(firFile, moduleComponents) } container is KtDeclaration -> createDeclarationStructure(container) container is KtModifierList && container.nextSibling is PsiErrorElement -> createDanglingModifierListStructure(container) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureCache.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureCache.kt index b9b0a60f0ea..f82c20fd689 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureCache.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureCache.kt @@ -18,4 +18,6 @@ internal class FileStructureCache(private val moduleResolveComponents: LLFirModu fun getFileStructure(ktFile: KtFile): FileStructure = cache.computeIfAbsent(ktFile) { FileStructure.build(ktFile, moduleResolveComponents) } + + fun getCachedFileStructure(ktFile: KtFile): FileStructure? = cache[ktFile] } \ No newline at end of file diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureElement.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureElement.kt index 16176986d45..0b161bf6304 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureElement.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/FileStructureElement.kt @@ -19,16 +19,10 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.correspondingProperty import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirCodeFragmentSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.psi.* -internal sealed class FileStructureElement(val firFile: FirFile, protected val moduleComponents: LLFirModuleResolveComponents) { - abstract val psi: KtAnnotated +internal sealed class FileStructureElement { abstract val mappings: KtToFirMapping abstract val diagnostics: FileStructureElementDiagnostics @@ -38,8 +32,8 @@ internal sealed class FileStructureElement(val firFile: FirFile, protected val m fun recorderFor(fir: FirElement): FirElementsRecorder = when (fir) { is FirFile -> RootStructureElement.Recorder is FirScript -> RootScriptStructureElement.Recorder - is FirRegularClass -> NonReanalyzableClassDeclarationStructureElement.Recorder(fir) - else -> NonReanalyzableNonClassDeclarationStructureElement.Recorder + is FirRegularClass -> ClassDeclarationStructureElement.Recorder(fir) + else -> DeclarationStructureElement.Recorder } } } @@ -120,101 +114,18 @@ internal class KtToFirMapping(firElement: FirElement) { } } -internal sealed class ReanalyzableStructureElement>( - firFile: FirFile, - val firSymbol: S, - moduleComponents: LLFirModuleResolveComponents, -) : FileStructureElement(firFile, moduleComponents) { - abstract override val psi: KtAnnotated - abstract val timestamp: Long - - override val mappings = KtToFirMapping(firSymbol.fir) - - /** - * Recreate [mappings] and [diagnostics] - */ - abstract fun reanalyze(): ReanalyzableStructureElement - - fun isUpToDate(): Boolean = psi.getModificationStamp() == timestamp - - override val diagnostics = FileStructureElementDiagnostics( - firFile, - SingleNonLocalDeclarationDiagnosticRetriever(firSymbol.fir), - moduleComponents, - ) -} - -internal class ReanalyzableCodeFragmentStructureElement( - firFile: FirFile, - override val psi: KtCodeFragment, - firSymbol: FirCodeFragmentSymbol, - moduleComponents: LLFirModuleResolveComponents, -) : ReanalyzableStructureElement(firFile, firSymbol, moduleComponents) { - override val timestamp = psi.modificationStamp - - override fun reanalyze(): ReanalyzableStructureElement { - firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) - return ReanalyzableCodeFragmentStructureElement(firFile, psi, firSymbol, moduleComponents) - } -} - -internal class ReanalyzableFunctionStructureElement( - firFile: FirFile, - override val psi: KtNamedFunction, - firSymbol: FirFunctionSymbol<*>, - override val timestamp: Long, - moduleComponents: LLFirModuleResolveComponents, -) : ReanalyzableStructureElement>(firFile, firSymbol, moduleComponents) { - override fun reanalyze(): ReanalyzableFunctionStructureElement { - firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) - - return ReanalyzableFunctionStructureElement( - firFile, - psi, - firSymbol, - psi.modificationStamp, - moduleComponents, - ) - } -} - -internal class ReanalyzablePropertyStructureElement( - firFile: FirFile, - override val psi: KtProperty, - firSymbol: FirPropertySymbol, - override val timestamp: Long, - moduleComponents: LLFirModuleResolveComponents, -) : ReanalyzableStructureElement(firFile, firSymbol, moduleComponents) { - override fun reanalyze(): ReanalyzablePropertyStructureElement { - firSymbol.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) - - return ReanalyzablePropertyStructureElement( - firFile, - psi, - firSymbol, - psi.modificationStamp, - moduleComponents, - ) - } -} - -internal sealed class NonReanalyzableDeclarationStructureElement( - val firDeclaration: T, - firFile: FirFile, - moduleComponents: LLFirModuleResolveComponents, -) : FileStructureElement(firFile, moduleComponents) { - override val mappings: KtToFirMapping = KtToFirMapping(firDeclaration) +internal sealed class DeclarationBaseStructureElement(val declaration: F) : FileStructureElement() { + override val mappings: KtToFirMapping = KtToFirMapping(declaration) } internal class RootScriptStructureElement( - firFile: FirFile, + file: FirFile, script: FirScript, - override val psi: KtScript, moduleComponents: LLFirModuleResolveComponents, -) : NonReanalyzableDeclarationStructureElement(script, firFile, moduleComponents) { +) : DeclarationBaseStructureElement(script) { override val diagnostics: FileStructureElementDiagnostics = FileStructureElementDiagnostics( - firFile, - ScriptDiagnosticRetriever(firDeclaration), + file, + ScriptDiagnosticRetriever(declaration), moduleComponents, ) @@ -236,15 +147,14 @@ internal fun visitScriptDependentElements(script: FirScript, visitor: Fir } } -internal class NonReanalyzableClassDeclarationStructureElement( - firFile: FirFile, - fir: FirRegularClass, - override val psi: KtClassOrObject, +internal class ClassDeclarationStructureElement( + file: FirFile, + clazz: FirRegularClass, moduleComponents: LLFirModuleResolveComponents, -) : NonReanalyzableDeclarationStructureElement(fir, firFile, moduleComponents) { +) : DeclarationBaseStructureElement(clazz) { override val diagnostics = FileStructureElementDiagnostics( - firFile, - ClassDiagnosticRetriever(firDeclaration), + file, + ClassDiagnosticRetriever(declaration), moduleComponents, ) @@ -263,7 +173,7 @@ internal class NonReanalyzableClassDeclarationStructureElement( (constructor is FirPrimaryConstructor || constructor is FirErrorPrimaryConstructor) && constructor.source?.kind == KtFakeSourceElementKind.ImplicitConstructor ) { - NonReanalyzableNonClassDeclarationStructureElement.Recorder.visitConstructor(constructor, data) + DeclarationStructureElement.Recorder.visitConstructor(constructor, data) } } @@ -283,15 +193,14 @@ internal class NonReanalyzableClassDeclarationStructureElement( } } -internal class NonReanalyzableNonClassDeclarationStructureElement( - firFile: FirFile, - fir: FirDeclaration, - override val psi: KtDeclaration, +internal class DeclarationStructureElement( + file: FirFile, + declaration: FirDeclaration, moduleComponents: LLFirModuleResolveComponents, -) : NonReanalyzableDeclarationStructureElement(fir, firFile, moduleComponents) { +) : DeclarationBaseStructureElement(declaration) { override val diagnostics = FileStructureElementDiagnostics( - firFile, - SingleNonLocalDeclarationDiagnosticRetriever(firDeclaration), + file, + SingleNonLocalDeclarationDiagnosticRetriever(declaration), moduleComponents, ) @@ -310,26 +219,12 @@ internal class NonReanalyzableNonClassDeclarationStructureElement( } } -internal class DanglingTopLevelModifierListStructureElement( - firFile: FirFile, - fir: FirDanglingModifierList, - moduleComponents: LLFirModuleResolveComponents, - override val psi: KtAnnotated, -) : NonReanalyzableDeclarationStructureElement(fir, firFile, moduleComponents) { - override val diagnostics = FileStructureElementDiagnostics( - firFile, - SingleNonLocalDeclarationDiagnosticRetriever(firDeclaration), - moduleComponents, - ) -} - internal class RootStructureElement( - firFile: FirFile, - override val psi: KtFile, + val file: FirFile, moduleComponents: LLFirModuleResolveComponents, -) : FileStructureElement(firFile, moduleComponents) { - override val mappings = KtToFirMapping(firFile) - override val diagnostics = FileStructureElementDiagnostics(firFile, FileDiagnosticRetriever, moduleComponents) +) : FileStructureElement() { + override val mappings = KtToFirMapping(file) + override val diagnostics = FileStructureElementDiagnostics(file, FileDiagnosticRetriever, moduleComponents) object Recorder : FirElementsRecorder() { override fun visitElement(element: FirElement, data: MutableMap) { diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/LLFirDeclarationModificationService.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/LLFirDeclarationModificationService.kt index 6c1440b86ce..8450fca1f62 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/LLFirDeclarationModificationService.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/LLFirDeclarationModificationService.kt @@ -15,6 +15,8 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getFirResolveSession import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile import org.jetbrains.kotlin.analysis.low.level.api.fir.api.resolveToFirSymbol import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.LLFirDeclarationModificationService.ModificationType +import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirResolvableModuleSession +import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.llFirResolvableSession import org.jetbrains.kotlin.analysis.low.level.api.fir.util.codeFragment import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider @@ -24,6 +26,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.psi.KtAnnotated import org.jetbrains.kotlin.psi.KtCodeFragment import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtElement /** * This service is responsible for processing incoming [PsiElement] changes to reflect them on FIR tree. @@ -67,7 +70,7 @@ class LLFirDeclarationModificationService(val project: Project) { } } - private fun inBlockModification(declaration: PsiElement) { + private fun inBlockModification(declaration: KtElement) { val ktModule = ProjectStructureProvider.getModule(project, declaration, contextualModule = null) val resolveSession = ktModule.getFirResolveSession(project) val firDeclaration = when (declaration) { @@ -80,6 +83,21 @@ class LLFirDeclarationModificationService(val project: Project) { } invalidateAfterInBlockModification(firDeclaration) + + val moduleSession = firDeclaration.llFirResolvableSession ?: errorWithFirSpecificEntries( + "${LLFirResolvableModuleSession::class.simpleName} is not found", + fir = firDeclaration, + psi = declaration, + ) { + withEntry("session", resolveSession) { it.toString() } + } + + val fileStructure = moduleSession.moduleComponents + .fileStructureCache + .getCachedFileStructure(declaration.containingKtFile) + ?: return // we do not have a cache for this file + + fileStructure.invalidateElement(declaration) } private fun outOfBlockModification(element: PsiElement) { diff --git a/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.kt b/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.kt index 15b8eac3f0b..db76a10b6a2 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/annonymousClass.kt @@ -1,4 +1,4 @@ -fun x() {/* ReanalyzableFunctionStructureElement */ +fun x() {/* DeclarationStructureElement */ val x = object: Any() { fun foo(){} } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.kt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.kt index 614bac2e664..c114acc5f14 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndExplicitConstructor.kt @@ -1,7 +1,7 @@ -open class B(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +open class B(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ -class A()/* NonReanalyzableNonClassDeclarationStructureElement */ : B(1, { +class A()/* DeclarationStructureElement */ : B(1, { foo() -})/* NonReanalyzableClassDeclarationStructureElement */ +})/* ClassDeclarationStructureElement */ -fun foo() {/* ReanalyzableFunctionStructureElement */} +fun foo() {/* DeclarationStructureElement */} diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.kt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.kt index a59faab2494..18a7aa8c3cb 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallAndImplicitConstructor.kt @@ -1,7 +1,7 @@ -open class B(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +open class B(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ class A : B(1, { foo() -})/* NonReanalyzableClassDeclarationStructureElement */ +})/* ClassDeclarationStructureElement */ -fun foo() {/* ReanalyzableFunctionStructureElement */} +fun foo() {/* DeclarationStructureElement */} diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt index b40011374a6..9dfa9b5754d 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSecondaryConstructor.kt @@ -1,17 +1,17 @@ -open class A(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +open class A(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ -class B : A {/* NonReanalyzableClassDeclarationStructureElement */ +class B : A {/* ClassDeclarationStructureElement */ constructor(i: Int) : super( { foo(i) } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ constructor(l: Long) : super( { foo(l) } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } -fun foo(any: Any) {/* ReanalyzableFunctionStructureElement */} +fun foo(any: Any) {/* DeclarationStructureElement */} diff --git a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt index fb14cf30b54..2fd90d9d7d4 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/callInsideLambdaInsideSuperCallFromSingleSecondaryConstructor.kt @@ -1,11 +1,11 @@ -open class A(x: () -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +open class A(x: () -> Unit)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ -class B : A {/* NonReanalyzableClassDeclarationStructureElement */ +class B : A {/* ClassDeclarationStructureElement */ constructor(i: Int) : super( { foo(i) } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } -fun foo(any: Any) {/* ReanalyzableFunctionStructureElement */} +fun foo(any: Any) {/* DeclarationStructureElement */} diff --git a/analysis/low-level-api-fir/testdata/fileStructure/class.kt b/analysis/low-level-api-fir/testdata/fileStructure/class.kt index 041931d6ece..2577b38eb33 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/class.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/class.kt @@ -1,6 +1,6 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun x() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun x() {/* DeclarationStructureElement */ } - fun y(): Int = 10/* ReanalyzableFunctionStructureElement */ + fun y(): Int = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/class2.kt b/analysis/low-level-api-fir/testdata/fileStructure/class2.kt index c37daaecbf6..e0a29695948 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/class2.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/class2.kt @@ -1,8 +1,8 @@ -class B {/* NonReanalyzableClassDeclarationStructureElement */ - fun q(): C {/* ReanalyzableFunctionStructureElement */} - private val y = q()/* NonReanalyzableNonClassDeclarationStructureElement */ +class B {/* ClassDeclarationStructureElement */ + fun q(): C {/* DeclarationStructureElement */} + private val y = q()/* DeclarationStructureElement */ fun foo(a: A) = with(a) { bar("a", y) - }/* NonReanalyzableNonClassDeclarationStructureElement */ + }/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.kt b/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.kt index 1f7dda523f8..fbd08ff401c 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/classMemberProperty.kt @@ -1,11 +1,11 @@ -class X {/* NonReanalyzableClassDeclarationStructureElement */ - var x: Int/* ReanalyzablePropertyStructureElement */ +class X {/* ClassDeclarationStructureElement */ + var x: Int/* DeclarationStructureElement */ get() = field set(value) { field = value } - val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */ + val y = 42/* DeclarationStructureElement */ - var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */ + var z: Int = 15/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.kts index db23d41206a..c31e475352c 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/classMemberPropertyScript.kts @@ -1,11 +1,11 @@ -/* RootScriptStructureElement */class X {/* NonReanalyzableClassDeclarationStructureElement */ - var x: Int/* ReanalyzablePropertyStructureElement */ +/* RootScriptStructureElement */class X {/* ClassDeclarationStructureElement */ + var x: Int/* DeclarationStructureElement */ get() = field set(value) { field = value } - val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */ + val y = 42/* DeclarationStructureElement */ - var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */ + var z: Int = 15/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/classScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/classScript.kts index 2a66686e3c9..dd8e07ab169 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/classScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/classScript.kts @@ -1,6 +1,6 @@ -/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun x() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */ + fun x() {/* DeclarationStructureElement */ } - fun y(): Int = 10/* ReanalyzableFunctionStructureElement */ + fun y(): Int = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter.kt b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter.kt index eb0073b1d28..203552015b4 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter.kt @@ -1 +1 @@ -class A(var x: Int)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +class A(var x: Int)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter2.kt b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter2.kt index 64a064fa847..da9071ca625 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter2.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameter2.kt @@ -1 +1 @@ -class A(val x: String)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +class A(val x: String)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameterWithAnnotations.kt b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameterWithAnnotations.kt index a3f96d208ab..286950c2019 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/constructorParameterWithAnnotations.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/constructorParameterWithAnnotations.kt @@ -5,6 +5,6 @@ class A( @field:Ann @property:Ann var x: Int -)/* NonReanalyzableNonClassDeclarationStructureElement *//* NonReanalyzableClassDeclarationStructureElement */ +)/* DeclarationStructureElement *//* ClassDeclarationStructureElement */ -annotation class Ann/* NonReanalyzableClassDeclarationStructureElement */ +annotation class Ann/* ClassDeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/constructors.kt b/analysis/low-level-api-fir/testdata/fileStructure/constructors.kt index 3a5b564ff9d..f37eb1c65e5 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/constructors.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/constructors.kt @@ -1,9 +1,9 @@ class A - (val a: Int)/* NonReanalyzableNonClassDeclarationStructureElement */ + (val a: Int)/* DeclarationStructureElement */ -{/* NonReanalyzableClassDeclarationStructureElement */ - constructor() : this(1) {/* NonReanalyzableNonClassDeclarationStructureElement */ +{/* ClassDeclarationStructureElement */ + constructor() : this(1) {/* DeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/constructorsScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/constructorsScript.kts index 3f3f19280c3..b8d63f8318b 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/constructorsScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/constructorsScript.kts @@ -1,9 +1,9 @@ /* RootScriptStructureElement */class A - (val a: Int)/* NonReanalyzableNonClassDeclarationStructureElement */ + (val a: Int)/* DeclarationStructureElement */ -{/* NonReanalyzableClassDeclarationStructureElement */ - constructor() : this(1) {/* NonReanalyzableNonClassDeclarationStructureElement */ +{/* ClassDeclarationStructureElement */ + constructor() : this(1) {/* DeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevel.kt b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevel.kt index 3e546f4338c..d0d756f8479 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevel.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevel.kt @@ -1,14 +1,14 @@ -class Foo {/* NonReanalyzableClassDeclarationStructureElement */ +class Foo {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } -class Bar {/* NonReanalyzableClassDeclarationStructureElement */ +class Bar {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } -class Outer {/* NonReanalyzableClassDeclarationStructureElement */ - class Inner {/* NonReanalyzableClassDeclarationStructureElement */ +class Outer {/* ClassDeclarationStructureElement */ + class Inner {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } - fun foo() {/* ReanalyzableFunctionStructureElement */ + fun foo() {/* DeclarationStructureElement */ class Local { @Suppress("") @MustBeDocumented } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevelScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevelScript.kts index 271c7224223..b345f68d6b6 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevelScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationClassLevelScript.kts @@ -1,14 +1,14 @@ -/* RootScriptStructureElement */class Foo {/* NonReanalyzableClassDeclarationStructureElement */ +/* RootScriptStructureElement */class Foo {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } -class Bar {/* NonReanalyzableClassDeclarationStructureElement */ +class Bar {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } -class Outer {/* NonReanalyzableClassDeclarationStructureElement */ - class Inner {/* NonReanalyzableClassDeclarationStructureElement */ +class Outer {/* ClassDeclarationStructureElement */ + class Inner {/* ClassDeclarationStructureElement */ @Suppress("") @MustBeDocumented } - fun foo() {/* ReanalyzableFunctionStructureElement */ + fun foo() {/* DeclarationStructureElement */ class Local { @Suppress("") @MustBeDocumented } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationTopLevel.kt b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationTopLevel.kt index dd22e44a5ff..c33724a8205 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationTopLevel.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/danglingAnnotationTopLevel.kt @@ -1 +1 @@ -@Suppress("") @MustBeDocumented/* DanglingTopLevelModifierListStructureElement */ +@Suppress("") @MustBeDocumented/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInit.kt b/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInit.kt index fab11fac7d5..eb4f7e2d2fe 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInit.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInit.kt @@ -1,11 +1,11 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ val a = myRun { class X() val y = 10 - }/* NonReanalyzableNonClassDeclarationStructureElement */ + }/* DeclarationStructureElement */ } -inline fun myRun(block: () -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun myRun(block: () -> R): R {/* DeclarationStructureElement */ return block() } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInitScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInitScript.kts index 34a370e0c7d..7ace23a45e9 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInitScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/declarationsInPropertyInitScript.kts @@ -1,11 +1,11 @@ -/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */ +/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */ val a = run { class X() val y = 10 - }/* NonReanalyzableNonClassDeclarationStructureElement */ + }/* DeclarationStructureElement */ } -inline fun run(block: () -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun run(block: () -> R): R {/* DeclarationStructureElement */ return block() } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/enum.kt b/analysis/low-level-api-fir/testdata/fileStructure/enum.kt index dfc6e261e41..f7def2256b0 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/enum.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/enum.kt @@ -1,3 +1,3 @@ -enum class Enum(val x: Int)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */ - A(1),/* NonReanalyzableNonClassDeclarationStructureElement */ +enum class Enum(val x: Int)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */ + A(1),/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/enumClass.kt b/analysis/low-level-api-fir/testdata/fileStructure/enumClass.kt index 6677be3c428..fdbbc0a88c0 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/enumClass.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/enumClass.kt @@ -1,13 +1,13 @@ -enum class A {/* NonReanalyzableClassDeclarationStructureElement */ - X,/* NonReanalyzableNonClassDeclarationStructureElement */ - Y,/* NonReanalyzableNonClassDeclarationStructureElement */ +enum class A {/* ClassDeclarationStructureElement */ + X,/* DeclarationStructureElement */ + Y,/* DeclarationStructureElement */ Z - ;/* NonReanalyzableNonClassDeclarationStructureElement */ + ;/* DeclarationStructureElement */ - fun foo(){/* ReanalyzableFunctionStructureElement */} + fun foo(){/* DeclarationStructureElement */} - val x = 10/* NonReanalyzableNonClassDeclarationStructureElement */ + val x = 10/* DeclarationStructureElement */ - fun bar() = 10/* NonReanalyzableNonClassDeclarationStructureElement */ + fun bar() = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/enumClassScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/enumClassScript.kts index a77174ff7f1..3134afcfbdc 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/enumClassScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/enumClassScript.kts @@ -1,13 +1,13 @@ -/* RootScriptStructureElement */enum class A {/* NonReanalyzableClassDeclarationStructureElement */ - X,/* NonReanalyzableNonClassDeclarationStructureElement */ - Y,/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */enum class A {/* ClassDeclarationStructureElement */ + X,/* DeclarationStructureElement */ + Y,/* DeclarationStructureElement */ Z - ;/* NonReanalyzableNonClassDeclarationStructureElement */ + ;/* DeclarationStructureElement */ - fun foo(){/* ReanalyzableFunctionStructureElement */} + fun foo(){/* DeclarationStructureElement */} - val x = 10/* NonReanalyzableNonClassDeclarationStructureElement */ + val x = 10/* DeclarationStructureElement */ - fun bar() = 10/* NonReanalyzableNonClassDeclarationStructureElement */ + fun bar() = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBody.kt b/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBody.kt index 2f48e86447b..15f9ae546b6 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBody.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBody.kt @@ -1,13 +1,13 @@ -enum class A {/* NonReanalyzableClassDeclarationStructureElement */ - X {/* NonReanalyzableNonClassDeclarationStructureElement */ +enum class A {/* ClassDeclarationStructureElement */ + X {/* DeclarationStructureElement */ fun localInX() = 1 }, - Y {/* NonReanalyzableNonClassDeclarationStructureElement */ + Y {/* DeclarationStructureElement */ override fun foo() {} }, Z, - ;/* NonReanalyzableNonClassDeclarationStructureElement */ + ;/* DeclarationStructureElement */ - open fun foo() {/* ReanalyzableFunctionStructureElement */} + open fun foo() {/* DeclarationStructureElement */} } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBodyScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBodyScript.kts index 6428cd508b1..c4ed3476c64 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBodyScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/enumClassWithBodyScript.kts @@ -1,13 +1,13 @@ -/* RootScriptStructureElement */enum class A {/* NonReanalyzableClassDeclarationStructureElement */ - X {/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */enum class A {/* ClassDeclarationStructureElement */ + X {/* DeclarationStructureElement */ fun localInX() = 1 }, - Y {/* NonReanalyzableNonClassDeclarationStructureElement */ + Y {/* DeclarationStructureElement */ override fun foo() {} }, Z, - ;/* NonReanalyzableNonClassDeclarationStructureElement */ + ;/* DeclarationStructureElement */ - open fun foo() {/* ReanalyzableFunctionStructureElement */} + open fun foo() {/* DeclarationStructureElement */} } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/funWithoutTypes.kt b/analysis/low-level-api-fir/testdata/fileStructure/funWithoutTypes.kt index 56096c5b9ac..b52840442dc 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/funWithoutTypes.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/funWithoutTypes.kt @@ -1,3 +1,3 @@ -fun main() {/* ReanalyzableFunctionStructureElement */ +fun main() {/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/functionValueParameter.kt b/analysis/low-level-api-fir/testdata/fileStructure/functionValueParameter.kt index f31b9fe02b0..284541796ca 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/functionValueParameter.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/functionValueParameter.kt @@ -1,9 +1,9 @@ -fun bar(a: Int, b: (Boolean) -> Unit) {/* ReanalyzableFunctionStructureElement */ +fun bar(a: Int, b: (Boolean) -> Unit) {/* DeclarationStructureElement */ } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun foo(x: String, y: () -> String) {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun foo(x: String, y: () -> String) {/* DeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/functionWithImplicitType.kt b/analysis/low-level-api-fir/testdata/fileStructure/functionWithImplicitType.kt index 5d6cc0a7fac..615a6aaab17 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/functionWithImplicitType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/functionWithImplicitType.kt @@ -1,5 +1,5 @@ import java.util.Collections -fun checkSubtype(t: T) = t/* NonReanalyzableNonClassDeclarationStructureElement */ +fun checkSubtype(t: T) = t/* DeclarationStructureElement */ -val ab = checkSubtype?>(Collections.emptyList())/* NonReanalyzableNonClassDeclarationStructureElement */ +val ab = checkSubtype?>(Collections.emptyList())/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/functionalType.kt b/analysis/low-level-api-fir/testdata/fileStructure/functionalType.kt index 18d61b7d508..1cb7ed65c61 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/functionalType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/functionalType.kt @@ -1,3 +1,3 @@ -class A(val x: Int = 10, val b: String)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */ +class A(val x: Int = 10, val b: String)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/initBlock.kt b/analysis/low-level-api-fir/testdata/fileStructure/initBlock.kt index b144376ca16..3f72d07ed4c 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/initBlock.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/initBlock.kt @@ -1,5 +1,5 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - init {/* NonReanalyzableNonClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ + init {/* DeclarationStructureElement */ val x = 10 class B } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/initBlockScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/initBlockScript.kts index 552f6ea5649..e2b2c8711e3 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/initBlockScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/initBlockScript.kts @@ -1,5 +1,5 @@ -/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */ - init {/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */ + init {/* DeclarationStructureElement */ val x = 10 class B } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/lambda.kt b/analysis/low-level-api-fir/testdata/fileStructure/lambda.kt index 8bbab97282a..00c05f87703 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/lambda.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/lambda.kt @@ -2,12 +2,12 @@ val x = myRun { val inLambda = 10 println(inLambda) inLambda -}/* NonReanalyzableNonClassDeclarationStructureElement */ +}/* DeclarationStructureElement */ -fun println(any: Any) {/* ReanalyzableFunctionStructureElement */ +fun println(any: Any) {/* DeclarationStructureElement */ } -inline fun myRun(block: () -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun myRun(block: () -> R): R {/* DeclarationStructureElement */ return block() } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitFunBody.kt b/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitFunBody.kt index d3783f7dbd6..4ae53432c7f 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitFunBody.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitFunBody.kt @@ -1,13 +1,13 @@ -inline fun with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */ return receiver.block() } -inline fun T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun T.let(block: (T) -> R): R {/* DeclarationStructureElement */ return block(this) } -class B {/* NonReanalyzableClassDeclarationStructureElement */ +class B {/* ClassDeclarationStructureElement */ fun foo(a: Int) = with(a) { toString().let { it } - }/* NonReanalyzableNonClassDeclarationStructureElement */ + }/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitPropertyBody.kt b/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitPropertyBody.kt index 7f4f3ada3fd..7b18251a1b3 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitPropertyBody.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/lambdaInImplicitPropertyBody.kt @@ -1,14 +1,14 @@ -inline fun with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */ return receiver.block() } -inline fun T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun T.let(block: (T) -> R): R {/* DeclarationStructureElement */ return block(this) } -class B {/* NonReanalyzableClassDeclarationStructureElement */ - val a: Int = 10/* NonReanalyzableNonClassDeclarationStructureElement */ +class B {/* ClassDeclarationStructureElement */ + val a: Int = 10/* DeclarationStructureElement */ val x = with(a) { toString().let { it } - }/* NonReanalyzableNonClassDeclarationStructureElement */ + }/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/lambdasInWithBodyFunction.kt b/analysis/low-level-api-fir/testdata/fileStructure/lambdasInWithBodyFunction.kt index 6348aa7df74..f7f96450514 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/lambdasInWithBodyFunction.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/lambdasInWithBodyFunction.kt @@ -1,13 +1,13 @@ -inline fun with(receiver: T, block: T.() -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun with(receiver: T, block: T.() -> R): R {/* DeclarationStructureElement */ return receiver.block() } -inline fun T.let(block: (T) -> R): R {/* ReanalyzableFunctionStructureElement */ +inline fun T.let(block: (T) -> R): R {/* DeclarationStructureElement */ return block(this) } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun foo() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun foo() {/* DeclarationStructureElement */ val a = with(1) { this.let { it } }.let { 2 } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localClass.kt b/analysis/low-level-api-fir/testdata/fileStructure/localClass.kt index c6d93243c00..34962b19f78 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localClass.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localClass.kt @@ -1,9 +1,9 @@ -fun a() {/* ReanalyzableFunctionStructureElement */ +fun a() {/* DeclarationStructureElement */ class X } -class Y {/* NonReanalyzableClassDeclarationStructureElement */ - fun b() {/* ReanalyzableFunctionStructureElement */ +class Y {/* ClassDeclarationStructureElement */ + fun b() {/* DeclarationStructureElement */ class Z } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localClass2.kt b/analysis/low-level-api-fir/testdata/fileStructure/localClass2.kt index a7d4df8e5e0..414e1022907 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localClass2.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localClass2.kt @@ -1,4 +1,4 @@ -fun x() {/* ReanalyzableFunctionStructureElement */ +fun x() {/* DeclarationStructureElement */ class Local { fun foo(){} } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localClassScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/localClassScript.kts index f7a3ce234b1..72402c43f32 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localClassScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/localClassScript.kts @@ -1,9 +1,9 @@ -/* RootScriptStructureElement */fun a() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun a() {/* DeclarationStructureElement */ class X } -class Y {/* NonReanalyzableClassDeclarationStructureElement */ - fun b() {/* ReanalyzableFunctionStructureElement */ +class Y {/* ClassDeclarationStructureElement */ + fun b() {/* DeclarationStructureElement */ class Z } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localDeclarationsInAccessor.kt b/analysis/low-level-api-fir/testdata/fileStructure/localDeclarationsInAccessor.kt index 540312cdaa4..0bf08d902e0 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localDeclarationsInAccessor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localDeclarationsInAccessor.kt @@ -1,5 +1,5 @@ -class Outer {/* NonReanalyzableClassDeclarationStructureElement */ - val i: Int = 1/* ReanalyzablePropertyStructureElement */ +class Outer {/* ClassDeclarationStructureElement */ + val i: Int = 1/* DeclarationStructureElement */ get() { class Inner { var i: Int = 2 @@ -20,7 +20,7 @@ class Outer {/* NonReanalyzableClassDeclarationStructureElement */ return field } - val j: Int = 4/* ReanalyzablePropertyStructureElement */ + val j: Int = 4/* DeclarationStructureElement */ get() { fun local() { field++ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localFun.kt b/analysis/low-level-api-fir/testdata/fileStructure/localFun.kt index 2b989f5182e..7a83b107c84 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localFun.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localFun.kt @@ -1,11 +1,11 @@ -fun x() {/* ReanalyzableFunctionStructureElement */ +fun x() {/* DeclarationStructureElement */ fun y() { } } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun z() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun z() {/* DeclarationStructureElement */ fun q() { } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localFunScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/localFunScript.kts index 2fb962fa070..0f36253589d 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localFunScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/localFunScript.kts @@ -1,11 +1,11 @@ -/* RootScriptStructureElement */fun x() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun x() {/* DeclarationStructureElement */ fun y() { } } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun z() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun z() {/* DeclarationStructureElement */ fun q() { } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localFunctionWithImplicitType.kt b/analysis/low-level-api-fir/testdata/fileStructure/localFunctionWithImplicitType.kt index 02d88fba7cb..f556a7aaba0 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localFunctionWithImplicitType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localFunctionWithImplicitType.kt @@ -1,3 +1,3 @@ -fun foo() {/* ReanalyzableFunctionStructureElement */ +fun foo() {/* DeclarationStructureElement */ fun local() = 0 } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localProperty.kt b/analysis/low-level-api-fir/testdata/fileStructure/localProperty.kt index bb957e60a81..44e7715e6cb 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localProperty.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localProperty.kt @@ -1,14 +1,14 @@ -fun foo() {/* ReanalyzableFunctionStructureElement */ +fun foo() {/* DeclarationStructureElement */ var x: Int } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun q() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun q() {/* DeclarationStructureElement */ val y = 42 } } -class B {/* NonReanalyzableClassDeclarationStructureElement */ - class C {/* NonReanalyzableClassDeclarationStructureElement */ - fun u() {/* ReanalyzableFunctionStructureElement */ +class B {/* ClassDeclarationStructureElement */ + class C {/* ClassDeclarationStructureElement */ + fun u() {/* DeclarationStructureElement */ var z: Int = 15 } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localPropertyScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/localPropertyScript.kts index 5ecd4fa1d87..163ad5e0bf7 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localPropertyScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/localPropertyScript.kts @@ -1,14 +1,14 @@ -/* RootScriptStructureElement */fun foo() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun foo() {/* DeclarationStructureElement */ var x: Int } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun q() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun q() {/* DeclarationStructureElement */ val y = 42 } } -class B {/* NonReanalyzableClassDeclarationStructureElement */ - class C {/* NonReanalyzableClassDeclarationStructureElement */ - fun u() {/* ReanalyzableFunctionStructureElement */ +class B {/* ClassDeclarationStructureElement */ + class C {/* ClassDeclarationStructureElement */ + fun u() {/* DeclarationStructureElement */ var z: Int = 15 } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/localUnitFunction.kt b/analysis/low-level-api-fir/testdata/fileStructure/localUnitFunction.kt index cdad4424242..42fc44e492e 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/localUnitFunction.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/localUnitFunction.kt @@ -1,4 +1,4 @@ -fun foo() {/* ReanalyzableFunctionStructureElement */ +fun foo() {/* DeclarationStructureElement */ fun local() { println("local") } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/memberFunctions.kt b/analysis/low-level-api-fir/testdata/fileStructure/memberFunctions.kt index cb071f7efc9..aef9dc59f8d 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/memberFunctions.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/memberFunctions.kt @@ -1,7 +1,7 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun foo1() = 10/* NonReanalyzableNonClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun foo1() = 10/* DeclarationStructureElement */ - fun foo2() {/* ReanalyzableFunctionStructureElement */ + fun foo2() {/* DeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/memberProperties.kt b/analysis/low-level-api-fir/testdata/fileStructure/memberProperties.kt index cb071f7efc9..aef9dc59f8d 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/memberProperties.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/memberProperties.kt @@ -1,7 +1,7 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun foo1() = 10/* NonReanalyzableNonClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun foo1() = 10/* DeclarationStructureElement */ - fun foo2() {/* ReanalyzableFunctionStructureElement */ + fun foo2() {/* DeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAlias.kt b/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAlias.kt index 43d4bcc8888..7d98b01ea7d 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAlias.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAlias.kt @@ -1,3 +1,3 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - typealias X = Int/* NonReanalyzableNonClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ + typealias X = Int/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAliasScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAliasScript.kts index 7683ce0cff1..24296a87d8f 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAliasScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/memberTypeAliasScript.kts @@ -1,3 +1,3 @@ -/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */ - typealias X = Int/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */ + typealias X = Int/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelClasses.kt b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelClasses.kt index b964d65f7b9..847009c1a69 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelClasses.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelClasses.kt @@ -1,15 +1,15 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ } -class B {/* NonReanalyzableClassDeclarationStructureElement */ +class B {/* ClassDeclarationStructureElement */ } -class C {/* NonReanalyzableClassDeclarationStructureElement */ +class C {/* ClassDeclarationStructureElement */ } -class D {/* NonReanalyzableClassDeclarationStructureElement */ +class D {/* ClassDeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelFunctionsWithImplicitTypes.kt b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelFunctionsWithImplicitTypes.kt index 6b9abd76d6b..64536430609 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelFunctionsWithImplicitTypes.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelFunctionsWithImplicitTypes.kt @@ -1,7 +1,7 @@ -fun foo1() = 1/* NonReanalyzableNonClassDeclarationStructureElement */ +fun foo1() = 1/* DeclarationStructureElement */ -fun foo2() = 2/* NonReanalyzableNonClassDeclarationStructureElement */ +fun foo2() = 2/* DeclarationStructureElement */ -fun foo3() = 3/* NonReanalyzableNonClassDeclarationStructureElement */ +fun foo3() = 3/* DeclarationStructureElement */ -fun foo4() = 4/* NonReanalyzableNonClassDeclarationStructureElement */ +fun foo4() = 4/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelUnitFunctions.kt b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelUnitFunctions.kt index c4224d8bda2..f0c2639a550 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelUnitFunctions.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/multipleTopLevelUnitFunctions.kt @@ -1,15 +1,15 @@ -fun foo1() {/* ReanalyzableFunctionStructureElement */ +fun foo1() {/* DeclarationStructureElement */ println("foo1") } -fun foo2() {/* ReanalyzableFunctionStructureElement */ +fun foo2() {/* DeclarationStructureElement */ println("foo2") } -fun foo3() {/* ReanalyzableFunctionStructureElement */ +fun foo3() {/* DeclarationStructureElement */ println("foo3") } -fun foo4() {/* ReanalyzableFunctionStructureElement */ +fun foo4() {/* DeclarationStructureElement */ println("foo4") } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/nestedClases.kt b/analysis/low-level-api-fir/testdata/fileStructure/nestedClases.kt index b6c0ada184b..7c096a5eca3 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/nestedClases.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/nestedClases.kt @@ -1,10 +1,10 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - class B {/* NonReanalyzableClassDeclarationStructureElement */ +class A {/* ClassDeclarationStructureElement */ + class B {/* ClassDeclarationStructureElement */ } - object C {/* NonReanalyzableClassDeclarationStructureElement */ - class D {/* NonReanalyzableClassDeclarationStructureElement */ + object C {/* ClassDeclarationStructureElement */ + class D {/* ClassDeclarationStructureElement */ } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/nestedClasesWithFun.kt b/analysis/low-level-api-fir/testdata/fileStructure/nestedClasesWithFun.kt index c6d6ae3f28b..58c41efafe6 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/nestedClasesWithFun.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/nestedClasesWithFun.kt @@ -1,7 +1,7 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun y() {/* ReanalyzableFunctionStructureElement */} +class A {/* ClassDeclarationStructureElement */ + fun y() {/* DeclarationStructureElement */} - class B {/* NonReanalyzableClassDeclarationStructureElement */ - fun x() {/* ReanalyzableFunctionStructureElement */} + class B {/* ClassDeclarationStructureElement */ + fun x() {/* DeclarationStructureElement */} } } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/nestedClasses.kt b/analysis/low-level-api-fir/testdata/fileStructure/nestedClasses.kt index cbe305e8a06..f0e3ab19c2b 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/nestedClasses.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/nestedClasses.kt @@ -1,16 +1,16 @@ -class A {/* NonReanalyzableClassDeclarationStructureElement */ - class B {/* NonReanalyzableClassDeclarationStructureElement */ - fun x() {/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + class B {/* ClassDeclarationStructureElement */ + fun x() {/* DeclarationStructureElement */ } - class C {/* NonReanalyzableClassDeclarationStructureElement */ + class C {/* ClassDeclarationStructureElement */ } } - class E {/* NonReanalyzableClassDeclarationStructureElement */ + class E {/* ClassDeclarationStructureElement */ } - fun y(): Int = 10/* ReanalyzableFunctionStructureElement */ + fun y(): Int = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/nestedClassesScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/nestedClassesScript.kts index a9773f7de88..aeaf5f23889 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/nestedClassesScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/nestedClassesScript.kts @@ -1,16 +1,16 @@ -/* RootScriptStructureElement */class A {/* NonReanalyzableClassDeclarationStructureElement */ - class B {/* NonReanalyzableClassDeclarationStructureElement */ - fun x() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */class A {/* ClassDeclarationStructureElement */ + class B {/* ClassDeclarationStructureElement */ + fun x() {/* DeclarationStructureElement */ } - class C {/* NonReanalyzableClassDeclarationStructureElement */ + class C {/* ClassDeclarationStructureElement */ } } - class E {/* NonReanalyzableClassDeclarationStructureElement */ + class E {/* ClassDeclarationStructureElement */ } - fun y(): Int = 10/* ReanalyzableFunctionStructureElement */ + fun y(): Int = 10/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt b/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt index baa56881652..f45ed9343bc 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt @@ -1,11 +1,11 @@ -var x: Int = 10/* ReanalyzablePropertyStructureElement */ +var x: Int = 10/* DeclarationStructureElement */ get() = field set(value) { field = value } -class X {/* NonReanalyzableClassDeclarationStructureElement */ - var y: Int = 10/* ReanalyzablePropertyStructureElement */ +class X {/* ClassDeclarationStructureElement */ + var y: Int = 10/* DeclarationStructureElement */ get() = field set(value) { field = value diff --git a/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessorsScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessorsScript.kts index 521d1d58ef1..c48427e4f2a 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessorsScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/propertyAccessorsScript.kts @@ -1,11 +1,11 @@ -/* RootScriptStructureElement */var x: Int = 10/* ReanalyzablePropertyStructureElement */ +/* RootScriptStructureElement */var x: Int = 10/* DeclarationStructureElement */ get() = field set(value) { field = value } -class X {/* NonReanalyzableClassDeclarationStructureElement */ - var y: Int = 10/* ReanalyzablePropertyStructureElement */ +class X {/* ClassDeclarationStructureElement */ + var y: Int = 10/* DeclarationStructureElement */ get() = field set(value) { field = value diff --git a/analysis/low-level-api-fir/testdata/fileStructure/propertyWithGetterAndSetter.kt b/analysis/low-level-api-fir/testdata/fileStructure/propertyWithGetterAndSetter.kt index ccd7660634a..840ab532028 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/propertyWithGetterAndSetter.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/propertyWithGetterAndSetter.kt @@ -1,4 +1,4 @@ -var withGetterAndSetter: Int = 42/* ReanalyzablePropertyStructureElement */ +var withGetterAndSetter: Int = 42/* DeclarationStructureElement */ get() = field set(value) { field = value diff --git a/analysis/low-level-api-fir/testdata/fileStructure/propertyWithSetter.kt b/analysis/low-level-api-fir/testdata/fileStructure/propertyWithSetter.kt index ba64994f6bc..079f2a45f85 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/propertyWithSetter.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/propertyWithSetter.kt @@ -1,14 +1,14 @@ -abstract class Foo {/* NonReanalyzableClassDeclarationStructureElement */ - abstract var id: Int/* ReanalyzablePropertyStructureElement */ +abstract class Foo {/* ClassDeclarationStructureElement */ + abstract var id: Int/* DeclarationStructureElement */ protected set } -class Bar : Foo() {/* NonReanalyzableClassDeclarationStructureElement */ - override var id: Int = 1/* ReanalyzablePropertyStructureElement */ +class Bar : Foo() {/* ClassDeclarationStructureElement */ + override var id: Int = 1/* DeclarationStructureElement */ public set } -fun test() {/* ReanalyzableFunctionStructureElement */ +fun test() {/* DeclarationStructureElement */ val bar = Bar() bar.id = 1 } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/qualifiedCallInsideSuperCall.kt b/analysis/low-level-api-fir/testdata/fileStructure/qualifiedCallInsideSuperCall.kt index dc2bd2a496a..3585b2b9728 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/qualifiedCallInsideSuperCall.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/qualifiedCallInsideSuperCall.kt @@ -1,51 +1,51 @@ -open class A(init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */ - val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */ +open class A(init: A.() -> Unit)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */ + val prop: String = ""/* DeclarationStructureElement */ } -object B : A({})/* NonReanalyzableClassDeclarationStructureElement */ +object B : A({})/* ClassDeclarationStructureElement */ object C : A( { fun foo() = B.prop.toString() } -)/* NonReanalyzableClassDeclarationStructureElement */ +)/* ClassDeclarationStructureElement */ class D : A( { fun foo() = B.prop.toString() } -)/* NonReanalyzableClassDeclarationStructureElement */ +)/* ClassDeclarationStructureElement */ -class E()/* NonReanalyzableNonClassDeclarationStructureElement */ : A( +class E()/* DeclarationStructureElement */ : A( { fun foo() = B.prop.toString() } -)/* NonReanalyzableClassDeclarationStructureElement */ +)/* ClassDeclarationStructureElement */ class F : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ - constructor()/* NonReanalyzableNonClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ + constructor()/* DeclarationStructureElement */ } class G : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ constructor() : super( { fun foo() = B.prop.toString() } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } -class H : A {/* NonReanalyzableClassDeclarationStructureElement */ +class H : A {/* ClassDeclarationStructureElement */ constructor() : super( { fun foo() = B.prop.toString() } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/script.kts b/analysis/low-level-api-fir/testdata/fileStructure/script.kts index 94b29bd55b7..3edd7733e45 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/script.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/script.kts @@ -1,13 +1,13 @@ -/* RootScriptStructureElement */class Builder {/* NonReanalyzableClassDeclarationStructureElement */ - var version: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */class Builder {/* ClassDeclarationStructureElement */ + var version: String = ""/* DeclarationStructureElement */ - fun execute() {/* ReanalyzableFunctionStructureElement */ + fun execute() {/* DeclarationStructureElement */ println(version) } } -fun build(action: Builder.() -> Unit) = Builder().apply(action)/* NonReanalyzableNonClassDeclarationStructureElement */ -fun build2(action: Builder.() -> Unit): Builder = Builder().apply(action)/* ReanalyzableFunctionStructureElement */ +fun build(action: Builder.() -> Unit) = Builder().apply(action)/* DeclarationStructureElement */ +fun build2(action: Builder.() -> Unit): Builder = Builder().apply(action)/* DeclarationStructureElement */ build { version = "123" @@ -22,6 +22,6 @@ build { val builder = build { version = "321" -}/* NonReanalyzableNonClassDeclarationStructureElement */ +}/* DeclarationStructureElement */ builder.execute() diff --git a/analysis/low-level-api-fir/testdata/fileStructure/secondaryConstructor.kt b/analysis/low-level-api-fir/testdata/fileStructure/secondaryConstructor.kt index d9b5f29c269..7fd90fa7c08 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/secondaryConstructor.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/secondaryConstructor.kt @@ -1,3 +1,3 @@ -class A(val x: Int = 10, val b: String)/* NonReanalyzableNonClassDeclarationStructureElement */ {/* NonReanalyzableClassDeclarationStructureElement */ - constructor(i: Int) : this(x = 1, b = i.toString())/* NonReanalyzableNonClassDeclarationStructureElement */ +class A(val x: Int = 10, val b: String)/* DeclarationStructureElement */ {/* ClassDeclarationStructureElement */ + constructor(i: Int) : this(x = 1, b = i.toString())/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation.kt b/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation.kt index 04e45a1524f..8ebfe8714f4 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation.kt @@ -1,6 +1,6 @@ @Target(AnnotationTarget.TYPE) -annotation class Anno/* NonReanalyzableClassDeclarationStructureElement */ +annotation class Anno/* ClassDeclarationStructureElement */ -open class A/* NonReanalyzableClassDeclarationStructureElement */ +open class A/* ClassDeclarationStructureElement */ -class B : @Anno A()/* NonReanalyzableClassDeclarationStructureElement */ +class B : @Anno A()/* ClassDeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation2.kt b/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation2.kt index bc924c8bd10..0d668b09bc5 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation2.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/superCallAnnotation2.kt @@ -1,6 +1,6 @@ @Target(AnnotationTarget.TYPE) -annotation class Anno/* NonReanalyzableClassDeclarationStructureElement */ +annotation class Anno/* ClassDeclarationStructureElement */ -interface A/* NonReanalyzableClassDeclarationStructureElement */ +interface A/* ClassDeclarationStructureElement */ -class B : @Anno A/* NonReanalyzableClassDeclarationStructureElement */ +class B : @Anno A/* ClassDeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt b/analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt index c1b267c6426..38c13aa7b97 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt @@ -1,16 +1,16 @@ open class A - (init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */ -{/* NonReanalyzableClassDeclarationStructureElement */ - val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */ + (init: A.() -> Unit)/* DeclarationStructureElement */ +{/* ClassDeclarationStructureElement */ + val prop: String = ""/* DeclarationStructureElement */ } -class B()/* NonReanalyzableNonClassDeclarationStructureElement */ : A()/* NonReanalyzableClassDeclarationStructureElement */ +class B()/* DeclarationStructureElement */ : A()/* ClassDeclarationStructureElement */ object C : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ } @@ -20,16 +20,16 @@ val f = object : A( } ) { -}/* NonReanalyzableNonClassDeclarationStructureElement */ +}/* DeclarationStructureElement */ class D : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ constructor(): super( { fun boo() = prop.toString() } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/superClassCallScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/superClassCallScript.kts index 1f693fda124..c1a1b505763 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/superClassCallScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/superClassCallScript.kts @@ -1,16 +1,16 @@ /* RootScriptStructureElement */open class A - (init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */ -{/* NonReanalyzableClassDeclarationStructureElement */ - val prop: String = ""/* NonReanalyzableNonClassDeclarationStructureElement */ + (init: A.() -> Unit)/* DeclarationStructureElement */ +{/* ClassDeclarationStructureElement */ + val prop: String = ""/* DeclarationStructureElement */ } -class B()/* NonReanalyzableNonClassDeclarationStructureElement */ : A()/* NonReanalyzableClassDeclarationStructureElement */ +class B()/* DeclarationStructureElement */ : A()/* ClassDeclarationStructureElement */ object C : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ } @@ -20,16 +20,16 @@ val f = object : A( } ) { -}/* NonReanalyzableNonClassDeclarationStructureElement */ +}/* DeclarationStructureElement */ class D : A( { fun foo() = B.prop.toString() } -) {/* NonReanalyzableClassDeclarationStructureElement */ +) {/* ClassDeclarationStructureElement */ constructor(): super( { fun boo() = prop.toString() } - )/* NonReanalyzableNonClassDeclarationStructureElement */ + )/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/superType.kt b/analysis/low-level-api-fir/testdata/fileStructure/superType.kt index 4ff1d888c24..3fed7a3a08b 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/superType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/superType.kt @@ -1,7 +1,7 @@ -interface A/* NonReanalyzableClassDeclarationStructureElement */ +interface A/* ClassDeclarationStructureElement */ -typealias AS = A/* NonReanalyzableNonClassDeclarationStructureElement */ +typealias AS = A/* DeclarationStructureElement */ -class C : AS {/* NonReanalyzableClassDeclarationStructureElement */ - constructor()/* NonReanalyzableNonClassDeclarationStructureElement */ +class C : AS {/* ClassDeclarationStructureElement */ + constructor()/* DeclarationStructureElement */ } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt index 4733b336619..77f73b9d626 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithType.kt @@ -1 +1 @@ -fun foo(): Int = 42/* ReanalyzableFunctionStructureElement */ \ No newline at end of file +fun foo(): Int = 42/* DeclarationStructureElement */ \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithTypeScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithTypeScript.kts index 823c76742e8..41728124154 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithTypeScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithTypeScript.kts @@ -1 +1 @@ -/* RootScriptStructureElement */fun foo(): Int = 42/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun foo(): Int = 42/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt index 4211d88a39c..f2399eacf92 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutType.kt @@ -1 +1 @@ -fun foo() = 42/* NonReanalyzableNonClassDeclarationStructureElement */ +fun foo() = 42/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutTypeScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutTypeScript.kts index 7ea610ed03e..62b42dcf58e 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutTypeScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelExpressionBodyFunWithoutTypeScript.kts @@ -1 +1 @@ -/* RootScriptStructureElement */fun foo() = 42/* NonReanalyzableNonClassDeclarationStructureElement */ +/* RootScriptStructureElement */fun foo() = 42/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithType.kt b/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithType.kt index 850cad4630f..cab6a244660 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithType.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithType.kt @@ -1,4 +1,4 @@ -fun foo(): Int {/* ReanalyzableFunctionStructureElement */ +fun foo(): Int {/* DeclarationStructureElement */ println("") return 10 } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithTypeScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithTypeScript.kts index 0743088fafb..f73f66fa803 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithTypeScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelFunWithTypeScript.kts @@ -1,4 +1,4 @@ -/* RootScriptStructureElement */fun foo(): Int {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun foo(): Int {/* DeclarationStructureElement */ println("") return 10 } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelProperty.kt b/analysis/low-level-api-fir/testdata/fileStructure/topLevelProperty.kt index b849432b16d..d787cf481c7 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelProperty.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelProperty.kt @@ -1,9 +1,9 @@ -var x: Int/* ReanalyzablePropertyStructureElement */ +var x: Int/* DeclarationStructureElement */ get() = field set(value) { field = value } -val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */ +val y = 42/* DeclarationStructureElement */ -var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */ +var z: Int = 15/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelPropertyScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/topLevelPropertyScript.kts index 63ef0848338..77131049bb0 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelPropertyScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelPropertyScript.kts @@ -1,9 +1,9 @@ -/* RootScriptStructureElement */var x: Int/* ReanalyzablePropertyStructureElement */ +/* RootScriptStructureElement */var x: Int/* DeclarationStructureElement */ get() = field set(value) { field = value } -val y = 42/* NonReanalyzableNonClassDeclarationStructureElement */ +val y = 42/* DeclarationStructureElement */ -var z: Int = 15/* NonReanalyzableNonClassDeclarationStructureElement */ +var z: Int = 15/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFun.kt b/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFun.kt index 39edd9f8db0..27da350ead1 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFun.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFun.kt @@ -1,4 +1,4 @@ -fun foo() {/* ReanalyzableFunctionStructureElement */ +fun foo() {/* DeclarationStructureElement */ println("") } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFunScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFunScript.kts index 75c805e4b5f..9c79e83ba85 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFunScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/topLevelUnitFunScript.kts @@ -1,3 +1,3 @@ -/* RootScriptStructureElement */fun foo() {/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun foo() {/* DeclarationStructureElement */ println("") } diff --git a/analysis/low-level-api-fir/testdata/fileStructure/typeAlias.kt b/analysis/low-level-api-fir/testdata/fileStructure/typeAlias.kt index 45f0b761bcd..970f261d00e 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/typeAlias.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/typeAlias.kt @@ -1 +1 @@ -typealias A = 10/* NonReanalyzableNonClassDeclarationStructureElement */ +typealias A = 10/* DeclarationStructureElement */ diff --git a/analysis/low-level-api-fir/testdata/fileStructure/withoutName.kt b/analysis/low-level-api-fir/testdata/fileStructure/withoutName.kt index d756d78b480..0ad967b9b86 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/withoutName.kt +++ b/analysis/low-level-api-fir/testdata/fileStructure/withoutName.kt @@ -1,27 +1,27 @@ -fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */ +fun (a: Int = 1): String = "str"/* DeclarationStructureElement */ -fun () {/* ReanalyzableFunctionStructureElement */ +fun () {/* DeclarationStructureElement */ } -val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */ +val : Int = 4/* DeclarationStructureElement */ -var : Int/* ReanalyzablePropertyStructureElement */ +var : Int/* DeclarationStructureElement */ get() = 4 set(value) { } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun (a: Int = 1): String = "str"/* DeclarationStructureElement */ - fun () {/* ReanalyzableFunctionStructureElement */ + fun () {/* DeclarationStructureElement */ } - val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */ + val : Int = 4/* DeclarationStructureElement */ - var : Boolean/* ReanalyzablePropertyStructureElement */ + var : Boolean/* DeclarationStructureElement */ get() = true set(value) { diff --git a/analysis/low-level-api-fir/testdata/fileStructure/withoutNameScript.kts b/analysis/low-level-api-fir/testdata/fileStructure/withoutNameScript.kts index bb528575f6e..607104e2968 100644 --- a/analysis/low-level-api-fir/testdata/fileStructure/withoutNameScript.kts +++ b/analysis/low-level-api-fir/testdata/fileStructure/withoutNameScript.kts @@ -1,27 +1,27 @@ -/* RootScriptStructureElement */fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */ +/* RootScriptStructureElement */fun (a: Int = 1): String = "str"/* DeclarationStructureElement */ -fun () {/* ReanalyzableFunctionStructureElement */ +fun () {/* DeclarationStructureElement */ } -val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */ +val : Int = 4/* DeclarationStructureElement */ -var : Int/* ReanalyzablePropertyStructureElement */ +var : Int/* DeclarationStructureElement */ get() = 4 set(value) { } -class A {/* NonReanalyzableClassDeclarationStructureElement */ - fun (a: Int = 1): String = "str"/* ReanalyzableFunctionStructureElement */ +class A {/* ClassDeclarationStructureElement */ + fun (a: Int = 1): String = "str"/* DeclarationStructureElement */ - fun () {/* ReanalyzableFunctionStructureElement */ + fun () {/* DeclarationStructureElement */ } - val : Int = 4/* NonReanalyzableNonClassDeclarationStructureElement */ + val : Int = 4/* DeclarationStructureElement */ - var : Boolean/* ReanalyzablePropertyStructureElement */ + var : Boolean/* DeclarationStructureElement */ get() = true set(value) { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/AbstractFirContextCollectionTest.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/AbstractFirContextCollectionTest.kt index 2a0a1d95c98..b1d928df64a 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/AbstractFirContextCollectionTest.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/AbstractFirContextCollectionTest.kt @@ -55,19 +55,13 @@ abstract class AbstractFirContextCollectionTest : AbstractLowLevelApiSingleFileT val fileStructure = fileStructureCache.getFileStructure(ktFile) val allStructureElements = fileStructure.getAllStructureElements() - handler.elementsToCheckContext = allStructureElements.map { it.getFirDeclaration() } + handler.elementsToCheckContext = allStructureElements.map(FileStructureElement::firDeclaration) handler.firFile = ktFile.getOrBuildFirFile(firResolveSession) ktFile.getDiagnostics(firResolveSession, DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS) } } - private fun FileStructureElement.getFirDeclaration(): FirDeclaration = when (this) { - is RootStructureElement -> firFile - is ReanalyzableStructureElement<*, *> -> firSymbol.fir - is NonReanalyzableDeclarationStructureElement<*> -> firDeclaration - } - private class BeforeElementLLFirSessionConfigurator(private val testServices: TestServices) : LLFirSessionConfigurator { @OptIn(SessionConfiguration::class) override fun configure(session: LLFirSession) { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/AbstractFileStructureTest.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/AbstractFileStructureTest.kt index 3b3e1d38255..bc0d7339b19 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/AbstractFileStructureTest.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/file/structure/AbstractFileStructureTest.kt @@ -19,6 +19,8 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.Analys import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirScriptTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirSourceTestConfigurator import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.test.KotlinTestUtils @@ -29,8 +31,7 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() { override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) { val fileStructure = ktFile.getFileStructure() val allStructureElements = fileStructure.getAllStructureElements(ktFile) - val declarationToStructureElement = allStructureElements.associateBy { it.psi } - + val declarationToStructureElement = allStructureElements.associateBy { it.firDeclaration.psi } val elementToComment = mutableMapOf() ktFile.forEachDescendantOfType { ktDeclaration -> val structureElement = declarationToStructureElement[ktDeclaration] ?: return@forEachDescendantOfType @@ -76,7 +77,7 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() { PsiTreeUtil.getChildrenOfTypeAsList(ktFile, KtModifierList::class.java).forEach { if (it.nextSibling is PsiErrorElement) { - val structureElement = declarationToStructureElement[ktFile] ?: return@forEach + val structureElement = declarationToStructureElement[it] ?: return@forEach val comment = structureElement.createComment() elementToComment[it] = comment } @@ -120,6 +121,12 @@ abstract class AbstractFileStructureTest : AbstractLowLevelApiSingleFileTest() { } } +internal val FileStructureElement.firDeclaration: FirDeclaration + get() = when (this) { + is RootStructureElement -> file + is DeclarationBaseStructureElement<*> -> declaration + } + abstract class AbstractSourceFileStructureTest : AbstractFileStructureTest() { override val configurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false) }