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