From addbb713a545ea0620a0c0ddf27b3551d9251872 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Mon, 12 Feb 2024 16:18:27 +0100 Subject: [PATCH] [LL FIR] FileStructure: collect diagnostics from bottom to top In this way, we can be sure that all nested declarations will be fully resolved before the outer one. As an example, we had a workaround for file diagnostics as its `FileStructure` element resolves the file only to `IMPORTS` phase yet. Also, this commit probably should improve the performance of highlighting as we will trigger the resolution from bottom to top while other highlighting passes will iterate from top to bottom. ^KT-65562 --- .../low/level/api/fir/file/structure/FileStructure.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 55f06cac1f6..54840fba4df 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 @@ -115,8 +115,6 @@ internal class FileStructure private constructor( } fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): List { - // TODO, KT-60799: Add a new FileStructure for file diagnostics - firFile.lazyResolveToPhase(FirResolvePhase.BODY_RESOLVE) val structureElements = getAllStructureElements() return buildList { collectDiagnosticsFromStructureElements(structureElements, diagnosticCheckerFilter) @@ -159,10 +157,9 @@ internal class FileStructure private constructor( } }) - return structureElements + return structureElements.toList().asReversed() } - private fun createDeclarationStructure(declaration: KtDeclaration): FileStructureElement { val firDeclaration = declaration.findSourceNonLocalFirDeclaration( firFile,