remove extra deduplicate
This commit is contained in:
parent
db6f5bd832
commit
19596deb7f
2 changed files with 10 additions and 6 deletions
|
@ -464,7 +464,10 @@ namespace ts.server {
|
|||
return copiedList;
|
||||
}
|
||||
|
||||
export function processEachProjectThenConcatSortDeduplicateResults<T>(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean) {
|
||||
/**
|
||||
* This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
export function combineProjectOutput<T>(projects: Project[], action: (project: Project) => T[], comparer?: (a: T, b: T) => number, areEqual?: (a: T, b: T) => boolean) {
|
||||
const result = projects.reduce<T[]>((previous, current) => concatenate(previous, action(current)), []).sort(comparer);
|
||||
return projects.length > 1 ? deduplicate(result, areEqual) : result;
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace ts.server {
|
|||
};
|
||||
}
|
||||
|
||||
const fileSpans = processEachProjectThenConcatSortDeduplicateResults(
|
||||
const fileSpans = combineProjectOutput(
|
||||
projects,
|
||||
(project: Project) => {
|
||||
const compilerService = project.compilerService;
|
||||
|
@ -511,7 +511,7 @@ namespace ts.server {
|
|||
const nameSpan = nameInfo.textSpan;
|
||||
const nameColStart = defaultProject.compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
|
||||
const nameText = defaultProject.compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
const refs = processEachProjectThenConcatSortDeduplicateResults<protocol.ReferencesResponseItem>(
|
||||
const refs = combineProjectOutput<protocol.ReferencesResponseItem>(
|
||||
projects,
|
||||
(project: Project) => {
|
||||
const compilerService = project.compilerService;
|
||||
|
@ -534,11 +534,12 @@ namespace ts.server {
|
|||
};
|
||||
});
|
||||
},
|
||||
compareFileStart
|
||||
compareFileStart,
|
||||
areReferencesResponseItemsForTheSameLocation
|
||||
);
|
||||
|
||||
return {
|
||||
refs: deduplicate(refs, areReferencesResponseItemsForTheSameLocation),
|
||||
refs,
|
||||
symbolName: nameText,
|
||||
symbolStartOffset: nameColStart,
|
||||
symbolDisplayString: displayString
|
||||
|
@ -872,7 +873,7 @@ namespace ts.server {
|
|||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
const allNavToItems = processEachProjectThenConcatSortDeduplicateResults(
|
||||
const allNavToItems = combineProjectOutput(
|
||||
projects,
|
||||
(project: Project) => {
|
||||
const compilerService = project.compilerService;
|
||||
|
|
Loading…
Reference in a new issue