[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
This commit is contained in:
Dmitrii Gridin
2024-02-12 16:18:27 +01:00
committed by Space Team
parent 31852c6c05
commit addbb713a5
@@ -115,8 +115,6 @@ internal class FileStructure private constructor(
}
fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): List<KtPsiDiagnostic> {
// 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,