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

Function getTextSpanOfNode

packages/language-service/src/utils/index.ts:48–58  ·  view source on GitHub ↗
(node: TmplAstNode | AST)

Source from the content-addressed store, hash-verified

46import {findTightestNode, getParentClassDeclaration} from './ts_utils';
47
48export function getTextSpanOfNode(node: TmplAstNode | AST): ts.TextSpan {
49 if (isTemplateNodeWithKeyAndValue(node)) {
50 return toTextSpan(node.keySpan);
51 } else if (node instanceof BindingPipe || node instanceof PropertyRead) {
52 // The `name` part of a `PropertyRead` and `BindingPipe` does not have its own AST
53 // so there is no way to retrieve a `Symbol` for just the `name` via a specific node.
54 return toTextSpan(node.nameSpan);
55 } else {
56 return toTextSpan(node.sourceSpan);
57 }
58}
59
60export function toTextSpan(span: AbsoluteSourceSpan | ParseSourceSpan | ParseSpan): ts.TextSpan {
61 let start: number, end: number;

Calls 2

toTextSpanFunction · 0.85

Tested by

no test coverage detected