Skip to content

Commit f0abb86

Browse files
committed
Removing MultiLine, Synthetic, DeclarationFile, and OctalLiteral flags
1 parent ba0a7c7 commit f0abb86

8 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ namespace ts {
11101110
}
11111111

11121112
function checkStrictModeNumericLiteral(node: LiteralExpression) {
1113-
if (inStrictMode && node.flags & NodeFlags.OctalLiteral) {
1113+
if (inStrictMode && node.isOctalLiteral) {
11141114
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
11151115
}
11161116
}

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16749,7 +16749,7 @@ namespace ts {
1674916749
// Grammar checking for computedPropertName and shorthandPropertyAssignment
1675016750
checkGrammarForInvalidQuestionMark(prop, (<PropertyAssignment>prop).questionToken, Diagnostics.An_object_member_cannot_be_declared_optional);
1675116751
if (name.kind === SyntaxKind.NumericLiteral) {
16752-
checkGrammarNumericLiteral(<Identifier>name);
16752+
checkGrammarNumericLiteral(<LiteralExpression>name);
1675316753
}
1675416754
currentKind = Property;
1675516755
}
@@ -17250,9 +17250,9 @@ namespace ts {
1725017250
}
1725117251
}
1725217252

17253-
function checkGrammarNumericLiteral(node: Identifier): boolean {
17253+
function checkGrammarNumericLiteral(node: LiteralExpression): boolean {
1725417254
// Grammar checking
17255-
if (node.flags & NodeFlags.OctalLiteral && languageVersion >= ScriptTarget.ES5) {
17255+
if (node.isOctalLiteral && languageVersion >= ScriptTarget.ES5) {
1725617256
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
1725717257
}
1725817258
}

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17801780
write("]");
17811781
}
17821782
else {
1783-
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
1783+
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ node.multiLine,
17841784
/*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true);
17851785
}
17861786
}
@@ -1803,7 +1803,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18031803
emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces*/ true);
18041804
}
18051805
else {
1806-
const multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
1806+
const multiLine = node.multiLine;
18071807
if (!multiLine) {
18081808
write(" ");
18091809
}
@@ -1826,7 +1826,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18261826
}
18271827

18281828
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
1829-
const multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
1829+
const multiLine = node.multiLine;
18301830
const properties = node.properties;
18311831

18321832
write("(");

src/compiler/parser.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,8 @@ namespace ts {
666666
sourceFile.bindDiagnostics = [];
667667
sourceFile.languageVersion = languageVersion;
668668
sourceFile.fileName = normalizePath(fileName);
669-
sourceFile.flags = fileExtensionIs(sourceFile.fileName, ".d.ts") ? NodeFlags.DeclarationFile : 0;
670669
sourceFile.languageVariant = getLanguageVariant(sourceFile.fileName);
670+
sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, ".d.ts");
671671

672672
return sourceFile;
673673
}
@@ -1922,7 +1922,7 @@ namespace ts {
19221922
&& sourceText.charCodeAt(tokenPos) === CharacterCodes._0
19231923
&& isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) {
19241924

1925-
node.flags |= NodeFlags.OctalLiteral;
1925+
node.isOctalLiteral = true;
19261926
}
19271927

