Skip to content

Commit 5b7ca78

Browse files
PR feedback.
1 parent c27b3d3 commit 5b7ca78

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

src/compiler/binder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ namespace ts {
9090
let lastContainer: Node;
9191
let symbolCount = 0;
9292
let Symbol = objectAllocator.getSymbolConstructor();
93-
let typeNames: Map<string> = {};
93+
let classifiableNames: Map<string> = {};
9494

9595
if (!file.locals) {
9696
bind(file);
9797
file.symbolCount = symbolCount;
98-
file.typeNames = typeNames;
98+
file.classifiableNames = classifiableNames;
9999
}
100100

101101
return;
@@ -197,8 +197,8 @@ namespace ts {
197197
? symbolTable[name]
198198
: (symbolTable[name] = createSymbol(SymbolFlags.None, name));
199199

200-
if (name && (includes & (SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.TypeAlias | SymbolFlags.Interface | SymbolFlags.TypeParameter | SymbolFlags.Module))) {
201-
typeNames[name] = name;
200+
if (name && (includes & SymbolFlags.Classifiable)) {
201+
classifiableNames[name] = name;
202202
}
203203

204204
if (symbol.flags & excludes) {

src/compiler/program.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace ts {
148148
let commonSourceDirectory: string;
149149
let diagnosticsProducingTypeChecker: TypeChecker;
150150
let noDiagnosticsTypeChecker: TypeChecker;
151-
let typeNames: Map<string>;
151+
let classifiableNames: Map<string>;
152152

153153
let start = new Date().getTime();
154154

@@ -173,7 +173,7 @@ namespace ts {
173173
getDeclarationDiagnostics,
174174
getCompilerOptionsDiagnostics,
175175
getTypeChecker,
176-
getTypeNames,
176+
getClassifiableNames,
177177
getDiagnosticsProducingTypeChecker,
178178
getCommonSourceDirectory: () => commonSourceDirectory,
179179
emit,
@@ -185,18 +185,18 @@ namespace ts {
185185
};
186186
return program;
187187

188-
function getTypeNames() {
189-
if (!typeNames) {
188+
function getClassifiableNames() {
189+
if (!classifiableNames) {
190190
// Initialize a checker so that all our files are bound.
191191
getTypeChecker();
192-
typeNames = {};
192+
classifiableNames = {};
193193

194194
for (let sourceFile of files) {
195-
copyMap(sourceFile.typeNames, typeNames);
195+
copyMap(sourceFile.classifiableNames, classifiableNames);
196196
}
197197
}
198198

199-
return typeNames;
199+
return classifiableNames;
200200
}
201201

202202
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {

src/compiler/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ namespace ts {
422422
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
423423
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
424424
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
425-
/* @internal */ typeNames?: Map<string>;
426425
}
427426

428427
export interface NodeArray<T> extends Array<T>, TextRange {
@@ -1173,6 +1172,8 @@ namespace ts {
11731172
// Stores a line map for the file.
11741173
// This field should never be used directly to obtain line map, use getLineMap function instead.
11751174
/* @internal */ lineMap: number[];
1175+
1176+
/* @internal */ classifiableNames?: Map<string>;
11761177
}
11771178

11781179
export interface ScriptReferenceHost {
@@ -1224,7 +1225,7 @@ namespace ts {
12241225
// language service).
12251226
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
12261227

1227-
/* @internal */ getTypeNames(): Map<string>;
1228+
/* @internal */ getClassifiableNames(): Map<string>;
12281229

12291230
/* @internal */ getNodeCount(): number;
12301231
/* @internal */ getIdentifierCount(): number;
@@ -1522,6 +1523,11 @@ namespace ts {
15221523

15231524
PropertyOrAccessor = Property | Accessor,
15241525
Export = ExportNamespace | ExportType | ExportValue,
1526+
1527+
/* @internal */
1528+
// The set of things we consider semantically classifiable. Used to speed up the LS during
1529+
// classification.
1530+
Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module,
15251531
}
15261532

15271533
export interface Symbol {

src/services/services.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5992,7 +5992,7 @@ namespace ts {
59925992
let typeChecker = program.getTypeChecker();
59935993

59945994
let result: number[] = [];
5995-
let typeNames = program.getTypeNames();
5995+
let classifiableNames = program.getClassifiableNames();
59965996
processNode(sourceFile);
59975997

59985998
return { spans: result, endOfLineState: EndOfLineState.None };
@@ -6005,6 +6005,9 @@ namespace ts {
60056005

60066006
function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning): ClassificationType {
60076007
let flags = symbol.getFlags();
6008+
if ((flags & SymbolFlags.Classifiable) === 0) {
6009+
return;
6010+
}
60086011

60096012
if (flags & SymbolFlags.Class) {
60106013
return ClassificationType.className;
@@ -6054,7 +6057,7 @@ namespace ts {
60546057
// Only bother calling into the typechecker if this is an identifier that
60556058
// could possibly resolve to a type name. This makes classification run
60566059
// in a third of the time it would normally take.
6057-
if (typeNames[identifier.text]) {
6060+
if (classifiableNames[identifier.text]) {
60586061
let symbol = typeChecker.getSymbolAtLocation(node);
60596062
if (symbol) {
60606063
let type = classifySymbol(symbol, getMeaningFromLocation(node));

0 commit comments

Comments
 (0)