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.
@@ -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.20220518";
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 && originalCreateDirectory) {
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
- host.createDirectory = function (directory) {
116038
- var key = toPath(directory);
116039
- directoryExistsCache.delete(key);
116040
- originalCreateDirectory.call(host, directory);
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: 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: parseConfigHost.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
- // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
165146
- // It needs to be cleared to allow all collected snapshots to be released
165147
- hostCache = undefined;
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(hostCache !== undefined, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host.");
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 hostFileInformation = hostCache && hostCache.getOrCreateEntryByPath(fileName, path);
165222
- if (!hostFileInformation) {
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 (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
165257
- return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
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, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
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,
@@ -174929,66 +174959,142 @@ var ts;
174929
174959
  return textSpan.start + 100003 * textSpan.length;
174930
174960
  }, ts.documentSpansEqual);
174931
174961
  }
174932
- function combineProjectOutputForRenameLocations(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
174962
+ function getRenameLocationsWorker(projects, defaultProject, initialLocation, findInStrings, findInComments, _a) {
174933
174963
  var providePrefixAndSuffixTextForRename = _a.providePrefixAndSuffixTextForRename;
174934
- var outputs = [];
174964
+ var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174965
+ /*isForRename*/ true, function (project, position) { return project.getLanguageService().findRenameLocations(position.fileName, position.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }, function (renameLocation, cb) { return cb(documentSpanLocation(renameLocation)); });
174966
+ // No filtering or dedup'ing is required if there's exactly one project
174967
+ if (ts.isArray(perProjectResults)) {
174968
+ return perProjectResults;
174969
+ }
174970
+ var results = [];
174935
174971
  var seen = createDocumentSpanSet();
174936
- combineProjectOutputWorker(projects, defaultProject, initialLocation,
174937
- /*isForRename*/ true, function (project, location, tryAddToTodo) {
174938
- var projectOutputs = project.getLanguageService().findRenameLocations(location.fileName, location.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename);
174939
- if (projectOutputs) {
174940
- for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
174941
- var output = projectOutputs_1[_i];
174942
- if (!seen.has(output) && !tryAddToTodo(project, documentSpanLocation(output))) {
174943
- seen.add(output);
174944
- outputs.push(output);
174945
- }
174972
+ perProjectResults.forEach(function (projectResults, project) {
174973
+ for (var _i = 0, projectResults_1 = projectResults; _i < projectResults_1.length; _i++) {
174974
+ var result = projectResults_1[_i];
174975
+ // If there's a mapped location, it'll appear in the results for another project
174976
+ if (!seen.has(result) && !getMappedLocationForProject(documentSpanLocation(result), project)) {
174977
+ results.push(result);
174978
+ seen.add(result);
174946
174979
  }
174947
174980
  }
174948
174981
  });
174949
- return outputs;
174982
+ return results;
174950
174983
  }
174951
174984
  function getDefinitionLocation(defaultProject, initialLocation, isForRename) {
174952
- var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, isForRename);
174985
+ var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
174953
174986
  var info = infos && ts.firstOrUndefined(infos);
174954
174987
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
174955
174988
  }
174956
- function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
174957
- var outputs = [];
174958
- combineProjectOutputWorker(projects, defaultProject, initialLocation,
174959
- /*isForRename*/ false, function (project, location, getMappedLocation) {
174960
- var _a, _b;
174961
- logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
174962
- var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
174963
- if (projectOutputs) {
174964
- var clearIsDefinition = ((_b = (_a = projectOutputs[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined;
174965
- var _loop_9 = function (referencedSymbol) {
174966
- var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
174967
- var definition = mappedDefinitionFile === undefined ?
174968
- referencedSymbol.definition : __assign(__assign({}, referencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, referencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(referencedSymbol.definition, project) });
174969
- var symbolToAddTo = ts.find(outputs, function (o) { return ts.documentSpansEqual(o.definition, definition); });
174970
- if (!symbolToAddTo) {
174971
- symbolToAddTo = { definition: definition, references: [] };
174972
- outputs.push(symbolToAddTo);
174973
- }
174974
- for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
174975
- var ref = _d[_c];
174976
- // If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
174977
- if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
174978
- if (clearIsDefinition) {
174979
- delete ref.isDefinition;
174980
- }
174981
- symbolToAddTo.references.push(ref);
174982
- }
174989
+ function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
174990
+ var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
174991
+ /*isForRename*/ false, function (project, position) {
174992
+ logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
174993
+ return project.getLanguageService().findReferences(position.fileName, position.pos);
174994
+ }, function (referencedSymbol, cb) {
174995
+ cb(documentSpanLocation(referencedSymbol.definition));
174996
+ for (var _i = 0, _a = referencedSymbol.references; _i < _a.length; _i++) {
174997
+ var ref = _a[_i];
174998
+ cb(documentSpanLocation(ref));
174999
+ }
175000
+ });
175001
+ // No re-mapping or isDefinition updatses are required if there's exactly one project
175002
+ if (ts.isArray(perProjectResults)) {
175003
+ return perProjectResults;
175004
+ }
175005
+ // `isDefinition` is only (definitely) correct in `defaultProject` because we might
175006
+ // have started the other project searches from related symbols. Propagate the
175007
+ // correct results to all other projects.
175008
+ var defaultProjectResults = perProjectResults.get(defaultProject);
175009
+ if (defaultProjectResults[0].references[0].isDefinition === undefined) {
175010
+ // Clear all isDefinition properties
175011
+ perProjectResults.forEach(function (projectResults) {
175012
+ for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
175013
+ var referencedSymbol = projectResults_2[_i];
175014
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
175015
+ var ref = _b[_a];
175016
+ delete ref.isDefinition;
174983
175017
  }
174984
- };
174985
- for (var _i = 0, projectOutputs_2 = projectOutputs; _i < projectOutputs_2.length; _i++) {
174986
- var referencedSymbol = projectOutputs_2[_i];
174987
- _loop_9(referencedSymbol);
174988
175018
  }
175019
+ });
175020
+ }
175021
+ else {
175022
+ // Correct isDefinition properties from projects other than defaultProject
175023
+ var knownSymbolSpans_1 = createDocumentSpanSet();
175024
+ for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
175025
+ var referencedSymbol = defaultProjectResults_1[_i];
175026
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
175027
+ var ref = _b[_a];
175028
+ if (ref.isDefinition) {
175029
+ knownSymbolSpans_1.add(ref);
175030
+ // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
175031
+ break;
175032
+ }
175033
+ }
175034
+ }
175035
+ var updatedProjects_1 = new ts.Set();
175036
+ var _loop_9 = function () {
175037
+ var progress = false;
175038
+ perProjectResults.forEach(function (referencedSymbols, project) {
175039
+ if (updatedProjects_1.has(project))
175040
+ return;
175041
+ var updated = project.getLanguageService().updateIsDefinitionOfReferencedSymbols(referencedSymbols, knownSymbolSpans_1);
175042
+ if (updated) {
175043
+ updatedProjects_1.add(project);
175044
+ progress = true;
175045
+ }
175046
+ });
175047
+ if (!progress)
175048
+ return "break";
175049
+ };
175050
+ while (true) {
175051
+ var state_2 = _loop_9();
175052
+ if (state_2 === "break")
175053
+ break;
175054
+ }
175055
+ perProjectResults.forEach(function (referencedSymbols, project) {
175056
+ if (updatedProjects_1.has(project))
175057
+ return;
175058
+ for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) {
175059
+ var referencedSymbol = referencedSymbols_1[_i];
175060
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
175061
+ var ref = _b[_a];
175062
+ ref.isDefinition = false;
175063
+ }
175064
+ }
175065
+ });
175066
+ }
175067
+ // We need to de-duplicate and aggregate the results by choosing an authoritative version
175068
+ // of each definition and merging references from all the projects where they appear.
175069
+ var results = [];
175070
+ var seenRefs = createDocumentSpanSet(); // It doesn't make sense to have a reference in two definition lists, so we de-dup globally
175071
+ // TODO: We might end up with a more logical allocation of refs to defs if we pre-sorted the defs by descending ref-count.
175072
+ // Otherwise, it just ends up attached to the first corresponding def we happen to process. The others may or may not be
175073
+ // dropped later when we check for defs with ref-count 0.
175074
+ perProjectResults.forEach(function (projectResults, project) {
175075
+ var _loop_10 = function (referencedSymbol) {
175076
+ var mappedDefinitionFile = getMappedLocationForProject(documentSpanLocation(referencedSymbol.definition), project);
175077
+ var definition = mappedDefinitionFile === undefined ?
175078
+ referencedSymbol.definition : __assign(__assign({}, referencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, referencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpanForProject(referencedSymbol.definition, project) });
175079
+ var symbolToAddTo = ts.find(results, function (o) { return ts.documentSpansEqual(o.definition, definition); });
175080
+ if (!symbolToAddTo) {
175081
+ symbolToAddTo = { definition: definition, references: [] };
175082
+ results.push(symbolToAddTo);
175083
+ }
175084
+ for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) {
175085
+ var ref = _b[_a];
175086
+ if (!seenRefs.has(ref) && !getMappedLocationForProject(documentSpanLocation(ref), project)) {
175087
+ seenRefs.add(ref);
175088
+ symbolToAddTo.references.push(ref);
175089
+ }
175090
+ }
175091
+ };
175092
+ for (var _i = 0, projectResults_3 = projectResults; _i < projectResults_3.length; _i++) {
175093
+ var referencedSymbol = projectResults_3[_i];
175094
+ _loop_10(referencedSymbol);
174989
175095
  }
174990
175096
  });
174991
- return outputs.filter(function (o) { return o.references.length !== 0; });
175097
+ return results.filter(function (o) { return o.references.length !== 0; });
174992
175098
  }
174993
175099
  function forEachProjectInProjects(projects, path, cb) {
174994
175100
  for (var _i = 0, _a = ts.isArray(projects) ? projects : projects.projects; _i < _a.length; _i++) {
@@ -175004,40 +175110,117 @@ var ts;
175004
175110
  });
175005
175111
  }
175006
175112
  }
175007
- function combineProjectOutputWorker(projects, defaultProject, initialLocation, isForRename, cb) {
175008
- var projectService = defaultProject.projectService;
175009
- var toDo;
175010
- var seenProjects = new ts.Set();
175011
- forEachProjectInProjects(projects, initialLocation && initialLocation.fileName, function (project, path) {
175012
- // TLocation should be either `DocumentPosition` or `undefined`. Since `initialLocation` is `TLocation` this cast should be valid.
175013
- var location = (initialLocation ? { fileName: path, pos: initialLocation.pos } : undefined);
175014
- toDo = callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb);
175113
+ /**
175114
+ * @param projects Projects initially known to contain {@link initialLocation}
175115
+ * @param defaultProject The default project containing {@link initialLocation}
175116
+ * @param initialLocation Where the search operation was triggered
175117
+ * @param getResultsForPosition This is where you plug in `findReferences`, `renameLocation`, etc
175118
+ * @param forPositionInResult Given an item returned by {@link getResultsForPosition} enumerate the positions referred to by that result
175119
+ * @returns In the common case where there's only one project, returns an array of results from {@link getResultsForPosition}.
175120
+ * If multiple projects were searched - even if they didn't return results - the result will be a map from project to per-project results.
175121
+ */
175122
+ function getPerProjectReferences(projects, defaultProject, initialLocation, isForRename, getResultsForPosition, forPositionInResult) {
175123
+ // If `getResultsForPosition` returns results for a project, they go in here
175124
+ var resultsMap = new ts.Map();
175125
+ var queue = [];
175126
+ // In order to get accurate isDefinition values for `defaultProject`,
175127
+ // we need to ensure that it is searched from `initialLocation`.
175128
+ // The easiest way to do this is to search it first.
175129
+ queue.push({ project: defaultProject, location: initialLocation });
175130
+ // This will queue `defaultProject` a second time, but it will be dropped
175131
+ // as a dup when it is dequeued.
175132
+ forEachProjectInProjects(projects, initialLocation.fileName, function (project, path) {
175133
+ var location = { fileName: path, pos: initialLocation.pos };
175134
+ queue.push({ project: project, location: location });
175015
175135
  });
175016
- // After initial references are collected, go over every other project and see if it has a reference for the symbol definition.
175017
- if (initialLocation) {
175018
- var defaultDefinition_1 = getDefinitionLocation(defaultProject, initialLocation, isForRename);
175019
- if (defaultDefinition_1) {
175020
- var getGeneratedDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ?
175021
- defaultDefinition_1 :
175022
- defaultProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(defaultDefinition_1); });
175023
- var getSourceDefinition_1 = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition_1.fileName) ?
175024
- defaultDefinition_1 :
175025
- defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition_1); });
175026
- projectService.loadAncestorProjectTree(seenProjects);
175136
+ var projectService = defaultProject.projectService;
175137
+ var cancellationToken = defaultProject.getCancellationToken();
175138
+ var defaultDefinition = getDefinitionLocation(defaultProject, initialLocation, isForRename);
175139
+ // Don't call these unless !!defaultDefinition
175140
+ var getGeneratedDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
175141
+ defaultDefinition :
175142
+ defaultProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(defaultDefinition); });
175143
+ var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
175144
+ defaultDefinition :
175145
+ defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
175146
+ // Track which projects we have already searched so that we don't repeat searches.
175147
+ // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
175148
+ // (For that same reason, we don't use `resultsMap` for this check.)
175149
+ var searchedProjects = new ts.Set();
175150
+ onCancellation: while (queue.length) {
175151
+ while (queue.length) {
175152
+ if (cancellationToken.isCancellationRequested())
175153
+ break onCancellation;
175154
+ var _a = queue.shift(), project = _a.project, location = _a.location;
175155
+ if (isLocationProjectReferenceRedirect(project, location))
175156
+ continue;
175157
+ if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
175158
+ continue;
175159
+ var projectResults = searchPosition(project, location);
175160
+ if (projectResults) {
175161
+ resultsMap.set(project, projectResults);
175162
+ }
175163
+ }
175164
+ // At this point, we know about all projects passed in as arguments and any projects in which
175165
+ // `getResultsForPosition` has returned results. We expand that set to include any projects
175166
+ // downstream from any of these and then queue new initial-position searches for any new project
175167
+ // containing `initialLocation`.
175168
+ if (defaultDefinition) {
175169
+ // This seems to mean "load all projects downstream from any member of `seenProjects`".
175170
+ projectService.loadAncestorProjectTree(searchedProjects);
175027
175171
  projectService.forEachEnabledProject(function (project) {
175028
- if (!addToSeen(seenProjects, project))
175029
- return;
175030
- var definition = mapDefinitionInProject(defaultDefinition_1, project, getGeneratedDefinition_1, getSourceDefinition_1);
175031
- if (definition) {
175032
- toDo = callbackProjectAndLocation(project, definition, projectService, toDo, seenProjects, cb);
175172
+ if (cancellationToken.isCancellationRequested())
175173
+ return; // There's no mechanism for skipping the remaining projects
175174
+ if (searchedProjects.has(getProjectKey(project)))
175175
+ return; // Can loop forever without this (enqueue here, dequeue above, repeat)
175176
+ var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
175177
+ if (location) {
175178
+ queue.push({ project: project, location: location });
175033
175179
  }
175034
175180
  });
175035
175181
  }
175036
175182
  }
175037
- while (toDo && toDo.length) {
175038
- var next = toDo.pop();
175039
- ts.Debug.assertIsDefined(next);
175040
- toDo = callbackProjectAndLocation(next.project, next.location, projectService, toDo, seenProjects, cb);
175183
+ // In the common case where there's only one project, return a simpler result to make
175184
+ // it easier for the caller to skip post-processing.
175185
+ if (searchedProjects.size === 1) {
175186
+ var it = resultsMap.values().next();
175187
+ ts.Debug.assert(!it.done);
175188
+ return it.value;
175189
+ }
175190
+ return resultsMap;
175191
+ // May enqueue to otherPositionQueue
175192
+ function searchPosition(project, location) {
175193
+ var projectResults = getResultsForPosition(project, location);
175194
+ if (!projectResults)
175195
+ return undefined;
175196
+ for (var _i = 0, projectResults_4 = projectResults; _i < projectResults_4.length; _i++) {
175197
+ var result = projectResults_4[_i];
175198
+ forPositionInResult(result, function (position) {
175199
+ // This may trigger a search for a tsconfig, but there are several layers of caching that make it inexpensive
175200
+ var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, position);
175201
+ if (!originalLocation)
175202
+ return;
175203
+ var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
175204
+ for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
175205
+ var project_1 = _a[_i];
175206
+ if (!project_1.isOrphan()) {
175207
+ queue.push({ project: project_1, location: originalLocation });
175208
+ }
175209
+ }
175210
+ var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo);
175211
+ if (symlinkedProjectsMap) {
175212
+ symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
175213
+ for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
175214
+ var symlinkedProject = symlinkedProjects_2[_i];
175215
+ if (!symlinkedProject.isOrphan()) {
175216
+ queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
175217
+ }
175218
+ }
175219
+ });
175220
+ }
175221
+ });
175222
+ }
175223
+ return projectResults;
175041
175224
  }
