UNPKG

2.16 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="@angular/language-service/src/utils" />
9import { BoundEventAst, CompileTypeMetadata, HtmlAstPath, Node, ParseSourceSpan, TemplateAst, TemplateAstPath } from '@angular/compiler';
10import { AstResult, DiagnosticTemplateInfo, SelectorInfo, Span, Symbol, SymbolQuery } from './types';
11interface SpanHolder {
12 sourceSpan: ParseSourceSpan;
13 endSourceSpan?: ParseSourceSpan | null;
14 children?: SpanHolder[];
15}
16export declare function spanOf(span: SpanHolder): Span;
17export declare function spanOf(span: ParseSourceSpan): Span;
18export declare function spanOf(span: SpanHolder | ParseSourceSpan | undefined): Span | undefined;
19export declare function inSpan(position: number, span?: Span, exclusive?: boolean): boolean;
20export declare function offsetSpan(span: Span, amount: number): Span;
21export declare function isNarrower(spanA: Span, spanB: Span): boolean;
22export declare function isStructuralDirective(type: CompileTypeMetadata): boolean;
23export declare function getSelectors(info: AstResult): SelectorInfo;
24export declare function diagnosticInfoFromTemplateInfo(info: AstResult): DiagnosticTemplateInfo;
25export declare function findTemplateAstAt(ast: TemplateAst[], position: number): TemplateAstPath;
26/**
27 * Find the tightest node at the specified `position` from the AST `nodes`, and
28 * return the path to the node.
29 * @param nodes HTML AST nodes
30 * @param position
31 */
32export declare function getPathToNodeAtPosition(nodes: Node[], position: number): HtmlAstPath;
33/**
34 * Inverts an object's key-value pairs.
35 */
36export declare function invertMap(obj: {
37 [name: string]: string;
38}): {
39 [name: string]: string;
40};
41/**
42 * Finds the directive member providing a template output binding, if one exists.
43 * @param info aggregate template AST information
44 * @param path narrowing
45 */
46export declare function findOutputBinding(binding: BoundEventAst, path: TemplateAstPath, query: SymbolQuery): Symbol | undefined;
47export {};