Skip to content

[I] Scanner

Properties

PropertyModifierTypeDescription
filereadonlySourceFileThe source code being scanned.
positionreadonlynumberThe offset in UTF-16 code units to the current position at the start of the next token.
tokenreadonlyTokenThe current token
tokenFlagsreadonlyTokenFlagsThe flags on the current token.
tokenPositionreadonlynumberThe offset in UTF-16 code units to the start of the current token.

Methods

eof()

eof(): boolean

Determine if the scanner has reached the end of the input.

Returns

boolean


findTripleQuotedStringIndent()

findTripleQuotedStringIndent(start, end): [number, number]

Finds the indent for the given triple quoted string.

Parameters

ParameterTypeDescription
startnumber
endnumber

Returns

[number, number]


getTokenText()

getTokenText(): string

The exact spelling of the current token.

Returns

string


getTokenValue()

getTokenValue(): string

The value of the current token.

String literals are escaped and unquoted, identifiers are normalized, and all other tokens return their exact spelling sames as getTokenText().

Returns

string


reScanStringTemplate()

reScanStringTemplate(tokenFlags): StringTemplateToken

Unconditionally back up and scan a template expression portion.

Parameters

ParameterTypeDescription
tokenFlagsTokenFlagsToken Flags for head StringTemplateToken

Returns

StringTemplateToken


scan()

scan(): Token

Advance one token.

Returns

Token


scanDoc()

scanDoc(): DocToken

Advance one token inside DocComment. Use inside scanRange callback over DocComment range.

Returns

DocToken


scanRange()

scanRange<T>(range, callback): T

Reset the scanner to the given start and end positions, invoke the callback, and then restore scanner state.

Type Parameters

Type Parameter
T

Parameters

ParameterType
rangeTextRange
callback() => T

Returns

T


unindentAndUnescapeTripleQuotedString()

unindentAndUnescapeTripleQuotedString(
start,
end,
indentationStart,
indentationEnd,
token,
tokenFlags): string

Unindent and unescape the triple quoted string rawText

Parameters

ParameterType
startnumber
endnumber
indentationStartnumber
indentationEndnumber
tokenStringLiteral | StringTemplateToken
tokenFlagsTokenFlags

Returns

string