use state

This commit is contained in:
Joscha Feth 2018-04-13 11:39:29 +10:00
parent 4da2e5eda3
commit ee429ef2ea
4 changed files with 3 additions and 6 deletions

View File

@ -2929,7 +2929,6 @@ declare namespace ts {
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingDot(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;

View File

@ -22,7 +22,6 @@ namespace ts {
getTokenText(): string;
getTokenValue(): string;
hasExtendedUnicodeEscape(): boolean;
hasPrecedingDot(): boolean;
hasPrecedingLineBreak(): boolean;
isIdentifier(): boolean;
isReservedWord(): boolean;
@ -834,7 +833,6 @@ namespace ts {
getTokenText: () => text.substring(tokenPos, pos),
getTokenValue: () => tokenValue,
hasExtendedUnicodeEscape: () => (tokenFlags & TokenFlags.ExtendedUnicodeEscape) !== 0,
hasPrecedingDot: () => (tokenFlags & TokenFlags.PrecedingDot) !== 0,
hasPrecedingLineBreak: () => (tokenFlags & TokenFlags.PrecedingLineBreak) !== 0,
isIdentifier: () => token === SyntaxKind.Identifier || token > SyntaxKind.LastReservedWord,
isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord,
@ -1471,7 +1469,6 @@ namespace ts {
pos++;
return token = SyntaxKind.MinusToken;
case CharacterCodes.dot:
tokenFlags |= TokenFlags.PrecedingDot;
if (isDigit(text.charCodeAt(pos + 1))) {
tokenValue = scanNumber();
return token = SyntaxKind.NumericLiteral;

View File

@ -1585,7 +1585,6 @@ namespace ts {
BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000`
OctalSpecifier = 1 << 8, // e.g. `0o777`
ContainsSeparator = 1 << 9, // e.g. `0b1100_0101`
PrecedingDot = 1 << 10,
BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier,
NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinarySpecifier | OctalSpecifier | ContainsSeparator
}

View File

@ -13,6 +13,7 @@ namespace ts {
const importedFiles: FileReference[] = [];
let ambientExternalModules: { ref: FileReference, depth: number }[];
let braceNesting = 0;
let lastTokenWasDot = false;
// assume that text represent an external module if it contains at least one top level import/export
// ambient modules that are found inside external modules are interpreted as module augmentations
let externalModule = false;
@ -25,6 +26,7 @@ namespace ts {
else if (token === SyntaxKind.CloseBraceToken) {
braceNesting--;
}
lastTokenWasDot = token === SyntaxKind.DotToken;
return token;
}
@ -78,7 +80,7 @@ namespace ts {
*/
function tryConsumeImport(): boolean {
let token = scanner.getToken();
if (token === SyntaxKind.ImportKeyword && !scanner.hasPrecedingDot()) {
if (token === SyntaxKind.ImportKeyword && !lastTokenWasDot) {
token = nextToken();
if (token === SyntaxKind.OpenParenToken) {
token = nextToken();