Lossless Semantic Tree (LST)
A fully type-attributed, format-preserving code model that makes automated refactoring safe and precise.
What is it?
An LST is OpenRewrite’s internal representation of source code. Unlike a regular Abstract Syntax Tree (AST), it preserves every formatting detail — whitespace, comments, import order — while also carrying full type information. This means a recipe can modify code and produce a diff that looks like a human wrote it.
Why does it matter?
Without an LST, automated code transformations are either lossy (they destroy formatting) or blind (they lack type context). The LST is what makes OpenRewrite transformations predictable and reviewable. It’s the difference between a find-and-replace and a compiler-aware refactoring.
Go deeper
More in the Manual
Want to go deeper on this topic?
I cover these concepts in my talks and workshops — from 30-minute keynotes to half-day hands-on sessions.
Book a Session