const classafPlastic::SrcCodeSnippet
sys::Obj afPlastic::SrcCodeSnippet
Generates snippets of source code, often used to report errors. Example:
file:/C:/test/app/compilationErr.moustache : Line 11
- Unbalanced "{" in tag "{ alienHeadSvg } <span class="brand">{{ title"
6: {{{ bedSheetCss }}}
7: </style>
8: </head>
9: <body>
10: <header>
==> 11: {{{ alienHeadSvg }
12: <span class="brand">{{ title }}</span>
13: </header>
14:
15: <main>
16: {{{ content }}}
- make
new make(Uri srcCodeLocation, Str srcCode)Creates a SrcCodeSnippet. The srcCodeLocation URI may be anything as it is only used for reporting.
- srcCode
const Str[] srcCodeA list of source code lines.
- srcCodeLocation
const Uri srcCodeLocationAn arbitrary uri of where the source code originated from.
- srcCodeSnippet
Str srcCodeSnippet(Int lineNo, Str? msg := null, Int linesOfPadding := 5)Returns a snippet of source code, centred on
lineNoand padded on either side by an extralinesOfPadding.Note that
lineNois ONE based, not zero.- srcCodeSnippetMap
Int:Str srcCodeSnippetMap(Int lineNo, Int linesOfPadding := 5)Returns a map of line numbers to source code, centred on
lineNoand padded on either side by an extralinesOfPadding.Note that
lineNois ONE based, not zero.