File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/graphqlsp/src/ast Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -325,3 +325,29 @@ export function getValueOfIdentifier(
325
325
}
326
326
}
327
327
}
328
+
329
+ /** Resolves exressions that might not influence the target identifier */
330
+ export function getIdentifierOfChainExpression (
331
+ node : ts . Expression
332
+ ) : ts . Identifier | undefined {
333
+ let target : ts . Expression | undefined = node ;
334
+ while ( target ) {
335
+ if ( ts . isPropertyAccessExpression ( target ) ) {
336
+ target = target . name ;
337
+ } else if (
338
+ ts . isAsExpression ( target ) ||
339
+ ts . isSatisfiesExpression ( target ) ||
340
+ ts . isNonNullExpression ( target ) ||
341
+ ts . isParenthesizedExpression ( target ) ||
342
+ ts . isExpressionWithTypeArguments ( target )
343
+ ) {
344
+ target = target . expression ;
345
+ } else if ( ts . isCommaListExpression ( target ) ) {
346
+ target = target . elements [ target . elements . length - 1 ] ;
347
+ } else if ( ts . isIdentifier ( target ) ) {
348
+ return target ;
349
+ } else {
350
+ return ;
351
+ }
352
+ }
353
+ }
You can’t perform that action at this time.
0 commit comments