typescript 4.8.0-dev.20220518 → 4.8.0-dev.20220519
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +10 -8
- package/lib/tsserver.js +397 -268
- package/lib/tsserverlibrary.js +397 -268
- package/lib/typescript.js +155 -125
- package/lib/typescriptServices.js +155 -125
- package/lib/typingsInstaller.js +10 -8
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220519";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -82810,7 +82810,7 @@ var ts;
|
|
|
82810
82810
|
var childSymbol = getSymbolAtLocation(childNode);
|
|
82811
82811
|
if (childSymbol && childSymbol === testedSymbol) {
|
|
82812
82812
|
// If the test was a simple identifier, the above check is sufficient
|
|
82813
|
-
if (ts.isIdentifier(expr)) {
|
|
82813
|
+
if (ts.isIdentifier(expr) || ts.isIdentifier(testedNode) && ts.isBinaryExpression(testedNode.parent)) {
|
|
82814
82814
|
return true;
|
|
82815
82815
|
}
|
|
82816
82816
|
// Otherwise we need to ensure the symbol is called on the same target
|
|
@@ -116024,7 +116024,7 @@ var ts;
|
|
|
116024
116024
|
};
|
|
116025
116025
|
}
|
|
116026
116026
|
// directoryExists
|
|
116027
|
-
if (originalDirectoryExists
|
|
116027
|
+
if (originalDirectoryExists) {
|
|
116028
116028
|
host.directoryExists = function (directory) {
|
|
116029
116029
|
var key = toPath(directory);
|
|
116030
116030
|
var value = directoryExistsCache.get(key);
|
|
@@ -116034,11 +116034,13 @@ var ts;
|
|
|
116034
116034
|
directoryExistsCache.set(key, !!newValue);
|
|
116035
116035
|
return newValue;
|
|
116036
116036
|
};
|
|
116037
|
-
|
|
116038
|
-
|
|
116039
|
-
|
|
116040
|
-
|
|
116041
|
-
|
|
116037
|
+
if (originalCreateDirectory) {
|
|
116038
|
+
host.createDirectory = function (directory) {
|
|
116039
|
+
var key = toPath(directory);
|
|
116040
|
+
directoryExistsCache.delete(key);
|
|
116041
|
+
originalCreateDirectory.call(host, directory);
|
|
116042
|
+
};
|
|
116043
|
+
}
|
|
116042
116044
|
}
|
|
116043
116045
|
return {
|
|
116044
116046
|
originalReadFile: originalReadFile,
|
|
@@ -128424,6 +128426,41 @@ var ts;
|
|
|
128424
128426
|
return true;
|
|
128425
128427
|
}
|
|
128426
128428
|
ts.isTextWhiteSpaceLike = isTextWhiteSpaceLike;
|
|
128429
|
+
function getMappedLocation(location, sourceMapper, fileExists) {
|
|
128430
|
+
var mapsTo = sourceMapper.tryGetSourcePosition(location);
|
|
128431
|
+
return mapsTo && (!fileExists || fileExists(ts.normalizePath(mapsTo.fileName)) ? mapsTo : undefined);
|
|
128432
|
+
}
|
|
128433
|
+
ts.getMappedLocation = getMappedLocation;
|
|
128434
|
+
function getMappedDocumentSpan(documentSpan, sourceMapper, fileExists) {
|
|
128435
|
+
var fileName = documentSpan.fileName, textSpan = documentSpan.textSpan;
|
|
128436
|
+
var newPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start }, sourceMapper, fileExists);
|
|
128437
|
+
if (!newPosition)
|
|
128438
|
+
return undefined;
|
|
128439
|
+
var newEndPosition = getMappedLocation({ fileName: fileName, pos: textSpan.start + textSpan.length }, sourceMapper, fileExists);
|
|
128440
|
+
var newLength = newEndPosition
|
|
128441
|
+
? newEndPosition.pos - newPosition.pos
|
|
128442
|
+
: textSpan.length; // This shouldn't happen
|
|
128443
|
+
return {
|
|
128444
|
+
fileName: newPosition.fileName,
|
|
128445
|
+
textSpan: {
|
|
128446
|
+
start: newPosition.pos,
|
|
128447
|
+
length: newLength,
|
|
128448
|
+
},
|
|
128449
|
+
originalFileName: documentSpan.fileName,
|
|
128450
|
+
originalTextSpan: documentSpan.textSpan,
|
|
128451
|
+
contextSpan: getMappedContextSpan(documentSpan, sourceMapper, fileExists),
|
|
128452
|
+
originalContextSpan: documentSpan.contextSpan
|
|
128453
|
+
};
|
|
128454
|
+
}
|
|
128455
|
+
ts.getMappedDocumentSpan = getMappedDocumentSpan;
|
|
128456
|
+
function getMappedContextSpan(documentSpan, sourceMapper, fileExists) {
|
|
128457
|
+
var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, sourceMapper, fileExists);
|
|
128458
|
+
var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, sourceMapper, fileExists);
|
|
128459
|
+
return contextSpanStart && contextSpanEnd ?
|
|
128460
|
+
{ start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
|
|
128461
|
+
undefined;
|
|
128462
|
+
}
|
|
128463
|
+
ts.getMappedContextSpan = getMappedContextSpan;
|
|
128427
128464
|
// #endregion
|
|
128428
128465
|
// Display-part writer helpers
|
|
128429
128466
|
// #region
|
|
@@ -137345,6 +137382,7 @@ var ts;
|
|
|
137345
137382
|
var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined;
|
|
137346
137383
|
return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; })));
|
|
137347
137384
|
}
|
|
137385
|
+
FindAllReferences.isDeclarationOfSymbol = isDeclarationOfSymbol;
|
|
137348
137386
|
/**
|
|
137349
137387
|
* True if 'decl' provides a value, as in `function f() {}`;
|
|
137350
137388
|
* false if 'decl' is just a location for a future write, as in 'let x;'
|
|
@@ -164748,70 +164786,6 @@ var ts;
|
|
|
164748
164786
|
return ts.codefix.getSupportedErrorCodes();
|
|
164749
164787
|
}
|
|
164750
164788
|
ts.getSupportedCodeFixes = getSupportedCodeFixes;
|
|
164751
|
-
// Cache host information about script Should be refreshed
|
|
164752
|
-
// at each language service public entry point, since we don't know when
|
|
164753
|
-
// the set of scripts handled by the host changes.
|
|
164754
|
-
var HostCache = /** @class */ (function () {
|
|
164755
|
-
function HostCache(host, getCanonicalFileName) {
|
|
164756
|
-
this.host = host;
|
|
164757
|
-
// script id => script index
|
|
164758
|
-
this.currentDirectory = host.getCurrentDirectory();
|
|
164759
|
-
this.fileNameToEntry = new ts.Map();
|
|
164760
|
-
// Initialize the list with the root file names
|
|
164761
|
-
var rootFileNames = host.getScriptFileNames();
|
|
164762
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
164763
|
-
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
164764
|
-
var fileName = rootFileNames_1[_i];
|
|
164765
|
-
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
164766
|
-
}
|
|
164767
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
164768
|
-
}
|
|
164769
|
-
HostCache.prototype.createEntry = function (fileName, path) {
|
|
164770
|
-
var entry;
|
|
164771
|
-
var scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
|
164772
|
-
if (scriptSnapshot) {
|
|
164773
|
-
entry = {
|
|
164774
|
-
hostFileName: fileName,
|
|
164775
|
-
version: this.host.getScriptVersion(fileName),
|
|
164776
|
-
scriptSnapshot: scriptSnapshot,
|
|
164777
|
-
scriptKind: ts.getScriptKind(fileName, this.host)
|
|
164778
|
-
};
|
|
164779
|
-
}
|
|
164780
|
-
else {
|
|
164781
|
-
entry = fileName;
|
|
164782
|
-
}
|
|
164783
|
-
this.fileNameToEntry.set(path, entry);
|
|
164784
|
-
return entry;
|
|
164785
|
-
};
|
|
164786
|
-
HostCache.prototype.getEntryByPath = function (path) {
|
|
164787
|
-
return this.fileNameToEntry.get(path);
|
|
164788
|
-
};
|
|
164789
|
-
HostCache.prototype.getHostFileInformation = function (path) {
|
|
164790
|
-
var entry = this.fileNameToEntry.get(path);
|
|
164791
|
-
return !ts.isString(entry) ? entry : undefined;
|
|
164792
|
-
};
|
|
164793
|
-
HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) {
|
|
164794
|
-
var info = this.getEntryByPath(path) || this.createEntry(fileName, path);
|
|
164795
|
-
return ts.isString(info) ? undefined : info; // TODO: GH#18217
|
|
164796
|
-
};
|
|
164797
|
-
HostCache.prototype.getRootFileNames = function () {
|
|
164798
|
-
var names = [];
|
|
164799
|
-
this.fileNameToEntry.forEach(function (entry) {
|
|
164800
|
-
if (ts.isString(entry)) {
|
|
164801
|
-
names.push(entry);
|
|
164802
|
-
}
|
|
164803
|
-
else {
|
|
164804
|
-
names.push(entry.hostFileName);
|
|
164805
|
-
}
|
|
164806
|
-
});
|
|
164807
|
-
return names;
|
|
164808
|
-
};
|
|
164809
|
-
HostCache.prototype.getScriptSnapshot = function (path) {
|
|
164810
|
-
var file = this.getHostFileInformation(path);
|
|
164811
|
-
return (file && file.scriptSnapshot); // TODO: GH#18217
|
|
164812
|
-
};
|
|
164813
|
-
return HostCache;
|
|
164814
|
-
}());
|
|
164815
164789
|
var SyntaxTreeCache = /** @class */ (function () {
|
|
164816
164790
|
function SyntaxTreeCache(host) {
|
|
164817
164791
|
this.host = host;
|
|
@@ -165073,32 +165047,13 @@ var ts;
|
|
|
165073
165047
|
program = undefined; // TODO: GH#18217
|
|
165074
165048
|
lastTypesRootVersion = typeRootsVersion;
|
|
165075
165049
|
}
|
|
165050
|
+
var rootFileNames = host.getScriptFileNames();
|
|
165076
165051
|
// Get a fresh cache of the host information
|
|
165077
|
-
var hostCache = new HostCache(host, getCanonicalFileName);
|
|
165078
|
-
var rootFileNames = hostCache.getRootFileNames();
|
|
165079
165052
|
var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
|
|
165080
165053
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
165081
165054
|
var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
|
|
165082
165055
|
var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
165083
165056
|
var parsedCommandLines;
|
|
165084
|
-
var parseConfigHost = {
|
|
165085
|
-
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
|
165086
|
-
fileExists: fileExists,
|
|
165087
|
-
readFile: readFile,
|
|
165088
|
-
readDirectory: readDirectory,
|
|
165089
|
-
trace: ts.maybeBind(host, host.trace),
|
|
165090
|
-
getCurrentDirectory: function () { return currentDirectory; },
|
|
165091
|
-
onUnRecoverableConfigFileDiagnostic: ts.noop,
|
|
165092
|
-
};
|
|
165093
|
-
// If the program is already up-to-date, we can reuse it
|
|
165094
|
-
if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
165095
|
-
return;
|
|
165096
|
-
}
|
|
165097
|
-
// IMPORTANT - It is critical from this moment onward that we do not check
|
|
165098
|
-
// cancellation tokens. We are about to mutate source files from a previous program
|
|
165099
|
-
// instance. If we cancel midway through, we may end up in an inconsistent state where
|
|
165100
|
-
// the program points to old source files that have been invalidated because of
|
|
165101
|
-
// incremental parsing.
|
|
165102
165057
|
// Now create a new compiler
|
|
165103
165058
|
var compilerHost = {
|
|
165104
165059
|
getSourceFile: getOrCreateSourceFile,
|
|
@@ -165110,8 +165065,8 @@ var ts;
|
|
|
165110
165065
|
getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
|
|
165111
165066
|
writeFile: ts.noop,
|
|
165112
165067
|
getCurrentDirectory: function () { return currentDirectory; },
|
|
165113
|
-
fileExists: fileExists,
|
|
165114
|
-
readFile: readFile,
|
|
165068
|
+
fileExists: function (fileName) { return host.fileExists(fileName); },
|
|
165069
|
+
readFile: function (fileName) { return host.readFile && host.readFile(fileName); },
|
|
165115
165070
|
getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
|
|
165116
165071
|
realpath: ts.maybeBind(host, host.realpath),
|
|
165117
165072
|
directoryExists: function (directoryName) {
|
|
@@ -165120,19 +165075,56 @@ var ts;
|
|
|
165120
165075
|
getDirectories: function (path) {
|
|
165121
165076
|
return host.getDirectories ? host.getDirectories(path) : [];
|
|
165122
165077
|
},
|
|
165123
|
-
readDirectory:
|
|
165078
|
+
readDirectory: function (path, extensions, exclude, include, depth) {
|
|
165079
|
+
ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
|
|
165080
|
+
return host.readDirectory(path, extensions, exclude, include, depth);
|
|
165081
|
+
},
|
|
165124
165082
|
onReleaseOldSourceFile: onReleaseOldSourceFile,
|
|
165125
165083
|
onReleaseParsedCommandLine: onReleaseParsedCommandLine,
|
|
165126
165084
|
hasInvalidatedResolution: hasInvalidatedResolution,
|
|
165127
165085
|
hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
|
|
165128
|
-
trace:
|
|
165086
|
+
trace: ts.maybeBind(host, host.trace),
|
|
165129
165087
|
resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
|
|
165130
165088
|
getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
|
|
165131
165089
|
resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
|
|
165132
165090
|
useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
|
|
165133
165091
|
getParsedCommandLine: getParsedCommandLine,
|
|
165134
165092
|
};
|
|
165093
|
+
var originalGetSourceFile = compilerHost.getSourceFile;
|
|
165094
|
+
var getSourceFileWithCache = ts.changeCompilerHostLikeToUseCache(compilerHost, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); }, function () {
|
|
165095
|
+
var args = [];
|
|
165096
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
165097
|
+
args[_i] = arguments[_i];
|
|
165098
|
+
}
|
|
165099
|
+
return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args, false));
|
|
165100
|
+
}).getSourceFileWithCache;
|
|
165101
|
+
compilerHost.getSourceFile = getSourceFileWithCache;
|
|
165135
165102
|
(_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost);
|
|
165103
|
+
var parseConfigHost = {
|
|
165104
|
+
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
|
165105
|
+
fileExists: function (fileName) { return compilerHost.fileExists(fileName); },
|
|
165106
|
+
readFile: function (fileName) { return compilerHost.readFile(fileName); },
|
|
165107
|
+
readDirectory: function () {
|
|
165108
|
+
var _a;
|
|
165109
|
+
var args = [];
|
|
165110
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
165111
|
+
args[_i] = arguments[_i];
|
|
165112
|
+
}
|
|
165113
|
+
return (_a = compilerHost).readDirectory.apply(_a, args);
|
|
165114
|
+
},
|
|
165115
|
+
trace: compilerHost.trace,
|
|
165116
|
+
getCurrentDirectory: compilerHost.getCurrentDirectory,
|
|
165117
|
+
onUnRecoverableConfigFileDiagnostic: ts.noop,
|
|
165118
|
+
};
|
|
165119
|
+
// If the program is already up-to-date, we can reuse it
|
|
165120
|
+
if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
|
|
165121
|
+
return;
|
|
165122
|
+
}
|
|
165123
|
+
// IMPORTANT - It is critical from this moment onward that we do not check
|
|
165124
|
+
// cancellation tokens. We are about to mutate source files from a previous program
|
|
165125
|
+
// instance. If we cancel midway through, we may end up in an inconsistent state where
|
|
165126
|
+
// the program points to old source files that have been invalidated because of
|
|
165127
|
+
// incremental parsing.
|
|
165136
165128
|
var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
|
|
165137
165129
|
var options = {
|
|
165138
165130
|
rootNames: rootFileNames,
|
|
@@ -165142,9 +165134,9 @@ var ts;
|
|
|
165142
165134
|
projectReferences: projectReferences
|
|
165143
165135
|
};
|
|
165144
165136
|
program = ts.createProgram(options);
|
|
165145
|
-
//
|
|
165146
|
-
//
|
|
165147
|
-
|
|
165137
|
+
// 'getOrCreateSourceFile' depends on caching but should be used past this point.
|
|
165138
|
+
// After this point, the cache needs to be cleared to allow all collected snapshots to be released
|
|
165139
|
+
compilerHost = undefined;
|
|
165148
165140
|
parsedCommandLines = undefined;
|
|
165149
165141
|
// We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above,
|
|
165150
165142
|
// Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during
|
|
@@ -165184,26 +165176,6 @@ var ts;
|
|
|
165184
165176
|
onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions);
|
|
165185
165177
|
}
|
|
165186
165178
|
}
|
|
165187
|
-
function fileExists(fileName) {
|
|
165188
|
-
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
165189
|
-
var entry = hostCache && hostCache.getEntryByPath(path);
|
|
165190
|
-
return entry ?
|
|
165191
|
-
!ts.isString(entry) :
|
|
165192
|
-
(!!host.fileExists && host.fileExists(fileName));
|
|
165193
|
-
}
|
|
165194
|
-
function readFile(fileName) {
|
|
165195
|
-
// stub missing host functionality
|
|
165196
|
-
var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
165197
|
-
var entry = hostCache && hostCache.getEntryByPath(path);
|
|
165198
|
-
if (entry) {
|
|
165199
|
-
return ts.isString(entry) ? undefined : ts.getSnapshotText(entry.scriptSnapshot);
|
|
165200
|
-
}
|
|
165201
|
-
return host.readFile && host.readFile(fileName);
|
|
165202
|
-
}
|
|
165203
|
-
function readDirectory(path, extensions, exclude, include, depth) {
|
|
165204
|
-
ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'");
|
|
165205
|
-
return host.readDirectory(path, extensions, exclude, include, depth);
|
|
165206
|
-
}
|
|
165207
165179
|
// Release any files we have acquired in the old program but are
|
|
165208
165180
|
// not part of the new program.
|
|
165209
165181
|
function onReleaseOldSourceFile(oldSourceFile, oldOptions) {
|
|
@@ -165214,14 +165186,16 @@ var ts;
|
|
|
165214
165186
|
return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile);
|
|
165215
165187
|
}
|
|
165216
165188
|
function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) {
|
|
165217
|
-
ts.Debug.assert(
|
|
165189
|
+
ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
|
|
165218
165190
|
// The program is asking for this file, check first if the host can locate it.
|
|
165219
165191
|
// If the host can not locate the file, then it does not exist. return undefined
|
|
165220
165192
|
// to the program to allow reporting of errors for missing files.
|
|
165221
|
-
var
|
|
165222
|
-
if (!
|
|
165193
|
+
var scriptSnapshot = host.getScriptSnapshot(fileName);
|
|
165194
|
+
if (!scriptSnapshot) {
|
|
165223
165195
|
return undefined;
|
|
165224
165196
|
}
|
|
165197
|
+
var scriptKind = ts.getScriptKind(fileName, host);
|
|
165198
|
+
var scriptVersion = host.getScriptVersion(fileName);
|
|
165225
165199
|
// Check if the language version has changed since we last created a program; if they are the same,
|
|
165226
165200
|
// it is safe to reuse the sourceFiles; if not, then the shape of the AST can change, and the oldSourceFile
|
|
165227
165201
|
// can not be reused. we have to dump all syntax trees and create new ones.
|
|
@@ -165253,8 +165227,8 @@ var ts;
|
|
|
165253
165227
|
// We do not support the scenario where a host can modify a registered
|
|
165254
165228
|
// file's script kind, i.e. in one project some file is treated as ".ts"
|
|
165255
165229
|
// and in another as ".js"
|
|
165256
|
-
if (
|
|
165257
|
-
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey,
|
|
165230
|
+
if (scriptKind === oldSourceFile.scriptKind) {
|
|
165231
|
+
return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
165258
165232
|
}
|
|
165259
165233
|
else {
|
|
165260
165234
|
// Release old source file and fall through to aquire new file with new script kind
|
|
@@ -165264,7 +165238,7 @@ var ts;
|
|
|
165264
165238
|
// We didn't already have the file. Fall through and acquire it from the registry.
|
|
165265
165239
|
}
|
|
165266
165240
|
// Could not find this file in the old program, create a new SourceFile for it.
|
|
165267
|
-
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey,
|
|
165241
|
+
return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind);
|
|
165268
165242
|
}
|
|
165269
165243
|
}
|
|
165270
165244
|
// TODO: GH#18217 frequently asserted as defined
|
|
@@ -165280,6 +165254,61 @@ var ts;
|
|
|
165280
165254
|
var _a;
|
|
165281
165255
|
return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
165282
165256
|
}
|
|
165257
|
+
function updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans) {
|
|
165258
|
+
var checker = program.getTypeChecker();
|
|
165259
|
+
var symbol = getSymbolForProgram();
|
|
165260
|
+
if (!symbol)
|
|
165261
|
+
return false;
|
|
165262
|
+
for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
|
|
165263
|
+
var referencedSymbol = referencedSymbols_1[_i];
|
|
165264
|
+
for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
|
|
165265
|
+
var ref = _b[_a];
|
|
165266
|
+
var refNode = getNodeForSpan(ref);
|
|
165267
|
+
ts.Debug.assertIsDefined(refNode);
|
|
165268
|
+
if (knownSymbolSpans.has(ref) || ts.FindAllReferences.isDeclarationOfSymbol(refNode, symbol)) {
|
|
165269
|
+
knownSymbolSpans.add(ref);
|
|
165270
|
+
ref.isDefinition = true;
|
|
165271
|
+
var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
|
|
165272
|
+
if (mappedSpan) {
|
|
165273
|
+
knownSymbolSpans.add(mappedSpan);
|
|
165274
|
+
}
|
|
165275
|
+
}
|
|
165276
|
+
else {
|
|
165277
|
+
ref.isDefinition = false;
|
|
165278
|
+
}
|
|
165279
|
+
}
|
|
165280
|
+
}
|
|
165281
|
+
return true;
|
|
165282
|
+
function getSymbolForProgram() {
|
|
165283
|
+
for (var _i = 0, referencedSymbols_2 = referencedSymbols; _i < referencedSymbols_2.length; _i++) {
|
|
165284
|
+
var referencedSymbol = referencedSymbols_2[_i];
|
|
165285
|
+
for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
|
|
165286
|
+
var ref = _b[_a];
|
|
165287
|
+
if (knownSymbolSpans.has(ref)) {
|
|
165288
|
+
var refNode = getNodeForSpan(ref);
|
|
165289
|
+
ts.Debug.assertIsDefined(refNode);
|
|
165290
|
+
return checker.getSymbolAtLocation(refNode);
|
|
165291
|
+
}
|
|
165292
|
+
var mappedSpan = ts.getMappedDocumentSpan(ref, sourceMapper, ts.maybeBind(host, host.fileExists));
|
|
165293
|
+
if (mappedSpan && knownSymbolSpans.has(mappedSpan)) {
|
|
165294
|
+
var refNode = getNodeForSpan(mappedSpan);
|
|
165295
|
+
if (refNode) {
|
|
165296
|
+
return checker.getSymbolAtLocation(refNode);
|
|
165297
|
+
}
|
|
165298
|
+
}
|
|
165299
|
+
}
|
|
165300
|
+
}
|
|
165301
|
+
return undefined;
|
|
165302
|
+
}
|
|
165303
|
+
function getNodeForSpan(docSpan) {
|
|
165304
|
+
var sourceFile = program.getSourceFile(docSpan.fileName);
|
|
165305
|
+
if (!sourceFile)
|
|
165306
|
+
return undefined;
|
|
165307
|
+
var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start);
|
|
165308
|
+
var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ });
|
|
165309
|
+
return adjustedNode;
|
|
165310
|
+
}
|
|
165311
|
+
}
|
|
165283
165312
|
function cleanupSemanticCache() {
|
|
165284
165313
|
program = undefined; // TODO: GH#18217
|
|
165285
165314
|
}
|
|
@@ -166206,6 +166235,7 @@ var ts;
|
|
|
166206
166235
|
getNonBoundSourceFile: getNonBoundSourceFile,
|
|
166207
166236
|
getProgram: getProgram,
|
|
166208
166237
|
getAutoImportProvider: getAutoImportProvider,
|
|
166238
|
+
updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols,
|
|
166209
166239
|
getApplicableRefactors: getApplicableRefactors,
|
|
166210
166240
|
getEditsForRefactor: getEditsForRefactor,
|
|
166211
166241
|
toLineColumnOffset: toLineColumnOffset,
|