forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallHierarchy.ts
More file actions
553 lines (509 loc) · 27 KB
/
callHierarchy.ts
File metadata and controls
553 lines (509 loc) · 27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
/* @internal */
namespace ts.CallHierarchy {
export type NamedExpression =
| ClassExpression & { name: Identifier }
| FunctionExpression & { name: Identifier }
;
/** Indictates whether a node is named function or class expression. */
function isNamedExpression(node: Node): node is NamedExpression {
return (isFunctionExpression(node) || isClassExpression(node)) && isNamedDeclaration(node);
}
export type ConstNamedExpression =
| ClassExpression & { name: undefined, parent: VariableDeclaration & { name: Identifier } }
| FunctionExpression & { name: undefined, parent: VariableDeclaration & { name: Identifier } }
| ArrowFunction & { name: undefined, parent: VariableDeclaration & { name: Identifier } }
;
/** Indicates whether a node is a function, arrow, or class expression assigned to a constant variable. */
function isConstNamedExpression(node: Node): node is ConstNamedExpression {
return (isFunctionExpression(node) || isArrowFunction(node) || isClassExpression(node))
&& isVariableDeclaration(node.parent)
&& node === node.parent.initializer
&& isIdentifier(node.parent.name)
&& !!(getCombinedNodeFlags(node.parent) & NodeFlags.Const);
}
export type CallHierarchyDeclaration =
| SourceFile
| ModuleDeclaration & { name: Identifier }
| FunctionDeclaration
| ClassDeclaration
| ClassStaticBlockDeclaration
| MethodDeclaration
| GetAccessorDeclaration
| SetAccessorDeclaration
| NamedExpression
| ConstNamedExpression
;
/**
* Indicates whether a node could possibly be a call hierarchy declaration.
*
* See `resolveCallHierarchyDeclaration` for the specific rules.
*/
function isPossibleCallHierarchyDeclaration(node: Node) {
return isSourceFile(node)
|| isModuleDeclaration(node)
|| isFunctionDeclaration(node)
|| isFunctionExpression(node)
|| isClassDeclaration(node)
|| isClassExpression(node)
|| isClassStaticBlockDeclaration(node)
|| isMethodDeclaration(node)
|| isMethodSignature(node)
|| isGetAccessorDeclaration(node)
|| isSetAccessorDeclaration(node);
}
/**
* Indicates whether a node is a valid a call hierarchy declaration.
*
* See `resolveCallHierarchyDeclaration` for the specific rules.
*/
function isValidCallHierarchyDeclaration(node: Node): node is CallHierarchyDeclaration {
return isSourceFile(node)
|| isModuleDeclaration(node) && isIdentifier(node.name)
|| isFunctionDeclaration(node)
|| isClassDeclaration(node)
|| isClassStaticBlockDeclaration(node)
|| isMethodDeclaration(node)
|| isMethodSignature(node)
|| isGetAccessorDeclaration(node)
|| isSetAccessorDeclaration(node)
|| isNamedExpression(node)
|| isConstNamedExpression(node);
}
/** Gets the node that can be used as a reference to a call hierarchy declaration. */
function getCallHierarchyDeclarationReferenceNode(node: CallHierarchyDeclaration) {
if (isSourceFile(node)) return node;
if (isNamedDeclaration(node)) return node.name;
if (isConstNamedExpression(node)) return node.parent.name;
return Debug.checkDefined(node.modifiers && find(node.modifiers, isDefaultModifier));
}
function isDefaultModifier(node: Node) {
return node.kind === SyntaxKind.DefaultKeyword;
}
/** Gets the symbol for a call hierarchy declaration. */
function getSymbolOfCallHierarchyDeclaration(typeChecker: TypeChecker, node: CallHierarchyDeclaration) {
const location = getCallHierarchyDeclarationReferenceNode(node);
return location && typeChecker.getSymbolAtLocation(location);
}
/** Gets the text and range for the name of a call hierarchy declaration. */
function getCallHierarchyItemName(program: Program, node: CallHierarchyDeclaration): { text: string, pos: number, end: number } {
if (isSourceFile(node)) {
return { text: node.fileName, pos: 0, end: 0 };
}
if ((isFunctionDeclaration(node) || isClassDeclaration(node)) && !isNamedDeclaration(node)) {
const defaultModifier = node.modifiers && find(node.modifiers, isDefaultModifier);
if (defaultModifier) {
return { text: "default", pos: defaultModifier.getStart(), end: defaultModifier.getEnd() };
}
}
if (isClassStaticBlockDeclaration(node)) {
const sourceFile = node.getSourceFile();
const pos = skipTrivia(sourceFile.text, moveRangePastModifiers(node).pos);
const end = pos + 6; /* "static".length */
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(node.parent);
const prefix = symbol ? `${typeChecker.symbolToString(symbol, node.parent)} ` : "";
return { text: `${prefix}static {}`, pos, end };
}
const declName = isConstNamedExpression(node) ? node.parent.name :
Debug.checkDefined(getNameOfDeclaration(node), "Expected call hierarchy item to have a name");
let text =
isIdentifier(declName) ? idText(declName) :
isStringOrNumericLiteralLike(declName) ? declName.text :
isComputedPropertyName(declName) ?
isStringOrNumericLiteralLike(declName.expression) ? declName.expression.text :
undefined :
undefined;
if (text === undefined) {
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(declName);
if (symbol) {
text = typeChecker.symbolToString(symbol, node);
}
}
if (text === undefined) {
// get the text from printing the node on a single line without comments...
const printer = createPrinter({ removeComments: true, omitTrailingSemicolon: true });
text = usingSingleLineStringWriter(writer => printer.writeNode(EmitHint.Unspecified, node, node.getSourceFile(), writer));
}
return { text, pos: declName.getStart(), end: declName.getEnd() };
}
function getCallHierarchItemContainerName(node: CallHierarchyDeclaration): string | undefined {
if (isConstNamedExpression(node)) {
if (isModuleBlock(node.parent.parent.parent.parent) && isIdentifier(node.parent.parent.parent.parent.parent.name)) {
return node.parent.parent.parent.parent.parent.name.getText();
}
return;
}
switch (node.kind) {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MethodDeclaration:
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression) {
return getAssignedName(node.parent)?.getText();
}
return getNameOfDeclaration(node.parent)?.getText();
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ModuleDeclaration:
if (isModuleBlock(node.parent) && isIdentifier(node.parent.parent.name)) {
return node.parent.parent.name.getText();
}
}
}
/** Finds the implementation of a function-like declaration, if one exists. */
function findImplementation(typeChecker: TypeChecker, node: Extract<CallHierarchyDeclaration, FunctionLikeDeclaration>): Extract<CallHierarchyDeclaration, FunctionLikeDeclaration> | undefined;
function findImplementation(typeChecker: TypeChecker, node: FunctionLikeDeclaration): FunctionLikeDeclaration | undefined;
function findImplementation(typeChecker: TypeChecker, node: FunctionLikeDeclaration): FunctionLikeDeclaration | undefined {
if (node.body) {
return node;
}
if (isConstructorDeclaration(node)) {
return getFirstConstructorWithBody(node.parent);
}
if (isFunctionDeclaration(node) || isMethodDeclaration(node)) {
const symbol = getSymbolOfCallHierarchyDeclaration(typeChecker, node);
if (symbol && symbol.valueDeclaration && isFunctionLikeDeclaration(symbol.valueDeclaration) && symbol.valueDeclaration.body) {
return symbol.valueDeclaration;
}
return undefined;
}
return node;
}
function findAllInitialDeclarations(typeChecker: TypeChecker, node: CallHierarchyDeclaration) {
const symbol = getSymbolOfCallHierarchyDeclaration(typeChecker, node);
let declarations: CallHierarchyDeclaration[] | undefined;
if (symbol && symbol.declarations) {
const indices = indicesOf(symbol.declarations);
const keys = map(symbol.declarations, decl => ({ file: decl.getSourceFile().fileName, pos: decl.pos }));
indices.sort((a, b) => compareStringsCaseSensitive(keys[a].file, keys[b].file) || keys[a].pos - keys[b].pos);
const sortedDeclarations = map(indices, i => symbol.declarations![i]);
let lastDecl: CallHierarchyDeclaration | undefined;
for (const decl of sortedDeclarations) {
if (isValidCallHierarchyDeclaration(decl)) {
if (!lastDecl || lastDecl.parent !== decl.parent || lastDecl.end !== decl.pos) {
declarations = append(declarations, decl);
}
lastDecl = decl;
}
}
}
return declarations;
}
/** Find the implementation or the first declaration for a call hierarchy declaration. */
function findImplementationOrAllInitialDeclarations(typeChecker: TypeChecker, node: CallHierarchyDeclaration): CallHierarchyDeclaration | CallHierarchyDeclaration[] {
if (isClassStaticBlockDeclaration(node)) {
return node;
}
if (isFunctionLikeDeclaration(node)) {
return findImplementation(typeChecker, node) ??
findAllInitialDeclarations(typeChecker, node) ??
node;
}
return findAllInitialDeclarations(typeChecker, node) ?? node;
}
/** Resolves the call hierarchy declaration for a node. */
export function resolveCallHierarchyDeclaration(program: Program, location: Node): CallHierarchyDeclaration | CallHierarchyDeclaration[] | undefined {
// A call hierarchy item must refer to either a SourceFile, Module Declaration, Class Static Block, or something intrinsically callable that has a name:
// - Class Declarations
// - Class Expressions (with a name)
// - Function Declarations
// - Function Expressions (with a name or assigned to a const variable)
// - Arrow Functions (assigned to a const variable)
// - Constructors
// - Class `static {}` initializer blocks
// - Methods
// - Accessors
//
// If a call is contained in a non-named callable Node (function expression, arrow function, etc.), then
// its containing `CallHierarchyItem` is a containing function or SourceFile that matches the above list.
const typeChecker = program.getTypeChecker();
let followingSymbol = false;
while (true) {
if (isValidCallHierarchyDeclaration(location)) {
return findImplementationOrAllInitialDeclarations(typeChecker, location);
}
if (isPossibleCallHierarchyDeclaration(location)) {
const ancestor = findAncestor(location, isValidCallHierarchyDeclaration);
return ancestor && findImplementationOrAllInitialDeclarations(typeChecker, ancestor);
}
if (isDeclarationName(location)) {
if (isValidCallHierarchyDeclaration(location.parent)) {
return findImplementationOrAllInitialDeclarations(typeChecker, location.parent);
}
if (isPossibleCallHierarchyDeclaration(location.parent)) {
const ancestor = findAncestor(location.parent, isValidCallHierarchyDeclaration);
return ancestor && findImplementationOrAllInitialDeclarations(typeChecker, ancestor);
}
if (isVariableDeclaration(location.parent) && location.parent.initializer && isConstNamedExpression(location.parent.initializer)) {
return location.parent.initializer;
}
return undefined;
}
if (isConstructorDeclaration(location)) {
if (isValidCallHierarchyDeclaration(location.parent)) {
return location.parent;
}
return undefined;
}
if (location.kind === SyntaxKind.StaticKeyword && isClassStaticBlockDeclaration(location.parent)) {
location = location.parent;
continue;
}
// #39453
if (isVariableDeclaration(location) && location.initializer && isConstNamedExpression(location.initializer)) {
return location.initializer;
}
if (!followingSymbol) {
let symbol = typeChecker.getSymbolAtLocation(location);
if (symbol) {
if (symbol.flags & SymbolFlags.Alias) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
if (symbol.valueDeclaration) {
followingSymbol = true;
location = symbol.valueDeclaration;
continue;
}
}
}
return undefined;
}
}
/** Creates a `CallHierarchyItem` for a call hierarchy declaration. */
export function createCallHierarchyItem(program: Program, node: CallHierarchyDeclaration): CallHierarchyItem {
const sourceFile = node.getSourceFile();
const name = getCallHierarchyItemName(program, node);
const containerName = getCallHierarchItemContainerName(node);
const kind = getNodeKind(node);
const kindModifiers = getNodeModifiers(node);
const span = createTextSpanFromBounds(skipTrivia(sourceFile.text, node.getFullStart(), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true), node.getEnd());
const selectionSpan = createTextSpanFromBounds(name.pos, name.end);
return { file: sourceFile.fileName, kind, kindModifiers, name: name.text, containerName, span, selectionSpan };
}
function isDefined<T>(x: T): x is NonNullable<T> {
return x !== undefined;
}
interface CallSite {
declaration: CallHierarchyDeclaration;
range: TextRange;
}
function convertEntryToCallSite(entry: FindAllReferences.Entry): CallSite | undefined {
if (entry.kind === FindAllReferences.EntryKind.Node) {
const { node } = entry;
if (isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
|| isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
|| isDecoratorTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
|| isJsxOpeningLikeElementTagName(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true)
|| isRightSideOfPropertyAccess(node)
|| isArgumentExpressionOfElementAccess(node)) {
const sourceFile = node.getSourceFile();
const ancestor = findAncestor(node, isValidCallHierarchyDeclaration) || sourceFile;
return { declaration: ancestor, range: createTextRangeFromNode(node, sourceFile) };
}
}
}
function getCallSiteGroupKey(entry: CallSite) {
return getNodeId(entry.declaration);
}
function createCallHierarchyIncomingCall(from: CallHierarchyItem, fromSpans: TextSpan[]): CallHierarchyIncomingCall {
return { from, fromSpans };
}
function convertCallSiteGroupToIncomingCall(program: Program, entries: readonly CallSite[]) {
return createCallHierarchyIncomingCall(createCallHierarchyItem(program, entries[0].declaration), map(entries, entry => createTextSpanFromRange(entry.range)));
}
/** Gets the call sites that call into the provided call hierarchy declaration. */
export function getIncomingCalls(program: Program, declaration: CallHierarchyDeclaration, cancellationToken: CancellationToken): CallHierarchyIncomingCall[] {
// Source files and modules have no incoming calls.
if (isSourceFile(declaration) || isModuleDeclaration(declaration) || isClassStaticBlockDeclaration(declaration)) {
return [];
}
const location = getCallHierarchyDeclarationReferenceNode(declaration);
const calls = filter(FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: FindAllReferences.FindReferencesUse.References }, convertEntryToCallSite), isDefined);
return calls ? group(calls, getCallSiteGroupKey, entries => convertCallSiteGroupToIncomingCall(program, entries)) : [];
}
function createCallSiteCollector(program: Program, callSites: CallSite[]): (node: Node | undefined) => void {
function recordCallSite(node: CallExpression | NewExpression | TaggedTemplateExpression | PropertyAccessExpression | ElementAccessExpression | Decorator | JsxOpeningLikeElement | ClassStaticBlockDeclaration) {
const target =
isTaggedTemplateExpression(node) ? node.tag :
isJsxOpeningLikeElement(node) ? node.tagName :
isAccessExpression(node) ? node :
isClassStaticBlockDeclaration(node) ? node :
node.expression;
const declaration = resolveCallHierarchyDeclaration(program, target);
if (declaration) {
const range = createTextRangeFromNode(target, node.getSourceFile());
if (isArray(declaration)) {
for (const decl of declaration) {
callSites.push({ declaration: decl, range });
}
}
else {
callSites.push({ declaration, range });
}
}
}
function collect(node: Node | undefined) {
if (!node) return;
if (node.flags & NodeFlags.Ambient) {
// do not descend into ambient nodes.
return;
}
if (isValidCallHierarchyDeclaration(node)) {
// do not descend into other call site declarations, other than class member names
if (isClassLike(node)) {
for (const member of node.members) {
if (member.name && isComputedPropertyName(member.name)) {
collect(member.name.expression);
}
}
}
return;
}
switch (node.kind) {
case SyntaxKind.Identifier:
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ExportDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
// do not descend into nodes that cannot contain callable nodes
return;
case SyntaxKind.ClassStaticBlockDeclaration:
recordCallSite(node as ClassStaticBlockDeclaration);
return;
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
// do not descend into the type side of an assertion
collect((node as TypeAssertion | AsExpression).expression);
return;
case SyntaxKind.VariableDeclaration:
case SyntaxKind.Parameter:
// do not descend into the type of a variable or parameter declaration
collect((node as VariableDeclaration | ParameterDeclaration).name);
collect((node as VariableDeclaration | ParameterDeclaration).initializer);
return;
case SyntaxKind.CallExpression:
// do not descend into the type arguments of a call expression
recordCallSite(node as CallExpression);
collect((node as CallExpression).expression);
forEach((node as CallExpression).arguments, collect);
return;
case SyntaxKind.NewExpression:
// do not descend into the type arguments of a new expression
recordCallSite(node as NewExpression);
collect((node as NewExpression).expression);
forEach((node as NewExpression).arguments, collect);
return;
case SyntaxKind.TaggedTemplateExpression:
// do not descend into the type arguments of a tagged template expression
recordCallSite(node as TaggedTemplateExpression);
collect((node as TaggedTemplateExpression).tag);
collect((node as TaggedTemplateExpression).template);
return;
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxSelfClosingElement:
// do not descend into the type arguments of a JsxOpeningLikeElement
recordCallSite(node as JsxOpeningLikeElement);
collect((node as JsxOpeningLikeElement).tagName);
collect((node as JsxOpeningLikeElement).attributes);
return;
case SyntaxKind.Decorator:
recordCallSite(node as Decorator);
collect((node as Decorator).expression);
return;
case SyntaxKind.PropertyAccessExpression:
case SyntaxKind.ElementAccessExpression:
recordCallSite(node as AccessExpression);
forEachChild(node, collect);
break;
}
if (isPartOfTypeNode(node)) {
// do not descend into types
return;
}
forEachChild(node, collect);
}
return collect;
}
function collectCallSitesOfSourceFile(node: SourceFile, collect: (node: Node | undefined) => void) {
forEach(node.statements, collect);
}
function collectCallSitesOfModuleDeclaration(node: ModuleDeclaration, collect: (node: Node | undefined) => void) {
if (!hasSyntacticModifier(node, ModifierFlags.Ambient) && node.body && isModuleBlock(node.body)) {
forEach(node.body.statements, collect);
}
}
function collectCallSitesOfFunctionLikeDeclaration(typeChecker: TypeChecker, node: FunctionLikeDeclaration, collect: (node: Node | undefined) => void) {
const implementation = findImplementation(typeChecker, node);
if (implementation) {
forEach(implementation.parameters, collect);
collect(implementation.body);
}
}
function collectCallSitesOfClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, collect: (node: Node | undefined) => void) {
collect(node.body);
}
function collectCallSitesOfClassLikeDeclaration(node: ClassLikeDeclaration, collect: (node: Node | undefined) => void) {
forEach(node.decorators, collect);
const heritage = getClassExtendsHeritageElement(node);
if (heritage) {
collect(heritage.expression);
}
for (const member of node.members) {
forEach(member.decorators, collect);
if (isPropertyDeclaration(member)) {
collect(member.initializer);
}
else if (isConstructorDeclaration(member) && member.body) {
forEach(member.parameters, collect);
collect(member.body);
}
else if (isClassStaticBlockDeclaration(member)) {
collect(member);
}
}
}
function collectCallSites(program: Program, node: CallHierarchyDeclaration) {
const callSites: CallSite[] = [];
const collect = createCallSiteCollector(program, callSites);
switch (node.kind) {
case SyntaxKind.SourceFile:
collectCallSitesOfSourceFile(node, collect);
break;
case SyntaxKind.ModuleDeclaration:
collectCallSitesOfModuleDeclaration(node, collect);
break;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect);
break;
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
collectCallSitesOfClassLikeDeclaration(node, collect);
break;
case SyntaxKind.ClassStaticBlockDeclaration:
collectCallSitesOfClassStaticBlockDeclaration(node, collect);
break;
default:
Debug.assertNever(node);
}
return callSites;
}
function createCallHierarchyOutgoingCall(to: CallHierarchyItem, fromSpans: TextSpan[]): CallHierarchyOutgoingCall {
return { to, fromSpans };
}
function convertCallSiteGroupToOutgoingCall(program: Program, entries: readonly CallSite[]) {
return createCallHierarchyOutgoingCall(createCallHierarchyItem(program, entries[0].declaration), map(entries, entry => createTextSpanFromRange(entry.range)));
}
/** Gets the call sites that call out of the provided call hierarchy declaration. */
export function getOutgoingCalls(program: Program, declaration: CallHierarchyDeclaration): CallHierarchyOutgoingCall[] {
if (declaration.flags & NodeFlags.Ambient || isMethodSignature(declaration)) {
return [];
}
return group(collectCallSites(program, declaration), getCallSiteGroupKey, entries => convertCallSiteGroupToOutgoingCall(program, entries));
}
}