Class StructuralReorderer
java.lang.Object
org.ek9lang.compiler.formatter.StructuralReorderer
Pass 2 of the EK9 source formatter: Structural Reordering.
Phase 1: Module-level reordering:
- Reference sorting: sorts
identifierReferenceentries within areferencesblock lexicographically - Module block ordering: orders
definesblocks by canonical type (constant, type, record, trait, class, function, component, text, service, application, program, package)
- Rule 1: No blank lines between consecutive field initialisers (unless a comment separates them)
- Rule 2: No blank lines between argument/return parameter declarations (same comment exception)
- Rule 3: Exactly one blank line between the last parameter declaration and the method body
AggregateMemberOrder (E01086) is the
only order the compiler itself requires: properties, then constructors and methods, then
operators, then a bare default operator last. That is a KIND-level order; it says
nothing about the order of members WITHIN a kind, so a body already satisfying it (the only kind
a compiling source can be) needs no member moved at all — this pass leaves such a body exactly
as written. A body failing E01086 is left alone too: fixing it is a compile error, not a
formatting job.
Doc comments travel with the construct they precede.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumCanonical ordering for module block types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) EK9Parser.CompilationUnitContextparseToTree(String source) Parse the source to a CompilationUnitContext.(package private) StringApply structural reordering to the given canonically indented EK9 source.
-
Constructor Details
-
StructuralReorderer
StructuralReorderer()
-
-
Method Details
-
reorder
-
parseToTree
Parse the source to a CompilationUnitContext. Returns null if parsing encounters errors.
-