Skip to content

Commit afc0496

Browse files
committed
Refactor wrapSymbolTrackerToReportForContext to improve perf
1 parent d4c2ef3 commit afc0496

File tree

6 files changed

+200
-120
lines changed

6 files changed

+200
-120
lines changed

src/compiler/checker.ts

+187-100
Large diffs are not rendered by default.

src/compiler/emitter.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import {
2828
BundleFileTextLikeKind,
2929
CallExpression,
3030
CallSignatureDeclaration,
31-
canHaveLocals, CaseBlock,
31+
canHaveLocals,
32+
CaseBlock,
3233
CaseClause,
3334
CaseOrDefaultClause,
3435
cast,
@@ -181,7 +182,8 @@ import {
181182
getTransformers,
182183
getTypeNode,
183184
guessIndentation,
184-
HasLocals, hasRecordedExternalHelpers,
185+
HasLocals,
186+
hasRecordedExternalHelpers,
185187
HeritageClause,
186188
Identifier,
187189
idText,
@@ -412,7 +414,8 @@ import {
412414
tracing,
413415
TransformationResult,
414416
transformNodes,
415-
tryCast, tryParseRawSourceMap,
417+
tryCast,
418+
tryParseRawSourceMap,
416419
TryStatement,
417420
TupleTypeNode,
418421
TypeAliasDeclaration,

src/compiler/types.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,13 @@ export interface Node extends ReadonlyTextRange {
896896
/** @internal */ modifierFlagsCache: ModifierFlags;
897897
/** @internal */ readonly transformFlags: TransformFlags; // Flags for transforms
898898
/** @internal */ id?: NodeId; // Unique id (used to look up NodeLinks)
899-
readonly parent: Node; // Parent node (initialized by binding)
899+
readonly parent: Node; // Parent node (initialized by binding)
900900
/** @internal */ original?: Node; // The original node if this is an updated node.
901-
902901
/** @internal */ emitNode?: EmitNode; // Associated EmitNode (initialized by transforms)
902+
// NOTE: `symbol` and `localSymbol` have been moved to `Declaration`
903+
// `locals` and `nextContainer` have been moved to `LocalsContainer`
904+
// `flowNode` has been moved to `FlowContainer`
905+
// see: https://github.com/microsoft/TypeScript/pull/51682
903906
}
904907

905908
export interface JSDocContainer extends Node {
@@ -5381,7 +5384,7 @@ export interface SymbolWalker {
53815384

53825385
// This was previously deprecated in our public API, but is still used internally
53835386
/** @internal */
5384-
export interface SymbolWriter extends SymbolTracker {
5387+
export interface SymbolWriter {
53855388
writeKeyword(text: string): void;
53865389
writeOperator(text: string): void;
53875390
writePunctuation(text: string): void;

src/compiler/utilities.ts

-8
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,6 @@ function createSingleLineStringWriter(): EmitTextWriter {
607607
increaseIndent: noop,
608608
decreaseIndent: noop,
609609
clear: () => str = "",
610-
trackSymbol: () => false,
611-
reportInaccessibleThisError: noop,
612-
reportInaccessibleUniqueSymbolError: noop,
613-
reportPrivateInBaseOfClassExpression: noop,
614610
};
615611
}
616612

@@ -5325,10 +5321,6 @@ export function createTextWriter(newLine: string): EmitTextWriter {
53255321
hasTrailingComment: () => hasTrailingComment,
53265322
hasTrailingWhitespace: () => !!output.length && isWhiteSpaceLike(output.charCodeAt(output.length - 1)),
53275323
clear: reset,
5328-
reportInaccessibleThisError: noop,
5329-
reportPrivateInBaseOfClassExpression: noop,
5330-
reportInaccessibleUniqueSymbolError: noop,
5331-
trackSymbol: () => false,
53325324
writeKeyword: write,
53335325
writeOperator: write,
53345326
writeParameter: write,

src/services/inlayHints.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
387387
const printer = createPrinter(options);
388388

389389
return usingSingleLineStringWriter(writer => {
390-
const typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer);
390+
const typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags);
391391
Debug.assertIsDefined(typeNode, "should always get typenode");
392392
printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ file, writer);
393393
});

src/services/utilities.ts

-5
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ import {
271271
nodeIsMissing,
272272
nodeIsPresent,
273273
nodeIsSynthesized,
274-
noop,
275274
normalizePath,
276275
NoSubstitutionTemplateLiteral,
277276
notImplemented,
@@ -2721,10 +2720,6 @@ function getDisplayPartWriter(): DisplayPartsSymbolWriter {
27212720
increaseIndent: () => { indent++; },
27222721
decreaseIndent: () => { indent--; },
27232722
clear: resetWriter,
2724-
trackSymbol: () => false,
2725-
reportInaccessibleThisError: noop,
2726-
reportInaccessibleUniqueSymbolError: noop,
2727-
reportPrivateInBaseOfClassExpression: noop,
27282723
};
27292724

27302725
function writeIndent() {

0 commit comments

Comments
 (0)