175042
175225
  }
175043
175226
  function mapDefinitionInProject(definition, project, getGeneratedDefinition, getSourceDefinition) {
@@ -175068,43 +175251,6 @@ var ts;
175068
175251
  sourceFile.resolvedPath !== sourceFile.path &&
175069
175252
  sourceFile.resolvedPath !== project.toPath(location.fileName);
175070
175253
  }
175071
- function callbackProjectAndLocation(project, location, projectService, toDo, seenProjects, cb) {
175072
- if (project.getCancellationToken().isCancellationRequested())
175073
- return undefined; // Skip rest of toDo if cancelled
175074
- // If this is not the file we were actually looking, return rest of the toDo
175075
- if (isLocationProjectReferenceRedirect(project, location))
175076
- return toDo;
175077
- cb(project, location, function (innerProject, location) {
175078
- addToSeen(seenProjects, project);
175079
- var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(innerProject, location);
175080
- if (!originalLocation)
175081
- return undefined;
175082
- var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
175083
- toDo = toDo || [];
175084
- for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
175085
- var project_1 = _a[_i];
175086
- addToTodo(project_1, originalLocation, toDo, seenProjects);
175087
- }
175088
- var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo);
175089
- if (symlinkedProjectsMap) {
175090
- symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
175091
- for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
175092
- var symlinkedProject = symlinkedProjects_2[_i];
175093
- addToTodo(symlinkedProject, { fileName: symlinkedPath, pos: originalLocation.pos }, toDo, seenProjects);
175094
- }
175095
- });
175096
- }
175097
- return originalLocation === location ? undefined : originalLocation;
175098
- });
175099
- return toDo;
175100
- }
175101
- function addToTodo(project, location, toDo, seenProjects) {
175102
- if (!project.isOrphan() && addToSeen(seenProjects, project))
175103
- toDo.push({ project: project, location: location });
175104
- }
175105
- function addToSeen(seenProjects, project) {
175106
- return ts.tryAddToSet(seenProjects, getProjectKey(project));
175107
- }
175108
175254
  function getProjectKey(project) {
175109
175255
  return server.isConfiguredProject(project) ? project.canonicalConfigFilePath : project.getProjectName();
175110
175256
  }