19281928
return node;
@@ -3907,7 +3907,9 @@ namespace ts {
39073907
function parseArrayLiteralExpression(): ArrayLiteralExpression {
39083908
const node = <ArrayLiteralExpression>createNode(SyntaxKind.ArrayLiteralExpression);
39093909
parseExpected(SyntaxKind.OpenBracketToken);
3910-
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
3910+
if (scanner.hasPrecedingLineBreak()) {
3911+
node.multiLine = true;
3912+
}
39113913
node.elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement);
39123914
parseExpected(SyntaxKind.CloseBracketToken);
39133915
return finishNode(node);
@@ -3978,7 +3980,7 @@ namespace ts {
39783980
const node = <ObjectLiteralExpression>createNode(SyntaxKind.ObjectLiteralExpression);
39793981
parseExpected(SyntaxKind.OpenBraceToken);
39803982
if (scanner.hasPrecedingLineBreak()) {
3981-
node.flags |= NodeFlags.MultiLine;
3983+
node.multiLine = true;
39823984
}
39833985

39843986
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true);

src/compiler/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,8 @@ namespace ts {
381381
Abstract = 1 << 7, // Class/Method/ConstructSignature
382382
Async = 1 << 8, // Property/Method/Function
383383
Default = 1 << 9, // Function/Class (export default declaration)
384-
MultiLine = 1 << 10, // Multi-line array or object literal
385-
Synthetic = 1 << 11, // Synthetic node (for full fidelity)
386-
DeclarationFile = 1 << 12, // Node is a .d.ts file
387384
Let = 1 << 13, // Variable declaration
388385
Const = 1 << 14, // Variable declaration
389-
OctalLiteral = 1 << 15, // Octal numeric literal
390386
Namespace = 1 << 16, // Namespace declaration
391387
ExportContext = 1 << 17, // Export context (initialized by binding)
392388
ContainsThis = 1 << 18, // Interface contains references to "this"
@@ -938,6 +934,7 @@ namespace ts {
938934
text: string;
939935
isUnterminated?: boolean;
940936
hasExtendedUnicodeEscape?: boolean;
937+
isOctalLiteral?: boolean;
941938
}
942939

943940
// 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 {
979976
// @kind(SyntaxKind.ArrayLiteralExpression)
980977
export interface ArrayLiteralExpression extends PrimaryExpression {
981978
elements: NodeArray<Expression>;
979+
multiLine?: boolean;
982980
}
983981

984982
// @kind(SyntaxKind.SpreadElementExpression)
@@ -990,6 +988,7 @@ namespace ts {
990988
// @kind(SyntaxKind.ObjectLiteralExpression)
991989
export interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
992990
properties: NodeArray<ObjectLiteralElement>;
991+
multiLine?: boolean;
993992
}
994993

995994
// @kind(SyntaxKind.PropertyAccessExpression)
@@ -1546,6 +1545,7 @@ namespace ts {
15461545
moduleName: string;
15471546
referencedFiles: FileReference[];
15481547
languageVariant: LanguageVariant;
1548+
isDeclarationFile: boolean;
15491549

15501550
// this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling)
15511551
/* @internal */

src/compiler/utilities.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ namespace ts {
414414
}
415415

416416
export function isDeclarationFile(file: SourceFile): boolean {
417-
return (file.flags & NodeFlags.DeclarationFile) !== 0;
417+
return file.isDeclarationFile;
418418
}
419419

420420
export function isConstEnumDeclaration(node: Node): boolean {
@@ -1309,10 +1309,9 @@ namespace ts {
13091309

13101310
export function isInAmbientContext(node: Node): boolean {
13111311
while (node) {
1312-
if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) {
1312+
if (node.flags & NodeFlags.Ambient || (node.kind === SyntaxKind.SourceFile && (node as SourceFile).isDeclarationFile)) {
13131313
return true;
13141314
}
1315-
13161315
node = node.parent;
13171316
}
13181317
return false;

src/services/breakpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ts.BreakpointResolver {
1010
*/
1111
export function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number) {
1212
// Cannot set breakpoint in dts file
13-
if (sourceFile.flags & NodeFlags.DeclarationFile) {
13+
if (sourceFile.isDeclarationFile) {
1414
return undefined;
1515
}
1616

src/services/services.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ namespace ts {
237237
while (pos < end) {
238238
const token = scanner.scan();
239239
const textPos = scanner.getTextPos();
240-
nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
240+
nodes.push(createNode(token, pos, textPos, 0, this));
241241
pos = textPos;
242242
}
243243
return pos;
244244
}
245245

246246
private createSyntaxList(nodes: NodeArray<Node>): Node {
247-
const list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, NodeFlags.Synthetic, this);
247+
const list = createNode(SyntaxKind.SyntaxList, nodes.pos, nodes.end, 0, this);
248248
list._children = [];
249249
let pos = nodes.pos;
250250

@@ -797,6 +797,7 @@ namespace ts {
797797
public parseDiagnostics: Diagnostic[];
798798
public bindDiagnostics: Diagnostic[];
799799

800+
public isDeclarationFile: boolean;
800801
public isDefaultLib: boolean;
801802
public hasNoDefaultLib: boolean;
802803
public externalModuleIndicator: Node; // The first node that causes this file to be an external module

0 commit comments

Comments
 (0)