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

Source

new make(Uri srcCodeLocation, Str srcCode)

Creates a SrcCodeSnippet. The srcCodeLocation URI may be anything as it is only used for reporting.

srcCode

Source

const Str[] srcCode

A list of source code lines.

srcCodeLocation

Source

const Uri srcCodeLocation

An arbitrary uri of where the source code originated from.

srcCodeSnippet

Source

Str srcCodeSnippet(Int lineNo, Str? msg := null, Int linesOfPadding := 5)

Returns a snippet of source code, centred on lineNo and padded on either side by an extra linesOfPadding.

Note that lineNo is ONE based, not zero.

srcCodeSnippetMap

Source

Int:Str srcCodeSnippetMap(Int lineNo, Int linesOfPadding := 5)

Returns a map of line numbers to source code, centred on lineNo and padded on either side by an extra linesOfPadding.

Note that lineNo is ONE based, not zero.