[I] Scanner
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
file | readonly | SourceFile | The source code being scanned. |
position | readonly | number | The offset in UTF-16 code units to the current position at the start of the next token. |
token | readonly | Token | The current token |
tokenFlags | readonly | TokenFlags | The flags on the current token. |
tokenPosition | readonly | number | The offset in UTF-16 code units to the start of the current token. |
Methods
eof()
eof(): booleanDetermine 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
| Parameter | Type | Description |
|---|---|---|
start | number | |
end | number |
Returns
[number, number]
getTokenText()
getTokenText(): stringThe exact spelling of the current token.
Returns
string
getTokenValue()
getTokenValue(): stringThe 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): StringTemplateTokenUnconditionally back up and scan a template expression portion.
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenFlags | TokenFlags | Token Flags for head StringTemplateToken |
Returns
scan()
scan(): TokenAdvance one token.
Returns
scanDoc()
scanDoc(): DocTokenAdvance one token inside DocComment. Use inside scanRange callback over DocComment range.
Returns
scanRange()
scanRange<T>(range, callback): TReset the scanner to the given start and end positions, invoke the callback, and then restore scanner state.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
range | TextRange |
callback | () => T |
Returns
T
unindentAndUnescapeTripleQuotedString()
unindentAndUnescapeTripleQuotedString( start, end, indentationStart, indentationEnd, token, tokenFlags): stringUnindent and unescape the triple quoted string rawText
Parameters
| Parameter | Type |
|---|---|
start | number |
end | number |
indentationStart | number |
indentationEnd | number |
token | StringLiteral | StringTemplateToken |
tokenFlags | TokenFlags |
Returns
string