SYSTEM Cited by 1 source
PSI Libraries (JetBrains)¶
PSI (Program Structure Interface) is JetBrains' AST + semantic-analysis layer inside IntelliJ. PSI trees represent source files at a granularity that supports inspections, refactorings, navigation, and code generation. Available for Java, Kotlin, and most languages IntelliJ supports.
Role in the wiki¶
PSI is the substrate Meta builds metaprogramming on outside the compiler. The 2024-12-18 post makes the distinction sharp:
"These custom translation steps are built on top of an internal metaprogramming tool that leverages JetBrains' PSI libraries for both Java and Kotlin. Unlike most metaprogramming tools, it is very much not a compiler plugin, so it can analyze broken code across both languages, and does so very quickly."
That's the load-bearing property — see concepts/metaprogramming-on-broken-code. Meta's internal Editus tool uses PSI to parse + analyse + rewrite Java and Kotlin sources in the presence of compile errors, across "several thousand unbuildable Java and Kotlin files" simultaneously. Compiler-plugin-based tools cannot do this because they require a working type system and can't participate when the build has failed.
Limitations Meta calls out¶
PSI's non-compiler nature means it can't always resolve types, especially for symbols defined in third-party libraries. Meta's tool "bails quickly and obviously" in those cases rather than transforming with false confidence — the resulting Kotlin "might not build, but the appropriate fix is usually pretty obvious to a human (if a little tedious)."
Seen in¶
- sources/2024-12-18-meta-translating-10m-lines-of-java-to-kotlin — PSI as the Java+Kotlin AST layer for Meta's Editus tool.
Related¶
- systems/j2k-converter — J2K uses PSI internally.
- systems/intellij-platform — PSI's host platform.
- systems/kotlin-ast-tools — Meta's open-source subset built on PSI.
- concepts/abstract-syntax-tree — general AST concept.
- concepts/metaprogramming-on-broken-code — the property PSI enables that compiler plugins can't.