Skip to content

Commit

Permalink
Add links to where functions are sourced from
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Aug 22, 2024
1 parent 3d34875 commit 497bf90
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/graphqlsp/src/ast/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function getValueOfValueDeclaration(
}
}

// See: https://github.com/microsoft/TypeScript/blob/a5eec2485f8798ece493c00fce1cde4d8f8a8147/src/services/utilities.ts#L652-L654
function climbPastPropertyOrElementAccess(node: ts.Node): ts.Node {
if (
node.parent &&
Expand All @@ -127,18 +128,21 @@ function climbPastPropertyOrElementAccess(node: ts.Node): ts.Node {
}
}

// See: https://github.com/microsoft/TypeScript/blob/a5eec2485f8798ece493c00fce1cde4d8f8a8147/src/services/utilities.ts#L602-L605
function isNewExpressionTarget(node: ts.Node): node is ts.NewExpression {
const target = climbPastPropertyOrElementAccess(node).parent;
return ts.isNewExpression(target) && target.expression === node;
}

// See: https://github.com/microsoft/TypeScript/blob/a5eec2485f8798ece493c00fce1cde4d8f8a8147/src/services/utilities.ts#L607-L610
function isCallOrNewExpressionTarget(
node: ts.Node
): node is ts.CallExpression | ts.NewExpression {
const target = climbPastPropertyOrElementAccess(node).parent;
return ts.isCallOrNewExpression(target) && target.expression === node;
}

// See: https://github.com/microsoft/TypeScript/blob/a5eec2485f8798ece493c00fce1cde4d8f8a8147/src/services/utilities.ts#L716-L719
function isNameOfFunctionDeclaration(node: ts.Node): boolean {
return (
ts.isIdentifier(node) &&
Expand All @@ -148,6 +152,7 @@ function isNameOfFunctionDeclaration(node: ts.Node): boolean {
);
}

// See: https://github.com/microsoft/TypeScript/blob/a5eec2485f8798ece493c00fce1cde4d8f8a8147/src/services/utilities.ts#L2441-L2447
function getNameFromPropertyName(name: ts.PropertyName): string | undefined {
if (ts.isComputedPropertyName(name)) {
return ts.isStringLiteralLike(name.expression) ||
Expand Down

0 comments on commit 497bf90

Please sign in to comment.