Class KotlinPsi
The only class in Copilot permitted to import
org.jetbrains.kotlin.*. Everything else works through
invalid reference
KtNodeRef
Uses the lightweight PSI path — CoreApplicationEnvironment plus a
KotlinParserDefinition — and deliberately not
KotlinCoreEnvironment.createForProduction, which loads the whole
compiler frontend and its extension registry for no benefit here: Copilot
needs exact source offsets, not resolved types. Types come from reflection on
the live component instead.
Measured on this path: ~240 ms one-off environment setup, ~1.2 ms to parse a
typical view, ~2 MB retained heap. See
kotlin-support/PHASE-0-FINDINGS.md.
-
Method Summary
-
Method Details
-
parse
Parses Kotlin source text.The returned tree must not be retained past the operation that asked for it: it holds the whole PSI graph alive, and this class keeps its environment for the lifetime of the JVM.
- Parameters:
fileName- the file's name, used only for messages and to pick the parsertext- the source- Returns:
- the parsed file
-