Class SourceRegions
java.lang.Object
org.ek9lang.compiler.common.SourceRegions
THE reader of the region and elide markers in a compiled example source (site-examples spec ยง3.4, decision D5) -
every page fragment is cut from a whole, compiled source through here; never parse the markers anywhere else.
// region: anatomy a region a page may show: classes/classes_anatomy.ek9#anatomy // end region: anatomy // elide: constructors lines the page shows as ONE comment, "// ... constructors" // end elide: constructors
A marker is an EK9 comment WITH text (a bare // line is a syntax error), so the source still compiles
exactly as written. Regions may nest, and a region name is unique within its file. An elided run is rendered as
ONE comment line at the marker's indentation, // ... <name> - never a bare ... line, which is EK9's
range operator, does not compile, and would teach a model that it is legal (Steve, D5).
Two views of one source:
extract(String, String)- what a page shows: a region (or the whole body), markers removed, elided runs collapsed, dedented to its least-indented line;full(String)- the "full source" page: every line, markers removed, with the line each region starts on so the page can carry anidper region.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA source with its markers removed, and the line each region starts on.(package private) static enumThe kind of a marker line.(package private) static final recordOne marker line: whether it opens or closes, its kind, its name and its indentation. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringWhat a page shows: the named region ofbody(the whole body whenregionis null), with every marker line removed, each elided run replaced by ONE// ... <name>comment at the run's indentation, leading and trailing blank lines dropped, and the result dedented to its least-indented line.static SourceRegions.FullThe "full source" view ofbody: every source line with the marker lines removed, and for each region the (zero-based) line of that text it starts on.(package private) static SourceRegions.MarkerThe marker on this line, ornullwhen the line is source.Every structural problem in the markers ofbody- unbalanced or mismatched markers, a duplicate or malformed region name, an elide inside an elide.regionNames(String body) The region names declared inbody, in source order.
-
Method Details
-
markerOf
The marker on this line, ornullwhen the line is source. -
problems
-
regionNames
-
extract
What a page shows: the named region ofbody(the whole body whenregionis null), with every marker line removed, each elided run replaced by ONE// ... <name>comment at the run's indentation, leading and trailing blank lines dropped, and the result dedented to its least-indented line.- Throws:
IllegalArgumentException- when the markers are malformed or the region is not declared
-
full
The "full source" view ofbody: every source line with the marker lines removed, and for each region the (zero-based) line of that text it starts on.
-