Skip to content

Commit

Permalink
Move LSIF to TS 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Apr 23, 2021
1 parent 618b518 commit 0d7f06c
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 83 deletions.
29 changes: 29 additions & 0 deletions lib/tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36367,6 +36367,9 @@ var ts;
var requireSymbol = createSymbol(4, "require");
var apparentArgumentCount;
var checker = {
setSymbolChainCache: function (cache) {
nodeBuilder.setSymbolChainCache(cache);
},
getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
Expand Down Expand Up @@ -39625,7 +39628,9 @@ var ts;
return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824));
}
function createNodeBuilder() {
var symbolChainCache;
return {
setSymbolChainCache: function (cache) { symbolChainCache = cache; },
typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
},
Expand Down Expand Up @@ -39672,6 +39677,7 @@ var ts;
fileExists: function (fileName) { return host.fileExists(fileName); },
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
} : undefined },
cache: symbolChainCache,
encounteredError: false,
visitedTypes: undefined,
symbolDepth: undefined,
Expand Down Expand Up @@ -40544,6 +40550,29 @@ var ts;
}
return chain;
function getSymbolChain(symbol, meaning, endOfChain) {
var key;
var result;
if (context.cache) {
key = {
symbol: symbol,
enclosingDeclaration: context.enclosingDeclaration,
flags: context.flags,
meaning: meaning,
yieldModuleSymbol: yieldModuleSymbol,
endOfChain: endOfChain
};
result = context.cache.lookup(key);
if (result) {
return result;
}
}
result = doGetSymbolChain(symbol, meaning, endOfChain);
if (result && key && context.cache) {
context.cache.cache(key, result);
}
return result;
}
function doGetSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
var parentSpecifiers;
if (!accessibleSymbolChain ||
Expand Down
56 changes: 42 additions & 14 deletions lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -44650,6 +44650,9 @@ var ts;
// extra cost of calling `getParseTreeNode` when calling these functions from inside the
// checker.
var checker = {
setSymbolChainCache: function (cache) {
nodeBuilder.setSymbolChainCache(cache);
},
getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
Expand Down Expand Up @@ -48372,7 +48375,9 @@ var ts;
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */));
}
function createNodeBuilder() {
var symbolChainCache;
return {
setSymbolChainCache: function (cache) { symbolChainCache = cache; },
typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
},
Expand Down Expand Up @@ -48420,6 +48425,7 @@ var ts;
fileExists: function (fileName) { return host.fileExists(fileName); },
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
} : undefined },
cache: symbolChainCache,
encounteredError: false,
visitedTypes: undefined,
symbolDepth: undefined,
Expand Down Expand Up @@ -49340,6 +49346,29 @@ var ts;
return chain;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
var key;
var result;
if (context.cache) {
key = {
symbol: symbol,
enclosingDeclaration: context.enclosingDeclaration,
flags: context.flags,
meaning: meaning,
yieldModuleSymbol: yieldModuleSymbol,
endOfChain: endOfChain
};
result = context.cache.lookup(key);
if (result) {
return result;
}
}
result = doGetSymbolChain(symbol, meaning, endOfChain);
if (result && key && context.cache) {
context.cache.cache(key, result);
}
return result;
}
function doGetSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
var parentSpecifiers;
if (!accessibleSymbolChain ||
Expand Down Expand Up @@ -152926,10 +152955,11 @@ var ts;
synchronizeHostData();
return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, preferences);
}
function getQuickInfoAtPosition(fileName, position) {
function getQuickInfoAtPosition(arg0, arg1) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var node = ts.getTouchingPropertyName(sourceFile, position);
var sourceFile = typeof arg0 === 'string' ? getValidSourceFile(arg0) : (arg1 !== undefined) ? arg1 : arg0.getSourceFile();
var node = typeof arg0 === 'string' ? ts.getTouchingPropertyName(sourceFile, arg1) : arg0;
var position = typeof arg1 === 'number' ? arg1 : node.getStart(sourceFile, false);
if (node === sourceFile) {
// Avoid giving quickInfo for the sourceFile as a whole.
return undefined;
Expand Down Expand Up @@ -153178,9 +153208,9 @@ var ts;
// doesn't use compiler - no need to synchronize with host
return ts.getEncodedSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span);
}
function getOutliningSpans(fileName) {
function getOutliningSpans(arg0) {
// doesn't use compiler - no need to synchronize with host
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
var sourceFile = typeof arg0 === 'string' ? syntaxTreeCache.getCurrentSourceFile(arg0) : arg0;
return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
}
var braceMatching = new ts.Map(ts.getEntries((_a = {},
Expand Down Expand Up @@ -154925,14 +154955,11 @@ var ts;
return _this.realizeDiagnostics(diagnostics);
});
};
/// QUICKINFO
/**
* Computes a string representation of the type at the requested position
* in the active file.
*/
LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) {
LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (arg0, arg1) {
var _this = this;
return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); });
var fileName = typeof arg0 === "string" ? arg0 : arg1 !== undefined ? arg1.fileName : arg0.getSourceFile().fileName;
var position = typeof arg0 === "string" ? arg1 : arg0.getStart(arg1);
return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(arg0, arg1); });
};
/// NAMEORDOTTEDNAMESPAN
/**
Expand Down Expand Up @@ -155107,9 +155134,10 @@ var ts;
var _this = this;
return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); });
};
LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) {
LanguageServiceShimObject.prototype.getOutliningSpans = function (arg0) {
var _this = this;
return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); });
var fileName = typeof arg0 === "string" ? arg0 : arg0.fileName;
return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(arg0); });
};
LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) {
var _this = this;
Expand Down
15 changes: 15 additions & 0 deletions lib/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,20 @@ declare namespace ts {
diagnostics: readonly Diagnostic[];
emittedFiles?: string[];
}
export interface SymbolChainCacheKey {
symbol: Symbol;
enclosingDeclaration?: Node;
flags: NodeBuilderFlags;
meaning: SymbolFlags;
yieldModuleSymbol?: boolean;
endOfChain: boolean;
}
export interface SymbolChainCache {
lookup(key: SymbolChainCacheKey): Symbol[] | undefined;
cache(key: SymbolChainCacheKey, value: Symbol[]): void;
}
export interface TypeChecker {
setSymbolChainCache(cache: SymbolChainCache | undefined): void;
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
getPropertiesOfType(type: Type): Symbol[];
Expand Down Expand Up @@ -5599,6 +5612,7 @@ declare namespace ts {
* @param position A zero-based index of the character where you want the quick info
*/
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined;
getQuickInfoAtPosition(node: ts.Node, sourceFile?: ts.SourceFile): QuickInfo | undefined;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
Expand All @@ -5622,6 +5636,7 @@ declare namespace ts {
provideCallHierarchyIncomingCalls(fileName: string, position: number): CallHierarchyIncomingCall[];
provideCallHierarchyOutgoingCalls(fileName: string, position: number): CallHierarchyOutgoingCall[];
getOutliningSpans(fileName: string): OutliningSpan[];
getOutliningSpans(sourceFile: ts.SourceFile): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number;
Expand Down
56 changes: 42 additions & 14 deletions lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -44844,6 +44844,9 @@ var ts;
// extra cost of calling `getParseTreeNode` when calling these functions from inside the
// checker.
var checker = {
setSymbolChainCache: function (cache) {
nodeBuilder.setSymbolChainCache(cache);
},
getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
Expand Down Expand Up @@ -48566,7 +48569,9 @@ var ts;
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */));
}
function createNodeBuilder() {
var symbolChainCache;
return {
setSymbolChainCache: function (cache) { symbolChainCache = cache; },
typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
},
Expand Down Expand Up @@ -48614,6 +48619,7 @@ var ts;
fileExists: function (fileName) { return host.fileExists(fileName); },
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
} : undefined },
cache: symbolChainCache,
encounteredError: false,
visitedTypes: undefined,
symbolDepth: undefined,
Expand Down Expand Up @@ -49534,6 +49540,29 @@ var ts;
return chain;
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
function getSymbolChain(symbol, meaning, endOfChain) {
var key;
var result;
if (context.cache) {
key = {
symbol: symbol,
enclosingDeclaration: context.enclosingDeclaration,
flags: context.flags,
meaning: meaning,
yieldModuleSymbol: yieldModuleSymbol,
endOfChain: endOfChain
};
result = context.cache.lookup(key);
if (result) {
return result;
}
}
result = doGetSymbolChain(symbol, meaning, endOfChain);
if (result && key && context.cache) {
context.cache.cache(key, result);
}
return result;
}
function doGetSymbolChain(symbol, meaning, endOfChain) {
var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */));
var parentSpecifiers;
if (!accessibleSymbolChain ||
Expand Down Expand Up @@ -153495,10 +153524,11 @@ var ts;
synchronizeHostData();
return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, preferences);
}
function getQuickInfoAtPosition(fileName, position) {
function getQuickInfoAtPosition(arg0, arg1) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var node = ts.getTouchingPropertyName(sourceFile, position);
var sourceFile = typeof arg0 === 'string' ? getValidSourceFile(arg0) : (arg1 !== undefined) ? arg1 : arg0.getSourceFile();
var node = typeof arg0 === 'string' ? ts.getTouchingPropertyName(sourceFile, arg1) : arg0;
var position = typeof arg1 === 'number' ? arg1 : node.getStart(sourceFile, false);
if (node === sourceFile) {
// Avoid giving quickInfo for the sourceFile as a whole.
return undefined;
Expand Down Expand Up @@ -153747,9 +153777,9 @@ var ts;
// doesn't use compiler - no need to synchronize with host
return ts.getEncodedSyntacticClassifications(cancellationToken, syntaxTreeCache.getCurrentSourceFile(fileName), span);
}
function getOutliningSpans(fileName) {
function getOutliningSpans(arg0) {
// doesn't use compiler - no need to synchronize with host
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
var sourceFile = typeof arg0 === 'string' ? syntaxTreeCache.getCurrentSourceFile(arg0) : arg0;
return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
}
var braceMatching = new ts.Map(ts.getEntries((_a = {},
Expand Down Expand Up @@ -155494,14 +155524,11 @@ var ts;
return _this.realizeDiagnostics(diagnostics);
});
};
/// QUICKINFO
/**
* Computes a string representation of the type at the requested position
* in the active file.
*/
LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) {
LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (arg0, arg1) {
var _this = this;
return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); });
var fileName = typeof arg0 === "string" ? arg0 : arg1 !== undefined ? arg1.fileName : arg0.getSourceFile().fileName;
var position = typeof arg0 === "string" ? arg1 : arg0.getStart(arg1);
return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(arg0, arg1); });
};
/// NAMEORDOTTEDNAMESPAN
/**
Expand Down Expand Up @@ -155676,9 +155703,10 @@ var ts;
var _this = this;
return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); });
};
LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) {
LanguageServiceShimObject.prototype.getOutliningSpans = function (arg0) {
var _this = this;
return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); });
var fileName = typeof arg0 === "string" ? arg0 : arg0.fileName;
return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(arg0); });
};
LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) {
var _this = this;
Expand Down
Loading

0 comments on commit 0d7f06c

Please sign in to comment.