Removing MultiLine, Synthetic, DeclarationFile, and OctalLiteral flags
This commit is contained in:
parent
ba0a7c7786
commit
f0abb86158
|
@ -1110,7 +1110,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkStrictModeNumericLiteral(node: LiteralExpression) {
|
||||
if (inStrictMode && node.flags & NodeFlags.OctalLiteral) {
|
||||
if (inStrictMode && node.isOctalLiteral) {
|
||||
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16749,7 +16749,7 @@ namespace ts {
|
|||
// Grammar checking for computedPropertName and shorthandPropertyAssignment
|
||||
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
|
||||
if (name.kind === SyntaxKind.NumericLiteral) {
|
||||
checkGrammarNumericLiteral(<Identifier>name);
|
||||
checkGrammarNumericLiteral(<LiteralExpression>name);
|
||||
}
|
||||
currentKind = Property;
|
||||
}
|
||||
|
@ -17250,9 +17250,9 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function checkGrammarNumericLiteral(node: Identifier): boolean {
|
||||
function checkGrammarNumericLiteral(node: LiteralExpression): boolean {
|
||||
// Grammar checking
|
||||
if (node.flags & NodeFlags.OctalLiteral && languageVersion >= ScriptTarget.ES5) {
|
||||
if (node.isOctalLiteral && languageVersion >= ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1780,7 +1780,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
write("]");
|
||||
}
|
||||
else {
|
||||
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
|
||||
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ node.multiLine,
|
||||
/*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true);
|
||||
}
|
||||
}
|
||||
|
@ -1803,7 +1803,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces*/ true);
|
||||
}
|
||||
else {
|
||||
const multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
const multiLine = node.multiLine;
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
|
@ -1826,7 +1826,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
}
|
||||
|
||||
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
|
||||
const multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
const multiLine = node.multiLine;
|
||||
const properties = node.properties;
|
||||
|
||||
write("(");
|
||||
|
|
|
@ -666,8 +666,8 @@ namespace ts {
|
|||
sourceFile.bindDiagnostics = [];
|
||||
sourceFile.languageVersion = languageVersion;
|
||||
sourceFile.fileName = normalizePath(fileName);
|
||||
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
|
||||
sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName);
|
||||
sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, ".d.ts");
|
||||
|
||||
return sourceFile;
|
||||
}
|
||||
|
@ -1922,7 +1922,7 @@ namespace ts {
|
|||
&& sourceText.charCodeAt(tokenPos) === CharacterCodes._0
|
||||
&& isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) {
|
||||
|
||||
node.flags |= NodeFlags.OctalLiteral;
|
||||
node.isOctalLiteral = true;
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -3907,7 +3907,9 @@ namespace ts {
|
|||
function parseArrayLiteralExpression(): ArrayLiteralExpression {
|
||||
const node = <ArrayLiteralExpression>createNode(SyntaxKind.ArrayLiteralExpression);
|
||||
parseExpected(SyntaxKind.OpenBracketToken);
|
||||
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
node.multiLine = true;
|
||||
}
|
||||
node.elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement);
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
return finishNode(node);
|
||||
|
@ -3978,7 +3980,7 @@ namespace ts {
|
|||
const node = <ObjectLiteralExpression>createNode(SyntaxKind.ObjectLiteralExpression);
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
node.flags |= NodeFlags.MultiLine;
|
||||
node.multiLine = true;
|
||||
}
|
||||
|
||||
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true);
|
||||
|
|
|
@ -381,12 +381,8 @@ namespace ts {
|
|||
Abstract = 1 << 7, // Class/Method/ConstructSignature
|
||||
Async = 1 << 8, // Property/Method/Function
|
||||
Default = 1 << 9, // Function/Class (export default declaration)
|
||||
MultiLine = 1 << 10, // Multi-line array or object literal
|
||||
Synthetic = 1 << 11, // Synthetic node (for full fidelity)
|
||||
DeclarationFile = 1 << 12, // Node is a .d.ts file
|
||||
Let = 1 << 13, // Variable declaration
|
||||
Const = 1 << 14, // Variable declaration
|
||||
OctalLiteral = 1 << 15, // Octal numeric literal
|
||||
Namespace = 1 << 16, // Namespace declaration
|
||||
ExportContext = 1 << 17, // Export context (initialized by binding)
|
||||
ContainsThis = 1 << 18, // Interface contains references to "this"
|
||||
|
@ -938,6 +934,7 @@ namespace ts {
|
|||
text: string;
|
||||
isUnterminated?: boolean;
|
||||
hasExtendedUnicodeEscape?: boolean;
|
||||
isOctalLiteral?: boolean;
|
||||
}
|
||||
|
||||
// The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
||||
|
@ -979,6 +976,7 @@ namespace ts {
|
|||
// @kind(SyntaxKind.ArrayLiteralExpression)
|
||||
export interface ArrayLiteralExpression extends PrimaryExpression {
|
||||
elements: NodeArray<Expression>;
|
||||
multiLine?: boolean;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.SpreadElementExpression)
|
||||
|
@ -990,6 +988,7 @@ namespace ts {
|
|||
// @kind(SyntaxKind.ObjectLiteralExpression)
|
||||
export interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
multiLine?: boolean;
|
||||
}
|
||||
|
||||
// @kind(SyntaxKind.PropertyAccessExpression)
|
||||
|
@ -1546,6 +1545,7 @@ namespace ts {
|
|||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
isDeclarationFile: boolean;
|
||||
|
||||
// this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling)
|
||||
/* @internal */
|
||||
|
|
|
@ -414,7 +414,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
export function isDeclarationFile(file: SourceFile): boolean {
|
||||
return (file.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
return file.isDeclarationFile;
|
||||
}
|
||||
|
||||
export function isConstEnumDeclaration(node: Node): boolean {
|
||||
|
@ -1309,10 +1309,9 @@ namespace ts {
|
|||
|
||||
export function isInAmbientContext(node: Node): boolean {
|
||||
while (node) {
|
||||
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) {
|
||||
if (node.flags & NodeFlags.Ambient || (node.kind === SyntaxKind.SourceFile && (node as SourceFile).isDeclarationFile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
node = node.parent;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace ts.BreakpointResolver {
|
|||
*/
|
||||
export function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number) {
|
||||
// Cannot set breakpoint in dts file
|
||||
if (sourceFile.flags & NodeFlags.DeclarationFile) {
|
||||
if (sourceFile.isDeclarationFile) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,14 +237,14 @@ namespace ts {
|
|||
while (pos < end) {
|
||||
const token = scanner.scan();
|
||||
const textPos = scanner.getTextPos();
|
||||
nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
|
||||
nodes.push(createNode(token, pos, textPos, 0, this));
|
||||
pos = textPos;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
private createSyntaxList(nodes: NodeArray<Node>): Node {
|
||||
const list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, NodeFlags.Synthetic, this);
|
||||
const list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, 0, this);
|
||||
list._children = [];
|
||||
let pos = nodes.pos;
|
||||
|
||||
|
@ -797,6 +797,7 @@ namespace ts {
|
|||
public parseDiagnostics: Diagnostic[];
|
||||
public bindDiagnostics: Diagnostic[];
|
||||
|
||||
public isDeclarationFile: boolean;
|
||||
public isDefaultLib: boolean;
|
||||
public hasNoDefaultLib: boolean;
|
||||
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
|
|
Loading…
Reference in a new issue