Expand description
Lossless Kotlin syntax tree. Node and token kinds mirror the Kotlin compiler’s PSI element
types one-to-one (see kinds.tsv), so trees can be diffed against DebugUtil.psiToString.
Re-exports§
pub use tree::ElementId;pub use tree::Tree;pub use tree::TreeBuilder;
Modules§
- caught_
panic - Ported code mimics a Java exception with a panic, caught where the JVM tool catches the exception
(ktlint’s rule boundary, ktfmt’s per-file
catch). The default panic hook would still print each one to stderr, which the jar does not;silence_caught_panicskeeps those quiet. - tree
Tree: a parsed file as flat preorder arrays. An element (node or token) is its preorder index; navigation is index arithmetic, and token text is a slice of the source. Replaces rowan’s green/red trees, which allocate per node when built and per step when walked (see research/06-tree-library.md for the measurements).
Structs§
- Missed
Tokens PsiBuilderImpl.prepareLightTree’sLOG.error("Tokens [..] were not inserted into the tree. .."): the tree leaves those tokens out. IntelliJ’sDefaultLogger(what ktfmt and ktlint run with) printsSelf::logto stderr and throwsAssertionError, which their CLIs don’t catch. Both expand every chameleon before they look for error elements, so it wins over a parse error anywhere in the file (research/24, finding 4).- Parse
- A parsed file: the tree plus one message per
ERROR_ELEMENT, in tree preorder. - Text
Range - A range in text, represented as a pair of
TextSize. - Text
Size - A measure of text length. Also, equivalently, an index into text.
Enums§
Functions§
- psi_
dump - Renders
parseexactly like IntelliJ’sDebugUtil.psiToString(file, true, false), the format of the compiler’s parser fixtures and oftools/psi-dump.