* Finds the parent of child node in the provided AST.
(child: AnyNode, ast: Expression)
| 541 | * Finds the parent of child node in the provided AST. |
| 542 | */ |
| 543 | function findParentNode(child: AnyNode, ast: Expression): AnyNode | undefined { |
| 544 | let foundParent: AnyNode | undefined; |
| 545 | |
| 546 | walk.ancestor(ast, { |
| 547 | [child.type]: (node: AcornNode, _state: undefined, ancestors: AnyNode[]) => { |
| 548 | if (node.start === child.start && node.end === child.end) { |
| 549 | // The parent is the second last ancestor in the stack (last one is the actual node) |
| 550 | foundParent = ancestors[ancestors.length - 2]; |
| 551 | } |
| 552 | }, |
| 553 | }); |
| 554 | |
| 555 | return foundParent; |
| 556 | } |
| 557 | |
| 558 | function isSupportedMemberProperty(node: Expression | PrivateIdentifier | Super) { |
| 559 | return node.type === 'Identifier' || node.type === 'Literal'; |
no outgoing calls
no test coverage detected