Skip to content

Commit 844bb33

Browse files
committed
Upgrade lsif to 4.1.3
1 parent b512d91 commit 844bb33

File tree

8 files changed

+100
-32
lines changed

8 files changed

+100
-32
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "https://www.typescriptlang.org/",
5-
"version": "4.1.3",
5+
"version": "4.1.3-lsif.1",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [
@@ -128,6 +128,5 @@
128128
"@microsoft/typescript-etw": false,
129129
"source-map-support": false,
130130
"inspector": false
131-
},
132-
"dependencies": {}
131+
}
133132
}

src/compiler/checker.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ namespace ts {
381381
// extra cost of calling `getParseTreeNode` when calling these functions from inside the
382382
// checker.
383383
const checker: TypeChecker = {
384+
setSymbolChainCache: (cache: SymbolChainCache | undefined): void => {
385+
nodeBuilder.setSymbolChainCache(cache);
386+
},
384387
getNodeCount: () => sum(host.getSourceFiles(), "nodeCount"),
385388
getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"),
386389
getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount,
@@ -4323,7 +4326,9 @@ namespace ts {
43234326
}
43244327

43254328
function createNodeBuilder() {
4329+
let symbolChainCache: SymbolChainCache | undefined;
43264330
return {
4331+
setSymbolChainCache: (cache: SymbolChainCache | undefined): void => { symbolChainCache = cache },
43274332
typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) =>
43284333
withContext(enclosingDeclaration, flags, tracker, context => typeToTypeNodeHelper(type, context)),
43294334
indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) =>
@@ -4341,7 +4346,7 @@ namespace ts {
43414346
typeParameterToDeclaration: (parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker) =>
43424347
withContext(enclosingDeclaration, flags, tracker, context => typeParameterToDeclaration(parameter, context)),
43434348
symbolTableToDeclarationStatements: (symbolTable: SymbolTable, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker, bundled?: boolean) =>
4344-
withContext(enclosingDeclaration, flags, tracker, context => symbolTableToDeclarationStatements(symbolTable, context, bundled)),
4349+
withContext(enclosingDeclaration, flags, tracker, context => symbolTableToDeclarationStatements(symbolTable, context, bundled))
43454350
};
43464351

43474352
function withContext<T>(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker: SymbolTracker | undefined, cb: (context: NodeBuilderContext) => T): T | undefined {
@@ -4361,6 +4366,7 @@ namespace ts {
43614366
isSourceOfProjectReferenceRedirect: fileName => host.isSourceOfProjectReferenceRedirect(fileName),
43624367
fileExists: fileName => host.fileExists(fileName),
43634368
} : undefined },
4369+
cache: symbolChainCache,
43644370
encounteredError: false,
43654371
visitedTypes: undefined,
43664372
symbolDepth: undefined,
@@ -5333,6 +5339,30 @@ namespace ts {
53335339

53345340
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
53355341
function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined {
5342+
let key: SymbolChainCacheKey | undefined;
5343+
let result: Symbol[] | undefined;
5344+
if (context.cache) {
5345+
key = {
5346+
symbol,
5347+
enclosingDeclaration: context.enclosingDeclaration,
5348+
flags: context.flags,
5349+
meaning: meaning,
5350+
yieldModuleSymbol: yieldModuleSymbol,
5351+
endOfChain: endOfChain
5352+
}
5353+
result = context.cache.lookup(key);
5354+
if (result) {
5355+
return result;
5356+
}
5357+
}
5358+
result = doGetSymbolChain(symbol, meaning, endOfChain);
5359+
if (result && key && context.cache) {
5360+
context.cache.cache(key, result);
5361+
}
5362+
return result;
5363+
}
5364+
5365+
function doGetSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined {
53365366
let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & NodeBuilderFlags.UseOnlyExternalAliasing));
53375367
let parentSpecifiers: (string | undefined)[];
53385368
if (!accessibleSymbolChain ||
@@ -7446,6 +7476,7 @@ namespace ts {
74467476
enclosingDeclaration: Node | undefined;
74477477
flags: NodeBuilderFlags;
74487478
tracker: SymbolTracker;
7479+
cache: SymbolChainCache | undefined;
74497480

74507481
// State
74517482
encounteredError: boolean;

src/compiler/types.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3919,7 +3919,22 @@ namespace ts {
39193919
readonly redirectTargetsMap: RedirectTargetsMap;
39203920
}
39213921

3922+
export interface SymbolChainCacheKey {
3923+
symbol: Symbol;
3924+
enclosingDeclaration?: Node;
3925+
flags: NodeBuilderFlags;
3926+
meaning: SymbolFlags;
3927+
yieldModuleSymbol?: boolean;
3928+
endOfChain: boolean;
3929+
}
3930+
3931+
export interface SymbolChainCache {
3932+
lookup(key: SymbolChainCacheKey): Symbol[] | undefined;
3933+
cache(key: SymbolChainCacheKey, value: Symbol[]): void;
3934+
}
3935+
39223936
export interface TypeChecker {
3937+
setSymbolChainCache(cache: SymbolChainCache | undefined): void;
39233938
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
39243939
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
39253940
getPropertiesOfType(type: Type): Symbol[];

src/harness/client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ namespace ts.server {
163163
return { line, character: offset };
164164
}
165165

166-
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
166+
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
167+
getQuickInfoAtPosition(node: ts.Node, sourceFile?: ts.SourceFile): QuickInfo;
168+
getQuickInfoAtPosition(arg0: string | ts.Node, arg1: number | ts.SourceFile | undefined): QuickInfo {
169+
const fileName = typeof arg0 === "string" ? arg0 : arg1 !== undefined ? (arg1 as ts.SourceFile).fileName : arg0.getSourceFile().fileName;
170+
const position = typeof arg0 === "string" ? arg1 as number : arg0.getStart(arg1 as ts.SourceFile);
167171
const args = this.createFileLocationRequestArgs(fileName, position);
168172

169173
const request = this.processRequest<protocol.QuickInfoRequest>(CommandNames.Quickinfo, args);
@@ -574,7 +578,10 @@ namespace ts.server {
574578
}));
575579
}
576580

577-
getOutliningSpans(file: string): OutliningSpan[] {
581+
getOutliningSpans(file: string): OutliningSpan[];
582+
getOutliningSpans(sourceFile: ts.SourceFile): OutliningSpan[];
583+
getOutliningSpans(arg0: string | ts.SourceFile): OutliningSpan[] {
584+
const file = typeof arg0 === "string" ? arg0 : arg0.fileName;
578585
const request = this.processRequest<protocol.OutliningSpansRequest>(CommandNames.GetOutliningSpans, { file });
579586
const response = this.processResponse<protocol.OutliningSpansResponse>(request);
580587

src/harness/harnessLanguageService.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,10 @@ namespace Harness.LanguageService {
480480
getCompletionEntrySymbol(): ts.Symbol {
481481
throw new Error("getCompletionEntrySymbol not implemented across the shim layer.");
482482
}
483-
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo {
484-
return unwrapJSONCallResult(this.shim.getQuickInfoAtPosition(fileName, position));
483+
getQuickInfoAtPosition(filename: string, position: number): ts.QuickInfo | undefined;
484+
getQuickInfoAtPosition(node: ts.Node, sourceFile: ts.SourceFile | undefined): ts.QuickInfo | undefined;
485+
getQuickInfoAtPosition(arg0: string | ts.Node, arg1: number | ts.SourceFile | undefined): ts.QuickInfo | undefined {
486+
return unwrapJSONCallResult(this.shim.getQuickInfoAtPosition(arg0 as any, arg1 as any));
485487
}
486488
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): ts.TextSpan {
487489
return unwrapJSONCallResult(this.shim.getNameOrDottedNameSpan(fileName, startPos, endPos));
@@ -534,8 +536,8 @@ namespace Harness.LanguageService {
534536
getNavigationTree(fileName: string): ts.NavigationTree {
535537
return unwrapJSONCallResult(this.shim.getNavigationTree(fileName));
536538
}
537-
getOutliningSpans(fileName: string): ts.OutliningSpan[] {
538-
return unwrapJSONCallResult(this.shim.getOutliningSpans(fileName));
539+
getOutliningSpans(arg0: string | ts.SourceFile): ts.OutliningSpan[] {
540+
return unwrapJSONCallResult(this.shim.getOutliningSpans(arg0 as any));
539541
}
540542
getTodoComments(fileName: string, descriptors: ts.TodoCommentDescriptor[]): ts.TodoComment[] {
541543
return unwrapJSONCallResult(this.shim.getTodoComments(fileName, JSON.stringify(descriptors)));
@@ -855,7 +857,6 @@ namespace Harness.LanguageService {
855857
create(info: ts.server.PluginCreateInfo) {
856858
const proxy = makeDefaultProxy(info);
857859
const langSvc: any = info.languageService;
858-
// eslint-disable-next-line only-arrow-functions
859860
proxy.getQuickInfoAtPosition = function () {
860861
const parts = langSvc.getQuickInfoAtPosition.apply(langSvc, arguments);
861862
if (parts.displayParts.length > 0) {

src/services/services.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,11 +1567,15 @@ namespace ts {
15671567
return Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name, source }, host, preferences);
15681568
}
15691569

1570-
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined {
1571-
synchronizeHostData();
1570+
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
1571+
function getQuickInfoAtPosition(node: ts.Node, sourceFile?: ts.SourceFile): QuickInfo | undefined;
1572+
function getQuickInfoAtPosition(arg0: string | ts.Node, arg1: number | ts.SourceFile | undefined): QuickInfo | undefined {
1573+
synchronizeHostData();
1574+
1575+
const sourceFile: ts.SourceFile = typeof arg0 === 'string' ? getValidSourceFile(arg0) : (arg1 !== undefined) ? arg1 as ts.SourceFile : arg0.getSourceFile();
1576+
const node: ts.Node = typeof arg0 === 'string' ? getTouchingPropertyName(sourceFile, arg1 as number) : arg0;
1577+
const position: number = typeof arg1 === 'number' ? arg1 : node.getStart(sourceFile, false);
15721578

1573-
const sourceFile = getValidSourceFile(fileName);
1574-
const node = getTouchingPropertyName(sourceFile, position);
15751579
if (node === sourceFile) {
15761580
// Avoid giving quickInfo for the sourceFile as a whole.
15771581
return undefined;
@@ -1870,11 +1874,13 @@ namespace ts {
18701874
return ts.getEncodedSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span);
18711875
}
18721876

1873-
function getOutliningSpans(fileName: string): OutliningSpan[] {
1874-
// doesn't use compiler - no need to synchronize with host
1875-
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
1876-
return OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
1877-
}
1877+
function getOutliningSpans(fileName: string): OutliningSpan[];
1878+
function getOutliningSpans(sourceFile: ts.SourceFile): OutliningSpan[];
1879+
function getOutliningSpans(arg0: string | ts.SourceFile): OutliningSpan[] {
1880+
// doesn't use compiler - no need to synchronize with host
1881+
const sourceFile = typeof arg0 === 'string' ? syntaxTreeCache.getCurrentSourceFile(arg0) : arg0;
1882+
return OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
1883+
}
18781884

18791885
const braceMatching = new Map(getEntries({
18801886
[SyntaxKind.OpenBraceToken]: SyntaxKind.CloseBraceToken,

src/services/shims.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -756,12 +756,16 @@ namespace ts {
756756
* Computes a string representation of the type at the requested position
757757
* in the active file.
758758
*/
759-
public getQuickInfoAtPosition(fileName: string, position: number): string {
760-
return this.forwardJSONCall(
761-
`getQuickInfoAtPosition('${fileName}', ${position})`,
762-
() => this.languageService.getQuickInfoAtPosition(fileName, position)
763-
);
764-
}
759+
public getQuickInfoAtPosition(fileName: string, position: number): string;
760+
public getQuickInfoAtPosition(node: ts.Node, sourceFile: ts.SourceFile | undefined): string;
761+
public getQuickInfoAtPosition(arg0: string | ts.Node, arg1: number | ts.SourceFile | undefined): string {
762+
const fileName = typeof arg0 === "string" ? arg0 : arg1 !== undefined ? (arg1 as ts.SourceFile).fileName : arg0.getSourceFile().fileName;
763+
const position = typeof arg0 === "string" ? arg1 as number : arg0.getStart(arg1 as ts.SourceFile);
764+
return this.forwardJSONCall(
765+
`getQuickInfoAtPosition('${fileName}', ${position})`,
766+
() => this.languageService.getQuickInfoAtPosition(arg0 as any, arg1 as any)
767+
);
768+
}
765769

766770

767771
/// NAMEORDOTTEDNAMESPAN
@@ -1017,12 +1021,15 @@ namespace ts {
10171021
);
10181022
}
10191023

1020-
public getOutliningSpans(fileName: string): string {
1021-
return this.forwardJSONCall(
1022-
`getOutliningSpans('${fileName}')`,
1023-
() => this.languageService.getOutliningSpans(fileName)
1024-
);
1025-
}
1024+
public getOutliningSpans(fileName: string): string;
1025+
public getOutliningSpans(sourceFile: ts.SourceFile): string;
1026+
public getOutliningSpans(arg0: string | ts.SourceFile): string {
1027+
let fileName = typeof arg0 === "string" ? arg0 : arg0.fileName;
1028+
return this.forwardJSONCall(
1029+
`getOutliningSpans('${fileName}')`,
1030+
() => this.languageService.getOutliningSpans(arg0 as any)
1031+
);
1032+
}
10261033

10271034
public getTodoComments(fileName: string, descriptors: string): string {
10281035
return this.forwardJSONCall(

src/services/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ namespace ts {
446446
* @param position A zero-based index of the character where you want the quick info
447447
*/
448448
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
449+
getQuickInfoAtPosition(node: ts.Node, sourceFile?: ts.SourceFile): QuickInfo | undefined;
449450

450451
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
451452

@@ -479,6 +480,7 @@ namespace ts {
479480
provideCallHierarchyOutgoingCalls(fileName: string, position: number): CallHierarchyOutgoingCall[];
480481

481482
getOutliningSpans(fileName: string): OutliningSpan[];
483+
getOutliningSpans(sourceFile: ts.SourceFile): OutliningSpan[];
482484
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
483485
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
484486
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number;

0 commit comments

Comments
 (0)