@@ -175112,32 +175258,14 @@ var ts;
175112
175258
  var fileName = _a.fileName, textSpan = _a.textSpan;
175113
175259
  return { fileName: fileName, pos: textSpan.start };
175114
175260
  }
175115
- function getMappedLocation(location, project) {
175116
- var mapsTo = project.getSourceMapper().tryGetSourcePosition(location);
175117
- return mapsTo && project.projectService.fileExists(server.toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined;
175261
+ function getMappedLocationForProject(location, project) {
175262
+ return ts.getMappedLocation(location, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
175118
175263
  }
175119
- function getMappedDocumentSpan(documentSpan, project) {
175120
- var newPosition = getMappedLocation(documentSpanLocation(documentSpan), project);
175121
- if (!newPosition)
175122
- return undefined;
175123
- return {
175124
- fileName: newPosition.fileName,
175125
- textSpan: {
175126
- start: newPosition.pos,
175127
- length: documentSpan.textSpan.length
175128
- },
175129
- originalFileName: documentSpan.fileName,
175130
- originalTextSpan: documentSpan.textSpan,
175131
- contextSpan: getMappedContextSpan(documentSpan, project),
175132
- originalContextSpan: documentSpan.contextSpan
175133
- };
175264
+ function getMappedDocumentSpanForProject(documentSpan, project) {
175265
+ return ts.getMappedDocumentSpan(documentSpan, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
175134
175266
  }
175135
- function getMappedContextSpan(documentSpan, project) {
175136
- var contextSpanStart = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, project);
175137
- var contextSpanEnd = documentSpan.contextSpan && getMappedLocation({ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, project);
175138
- return contextSpanStart && contextSpanEnd ?
175139
- { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
175140
- undefined;
175267
+ function getMappedContextSpanForProject(documentSpan, project) {
175268
+ return ts.getMappedContextSpan(documentSpan, project.getSourceMapper(), function (p) { return project.projectService.fileExists(p); });
175141
175269
  }
175142
175270
  var invalidPartialSemanticModeCommands = [
175143
175271
  server.CommandNames.OpenExternalProject,
@@ -176030,7 +176158,7 @@ var ts;
176030
176158
  };
176031
176159
  Session.prototype.mapDefinitionInfoLocations = function (definitions, project) {
176032
176160
  return definitions.map(function (info) {
176033
- var newDocumentSpan = getMappedDocumentSpan(info, project);
176161
+ var newDocumentSpan = getMappedDocumentSpanForProject(info, project);
176034
176162
  return !newDocumentSpan ? info : __assign(__assign(__assign({}, newDocumentSpan), { containerKind: info.containerKind, containerName: info.containerName, kind: info.kind, name: info.name, failedAliasResolution: info.failedAliasResolution }), info.unverified && { unverified: info.unverified });
176035
176163
  });
176036
176164
  };
@@ -176275,7 +176403,7 @@ var ts;
176275
176403
  };
176276
176404
  Session.prototype.mapImplementationLocations = function (implementations, project) {
176277
176405
  return implementations.map(function (info) {
176278
- var newDocumentSpan = getMappedDocumentSpan(info, project);
176406
+ var newDocumentSpan = getMappedDocumentSpanForProject(info, project);
176279
176407
  return !newDocumentSpan ? info : __assign(__assign({}, newDocumentSpan), { kind: info.kind, displayParts: info.displayParts });
176280
176408
  });
176281
176409
  };
@@ -176432,7 +176560,7 @@ var ts;
176432
176560
  var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
176433
176561
  if (!renameInfo.canRename)
176434
176562
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
176435
- var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
176563
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
176436
176564
  if (!simplifiedResult)
176437
176565
  return locations;
176438
176566
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
@@ -176464,7 +176592,7 @@ var ts;
176464
176592
  var file = server.toNormalizedPath(args.file);
176465
176593
  var projects = this.getProjects(args);
176466
176594
  var position = this.getPositionInFile(args, file);
176467
- var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
176595
+ var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
176468
176596
  if (!simplifiedResult)
176469
176597
  return references;
176470
176598
  var defaultProject = this.getDefaultProject(args);
@@ -176490,8 +176618,8 @@ var ts;
176490
176618
  return;
176491
176619
  var projectOutputs = project.getLanguageService().getFileReferences(fileName);
176492
176620
  if (projectOutputs) {
176493
- for (var _i = 0, projectOutputs_3 = projectOutputs; _i < projectOutputs_3.length; _i++) {
176494
- var referenceEntry = projectOutputs_3[_i];
176621
+ for (var _i = 0, projectOutputs_1 = projectOutputs; _i < projectOutputs_1.length; _i++) {
176622
+ var referenceEntry = projectOutputs_1[_i];
176495
176623
  if (!seen.has(referenceEntry)) {
176496
176624
  references.push(referenceEntry);
176497
176625
  seen.add(referenceEntry);
@@ -176956,7 +177084,8 @@ var ts;
176956
177084
  // `name` is a very cheap hash function, but we could incorporate other properties to reduce collisions.
176957
177085
  var seenItems = new ts.Map(); // name to items with that name
176958
177086
  if (!args.file && !projectFileName) {
176959
- // VS Code's `Go to symbol in workspaces` sends request like this
177087
+ // VS Code's `Go to symbol in workspaces` sends request like this by default.
177088
+ // There's a setting to have it send a file name (reverting to older behavior).
176960
177089
  // TODO (https://github.com/microsoft/TypeScript/issues/47839)
176961
177090
  // This appears to have been intended to search all projects but, in practice, it seems to only search
176962
177091
  // those that are downstream from already-loaded projects.
@@ -176977,7 +177106,7 @@ var ts;
176977
177106
  // Mutates `outputs`
176978
177107
  function addItemsForProject(project) {
176979
177108
  var projectItems = project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*filename*/ undefined, /*excludeDts*/ project.isNonTsProject());
176980
- var unseenItems = ts.filter(projectItems, function (item) { return tryAddSeenItem(item) && !getMappedLocation(documentSpanLocation(item), project); });
177109
+ var unseenItems = ts.filter(projectItems, function (item) { return tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project); });
176981
177110
  if (unseenItems.length) {
176982
177111
  outputs.push({ project: project, navigateToItems: unseenItems });
176983
177112
  }