Skip to content

Commit

Permalink
Manually merge microsoft#48758
Browse files Browse the repository at this point in the history
  • Loading branch information
amcasey committed May 17, 2022
1 parent 780a84e commit d47ae8a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ namespace ts.server {
projects,
defaultProject,
initialLocation,
/*isForRename*/ true,
(project, position) => project.getLanguageService().findRenameLocations(position.fileName, position.pos, findInStrings, findInComments, providePrefixAndSuffixTextForRename),
(renameLocation, cb) => cb(documentSpanLocation(renameLocation)),
);
Expand All @@ -340,8 +341,8 @@ namespace ts.server {
return results;
}

function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition): DocumentPosition | undefined {
const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos);
function getDefinitionLocation(defaultProject: Project, initialLocation: DocumentPosition, isForRename: boolean): DocumentPosition | undefined {
const infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename);
const info = infos && firstOrUndefined(infos);
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
}
Expand All @@ -356,6 +357,7 @@ namespace ts.server {
projects,
defaultProject,
initialLocation,
/*isForRename*/ false,
(project, position) => {
logger.info(`Finding references to ${position.fileName} position ${position.pos} in project ${project.getProjectName()}`);
return project.getLanguageService().findReferences(position.fileName, position.pos);
Expand Down Expand Up @@ -495,6 +497,7 @@ namespace ts.server {
projects: Projects,
defaultProject: Project,
initialLocation: DocumentPosition,
isForRename: boolean,
getResultsForPosition: (project: Project, location: DocumentPosition) => readonly TResult[] | undefined,
forPositionInResult: (result: TResult, cb: (location: DocumentPosition) => void) => void,
): readonly TResult[] | ESMap<Project, readonly TResult[]> {
Expand All @@ -518,7 +521,7 @@ namespace ts.server {
const projectService = defaultProject.projectService;
const cancellationToken = defaultProject.getCancellationToken();

const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation);
const defaultDefinition = getDefinitionLocation(defaultProject, initialLocation, isForRename);

// Don't call these unless !!defaultDefinition
const getGeneratedDefinition = memoize(() => defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition!.fileName) ?
Expand Down

0 comments on commit d47ae8a

Please sign in to comment.