MCPcopy Create free account
hub / github.com/angular/angular / isWithinNode

Function isWithinNode

packages/language-service/src/template_target.ts:704–718  ·  view source on GitHub ↗

Checks whether a position is within an AST node.

(position: number, node: TmplAstNode)

Source from the content-addressed store, hash-verified

702
703/** Checks whether a position is within an AST node. */
704function 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. */
721function isWithinTagBody(position: number, node: TmplAstElement): boolean {

Callers 1

visitMethod · 0.85

Calls 3

isWithinFunction · 0.90
getSpanIncludingEndTagFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected