Low-level API FIR (LL API or LL FIR for short) is an interlayer between Analysis API FIR Implementation and FIR compiler. Low-level API FIR is responsible but not limited for:
- Finding corresponding FirElement by
KtElement - Lazy resolution of declarations (FirElementWithResolveState)
- Collecting diagnostics for FirDeclaration
- Incremental code analysis
- Implementing FIR providers using the Analysis API implementor's declaration/package/etc. providers (e.g., IntelliJ indexes in the IDE)
You can read about how FIR compiler works here.
The entry point for LL API is LLResolutionFacade.
LLResolutionFacade represents a project view from a use-site KaModule.
The lifetime of LLResolutionFacade is limited by modification events.
LowLevelFirApiFacade file contains a useful API surface to interact with Low Level API FIR from Analysis API FIR.
There are a bunch of different areas. Docs for each area are sorted by context depth – from the basic overview to the deepest implementation details.
- Mapping from
KtElementtoFirElement(KT → FIR) & Incremental Analysis & Collecting diagnostics- FirElementBuilder
is responsible for mapping from
KtElementtoFirElement. - FileStructure
is a tree like-structure of
FileStructureElementwhich is associated with someKtFile. Aggregates information about KT → FIR mapping and diagnostics for an associated file. - FileStructureElement
is a representation of specific
KtElement. Is responsible for KT → FIR mapping and diagnostics for the specificKtElement. - FileStructureElementDiagnosticRetriever
is responsible to collect diagnostics for
FileStructureElement. - LLFirDeclarationModificationService
is a service that is responsible for
FileStructureinvalidation in the case of associated PSI modification.
- FirElementBuilder
is responsible for mapping from
- Lazy resolution
- FirResolvePhase to understand what the compiler phases are and what is the basic difference between the CLI and the Analysis API modes.
- LLFirModuleLazyDeclarationResolver
is the entry point for lazy resolution.
Receives some
FirElementWithResolveStateelement and a desired phase and resolve this element to this phase. - LLFirResolveDesignationCollector
is a designation collector.
Collects
LLFirResolveTargetfor the specificFirElementWithResolveState. Decides which element can be resolved lazily and which cannot. - LLFirResolveTarget
is an instruction on how to resolve specific
FirElementWithResolveState. - LLFirLazyResolverRunner is responsible for running LLFirLazyResolver for the specific phase and making sure that it worked correctly.
- LLFirTargetResolver
is the core part of lazy resolution.
We have a separate implementation of
LLFirTargetResolverfor each compiler phase, each of which is responsible for all the resolution logic for the associated phase. - LLFirLockProvider
is responsible for locking logic which is widely used by
LLFirTargetResolverduring resolution.
- ContextCollector represents the resolution context of a specific place in code (a context)
The LLResolutionFacade represents a view from a specific module (root module) to the dependent modules. A module is represented by:
LLFirSession– the implementation ofFirSession(FIR compiler representation of a module)ModuleFileCache– theKtFile -> FirFilecache & also caches for FIR providers