(thisOrSuperKeyword, sourceFiles, cancellationToken)
| 138583 | return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; |
| 138584 | } |
| 138585 | function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { |
| 138586 | var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); |
| 138587 | // Whether 'this' occurs in a static context within a class. |
| 138588 | var staticFlag = 32 /* ModifierFlags.Static */; |
| 138589 | switch (searchSpaceNode.kind) { |
| 138590 | case 169 /* SyntaxKind.MethodDeclaration */: |
| 138591 | case 168 /* SyntaxKind.MethodSignature */: |
| 138592 | if (ts.isObjectLiteralMethod(searchSpaceNode)) { |
| 138593 | staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); |
| 138594 | searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals |
| 138595 | break; |
| 138596 | } |
| 138597 | // falls through |
| 138598 | case 167 /* SyntaxKind.PropertyDeclaration */: |
| 138599 | case 166 /* SyntaxKind.PropertySignature */: |
| 138600 | case 171 /* SyntaxKind.Constructor */: |
| 138601 | case 172 /* SyntaxKind.GetAccessor */: |
| 138602 | case 173 /* SyntaxKind.SetAccessor */: |
| 138603 | staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); |
| 138604 | searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class |
| 138605 | break; |
| 138606 | case 305 /* SyntaxKind.SourceFile */: |
| 138607 | if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { |
| 138608 | return undefined; |
| 138609 | } |
| 138610 | // falls through |
| 138611 | case 256 /* SyntaxKind.FunctionDeclaration */: |
| 138612 | case 213 /* SyntaxKind.FunctionExpression */: |
| 138613 | break; |
| 138614 | // Computed properties in classes are not handled here because references to this are illegal, |
| 138615 | // so there is no point finding references to them. |
| 138616 | default: |
| 138617 | return undefined; |
| 138618 | } |
| 138619 | var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { |
| 138620 | cancellationToken.throwIfCancellationRequested(); |
| 138621 | return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { |
| 138622 | if (!ts.isThis(node)) { |
| 138623 | return false; |
| 138624 | } |
| 138625 | var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); |
| 138626 | switch (searchSpaceNode.kind) { |
| 138627 | case 213 /* SyntaxKind.FunctionExpression */: |
| 138628 | case 256 /* SyntaxKind.FunctionDeclaration */: |
| 138629 | return searchSpaceNode.symbol === container.symbol; |
| 138630 | case 169 /* SyntaxKind.MethodDeclaration */: |
| 138631 | case 168 /* SyntaxKind.MethodSignature */: |
| 138632 | return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; |
| 138633 | case 226 /* SyntaxKind.ClassExpression */: |
| 138634 | case 257 /* SyntaxKind.ClassDeclaration */: |
| 138635 | case 205 /* SyntaxKind.ObjectLiteralExpression */: |
| 138636 | // Make sure the container belongs to the same class/object literals |
| 138637 | // and has the appropriate static modifier from the original container. |
| 138638 | return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; |
| 138639 | case 305 /* SyntaxKind.SourceFile */: |
| 138640 | return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); |
| 138641 | } |
| 138642 | }); |
no test coverage detected