Skip to content

Source

Source interface for filter source contents.

content(): string

Content returns the source content represented as a string. Example contents are the single file contents, textbox field, or url parameter.

string


description(): string

Description gives a brief description of the source. Example descriptions are a file name or ui element.

string


lineOffsets(): number[]

LineOffsets gives the character offsets at which lines occur. The zero-th entry should refer to the break between the first and second line, or EOF if there is only one line of source.

number[]


location(line, column): Location

Location takes an input line and column and produces a Location. The default behavior is to treat the line and column as absolute, but concrete derivations may use this method to convert a relative line and column position into an absolute location.

number

number

Location


locationOffset(location): [number, boolean]

LocationOffset translates a Location to an offset. Given the line and column of the Location returns the Location’s character offset in the Source, and a bool indicating whether the Location was found.

Location

[number, boolean]


offsetLocation(offset): [Location, boolean]

OffsetLocation translates a character offset to a Location, or false if the conversion was not feasible.

number

[Location, boolean]


snippet(line): [string, boolean]

Snippet returns a line of content and whether the line was found.

number

[string, boolean]