Checks whether a position is within an AST node.
(position: number, node: TmplAstNode)
| 768 | |
| 769 | /** Checks whether a position is within an AST node. */ |
| 770 | function isWithinNode(position: number, node: TmplAstNode): boolean { |
| 771 | if (!(node instanceof TmplAstHostElement)) { |
| 772 | return isWithin(position, getSpanIncludingEndTag(node)); |
| 773 | } |
| 774 | |
| 775 | // Host elements are special in that they don't have a contiguous source span. E.g. some bindings |
| 776 | // can be in the `host` literal in the decorator while others are on class members. That's why we |
| 777 | // need to check each binding, rather than the host element itself. |
| 778 | return ( |
| 779 | (node.bindings.length > 0 && |
| 780 | node.bindings.some((binding) => isWithin(position, binding.sourceSpan))) || |
| 781 | (node.listeners.length > 0 && |
| 782 | node.listeners.some((listener) => isWithin(position, listener.sourceSpan))) |
| 783 | ); |
| 784 | } |
| 785 | |
| 786 | /** Checks whether a position is within the body or the start syntax of a node. */ |
| 787 | function isWithinTagBody(position: number, node: TmplAstElement | TmplAstComponent): boolean { |
no test coverage detected
searching dependent graphs…