mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
Add support for Call Hierarchies in language server (#35176)
* Add support for Call Hierarchies in language server * Use baselines for callHierarchy tests * Clean up commented code * Support multiple hierarchy items when an implementation can't be found * Use optional chaining in a few places * Use getFileAndProject
This commit is contained in:
@@ -630,10 +630,18 @@ namespace ts {
|
||||
return [...array1, ...array2];
|
||||
}
|
||||
|
||||
function selectIndex(_: unknown, i: number) {
|
||||
return i;
|
||||
}
|
||||
|
||||
export function indicesOf(array: readonly unknown[]): number[] {
|
||||
return array.map(selectIndex);
|
||||
}
|
||||
|
||||
function deduplicateRelational<T>(array: readonly T[], equalityComparer: EqualityComparer<T>, comparer: Comparer<T>) {
|
||||
// Perform a stable sort of the array. This ensures the first entry in a list of
|
||||
// duplicates remains the first entry in the result.
|
||||
const indices = array.map((_, i) => i);
|
||||
const indices = indicesOf(array);
|
||||
stableSortIndices(array, indices, comparer);
|
||||
|
||||
let last = array[indices[0]];
|
||||
@@ -939,7 +947,7 @@ namespace ts {
|
||||
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
|
||||
*/
|
||||
export function stableSort<T>(array: readonly T[], comparer: Comparer<T>): SortedReadonlyArray<T> {
|
||||
const indices = array.map((_, i) => i);
|
||||
const indices = indicesOf(array);
|
||||
stableSortIndices(array, indices, comparer);
|
||||
return indices.map(i => array[i]) as SortedArray<T> as SortedReadonlyArray<T>;
|
||||
}
|
||||
@@ -1245,8 +1253,10 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string): readonly (readonly T[])[] {
|
||||
return arrayFrom(arrayToMultiMap(values, getGroupId).values());
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string): readonly (readonly T[])[];
|
||||
export function group<T, R>(values: readonly T[], getGroupId: (value: T) => string, resultSelector: (values: readonly T[]) => R): R[];
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string, resultSelector: (values: readonly T[]) => readonly T[] = identity): readonly (readonly T[])[] {
|
||||
return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
|
||||
}
|
||||
|
||||
export function clone<T>(object: T): T {
|
||||
|
||||
Reference in New Issue
Block a user