Checks whether a position is within an AST node.
(position: number, node: TmplAstNode)
| 702 | |
| 703 | /** Checks whether a position is within an AST node. */ |
| 704 | function isWithinNode(position: number, node: TmplAstNode): boolean { |
| 705 | if (!(node instanceof TmplAstHostElement)) { |
| 706 | return isWithin(position, getSpanIncludingEndTag(node)); |
| 707 | } |
| 708 | |
| 709 | // Host elements are special in that they don't have a contiguous source span. E.g. some bindings |
| 710 | // can be in the `host` literal in the decorator while others are on class members. That's why we |
| 711 | // need to check each binding, rather than the host element itself. |
| 712 | return ( |
| 713 | (node.bindings.length > 0 && |
| 714 | node.bindings.some((binding) => isWithin(position, binding.sourceSpan))) || |
| 715 | (node.listeners.length > 0 && |
| 716 | node.listeners.some((listener) => isWithin(position, listener.sourceSpan))) |
| 717 | ); |
| 718 | } |
| 719 | |
| 720 | /** Checks whether a position is within the body or the start syntax of a node. */ |
| 721 | function isWithinTagBody(position: number, node: TmplAstElement): boolean { |
no test coverage detected