Skip to content

Commit 36732ac

Browse files
committed
Remove Identifier.hasExtendedUnicodeEscape
1 parent 21cfc89 commit 36732ac

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

Diff for: src/compiler/binder.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
10301030
else if (containerFlags & ContainerFlags.IsInterface) {
10311031
seenThisKeyword = false;
10321032
bindChildren(node);
1033+
Debug.assertNotNode(node, isIdentifier); // ContainsThis cannot overlap with HasExtendedUnicodeEscape on Identifier
10331034
node.flags = seenThisKeyword ? node.flags | NodeFlags.ContainsThis : node.flags & ~NodeFlags.ContainsThis;
10341035
}
10351036
else {

Diff for: src/compiler/factory/nodeFactory.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
11561156
node.originalKeywordKind = originalKeywordKind;
11571157
node.escapedText = escapedText;
11581158
node.autoGenerate = undefined;
1159-
node.hasExtendedUnicodeEscape = undefined;
11601159
node.jsDoc = undefined; // initialized by parser (JsDocContainer)
11611160
node.jsDocCache = undefined; // initialized by parser (JsDocContainer)
11621161
node.flowNode = undefined; // initialized by binder (FlowContainer)
@@ -1186,13 +1185,13 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
11861185
}
11871186

11881187
const node = createBaseIdentifier(escapeLeadingUnderscores(text), originalKeywordKind);
1189-
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
1188+
if (hasExtendedUnicodeEscape) node.flags |= NodeFlags.HasExtendedUnicodeEscape;
11901189

11911190
// NOTE: we do not include transform flags of typeArguments in an identifier as they do not contribute to transformations
11921191
if (node.originalKeywordKind === SyntaxKind.AwaitKeyword) {
11931192
node.transformFlags |= TransformFlags.ContainsPossibleTopLevelAwait;
11941193
}
1195-
if (node.hasExtendedUnicodeEscape) {
1194+
if (node.flags & NodeFlags.HasExtendedUnicodeEscape) {
11961195
node.transformFlags |= TransformFlags.ContainsES2015;
11971196
}
11981197

@@ -6381,7 +6380,6 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
63816380
function cloneIdentifier(node: Identifier): Identifier {
63826381
const clone = createBaseIdentifier(node.escapedText, node.originalKeywordKind);
63836382
clone.flags |= node.flags & ~NodeFlags.Synthesized;
6384-
clone.hasExtendedUnicodeEscape = node.hasExtendedUnicodeEscape;
63856383
clone.jsDoc = node.jsDoc;
63866384
clone.jsDocCache = node.jsDocCache;
63876385
clone.flowNode = node.flowNode;

Diff for: src/compiler/transformers/es2015.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile
856856
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
857857
}
858858
}
859-
if (node.hasExtendedUnicodeEscape) {
859+
if (node.flags & NodeFlags.HasExtendedUnicodeEscape) {
860860
return setOriginalNode(setTextRange(
861861
factory.createIdentifier(unescapeLeadingUnderscores(node.escapedText)),
862862
node

Diff for: src/compiler/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ export const enum NodeFlags {
831831
// never cleared on SourceFiles which get re-used in between incremental parses.
832832
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
833833
/** @internal */ PermanentlySetIncrementalFlags = PossiblyContainsDynamicImport | PossiblyContainsImportMeta,
834+
835+
/** @internal */ HasExtendedUnicodeEscape = ContainsThis, // Reuses ContainsThis value with a different meaning on Identifiers
834836
}
835837

836838
export const enum ModifierFlags {
@@ -1682,7 +1684,6 @@ export interface Identifier extends PrimaryExpression, Declaration, JSDocContain
16821684
/** @internal */ generatedImportReference?: ImportSpecifier; // Reference to the generated import specifier this identifier refers to
16831685
isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace
16841686
/** @internal */ jsdocDotPos?: number; // Identifier occurs in JSDoc-style generic: Id.<T>
1685-
/** @internal */ hasExtendedUnicodeEscape?: boolean;
16861687
}
16871688

16881689
// Transient identifier node (marked by id === -1)

Diff for: src/harness/harnessUtils.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as ts from "./_namespaces/ts";
22
import * as Harness from "./_namespaces/Harness";
3+
import { isIdentifier } from "./_namespaces/ts";
34

45
export function encodeString(s: string): string {
56
return ts.sys.bufferFrom!(s).toString("utf8");
@@ -189,7 +190,7 @@ export function sourceFileToJSON(file: ts.Node): string {
189190
o.containsParseError = true;
190191
}
191192

192-
for (const propertyName of Object.getOwnPropertyNames(n) as readonly (keyof ts.SourceFile | keyof ts.Identifier)[]) {
193+
for (const propertyName of Object.getOwnPropertyNames(n) as readonly (keyof ts.SourceFile | keyof ts.Identifier | keyof ts.StringLiteral)[]) {
193194
switch (propertyName) {
194195
case "parent":
195196
case "symbol":
@@ -219,7 +220,13 @@ export function sourceFileToJSON(file: ts.Node): string {
219220
// Clear the flags that are produced by aggregating child values. That is ephemeral
220221
// data we don't care about in the dump. We only care what the parser set directly
221222
// on the AST.
222-
const flags = n.flags & ~(ts.NodeFlags.JavaScriptFile | ts.NodeFlags.HasAggregatedChildData);
223+
let flags = n.flags & ~(ts.NodeFlags.JavaScriptFile | ts.NodeFlags.HasAggregatedChildData);
224+
if (isIdentifier(n)) {
225+
if (flags & ts.NodeFlags.HasExtendedUnicodeEscape) {
226+
o.hasExtendedUnicodeEscape = true;
227+
flags &= ~ts.NodeFlags.HasExtendedUnicodeEscape;
228+
}
229+
}
223230
if (flags) {
224231
o[propertyName] = getNodeFlagName(flags);
225232
}

0 commit comments

Comments
 (0)