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

Function isWithinNode

packages/language-service/src/template_target.ts:775–789  ·  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

773
774/** Checks whether a position is within an AST node. */
775function 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. */
792function isWithinTagBody(position: number, node: TmplAstElement | TmplAstComponent): boolean {

Callers 1

visitMethod · 0.85

Calls 3

isWithinFunction · 0.90
getSpanIncludingEndTagFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected