source: trip-planner-front/node_modules/@angular/compiler/src/template_parser/template_ast.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 11.1 KB
Line 
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 */
8import { AstPath } from '../ast_path';
9import { CompileDirectiveSummary, CompileProviderMetadata, CompileTokenMetadata } from '../compile_metadata';
10import { SecurityContext } from '../core';
11import { ASTWithSource, BoundElementProperty, ParsedEvent, ParsedVariable } from '../expression_parser/ast';
12import { LifecycleHooks } from '../lifecycle_reflector';
13import { ParseSourceSpan } from '../parse_util';
14/**
15 * An Abstract Syntax Tree node representing part of a parsed Angular template.
16 */
17export interface TemplateAst {
18 /**
19 * The source span from which this node was parsed.
20 */
21 sourceSpan: ParseSourceSpan;
22 /**
23 * Visit this node and possibly transform it.
24 */
25 visit(visitor: TemplateAstVisitor, context: any): any;
26}
27/**
28 * A segment of text within the template.
29 */
30export declare class TextAst implements TemplateAst {
31 value: string;
32 ngContentIndex: number;
33 sourceSpan: ParseSourceSpan;
34 constructor(value: string, ngContentIndex: number, sourceSpan: ParseSourceSpan);
35 visit(visitor: TemplateAstVisitor, context: any): any;
36}
37/**
38 * A bound expression within the text of a template.
39 */
40export declare class BoundTextAst implements TemplateAst {
41 value: ASTWithSource;
42 ngContentIndex: number;
43 sourceSpan: ParseSourceSpan;
44 constructor(value: ASTWithSource, ngContentIndex: number, sourceSpan: ParseSourceSpan);
45 visit(visitor: TemplateAstVisitor, context: any): any;
46}
47/**
48 * A plain attribute on an element.
49 */
50export declare class AttrAst implements TemplateAst {
51 name: string;
52 value: string;
53 sourceSpan: ParseSourceSpan;
54 constructor(name: string, value: string, sourceSpan: ParseSourceSpan);
55 visit(visitor: TemplateAstVisitor, context: any): any;
56}
57export declare const enum PropertyBindingType {
58 Property = 0,
59 Attribute = 1,
60 Class = 2,
61 Style = 3,
62 Animation = 4
63}
64/**
65 * A binding for an element property (e.g. `[property]="expression"`) or an animation trigger (e.g.
66 * `[@trigger]="stateExp"`)
67 */
68export declare class BoundElementPropertyAst implements TemplateAst {
69 name: string;
70 type: PropertyBindingType;
71 securityContext: SecurityContext;
72 value: ASTWithSource;
73 unit: string | null;
74 sourceSpan: ParseSourceSpan;
75 readonly isAnimation: boolean;
76 constructor(name: string, type: PropertyBindingType, securityContext: SecurityContext, value: ASTWithSource, unit: string | null, sourceSpan: ParseSourceSpan);
77 static fromBoundProperty(prop: BoundElementProperty): BoundElementPropertyAst;
78 visit(visitor: TemplateAstVisitor, context: any): any;
79}
80/**
81 * A binding for an element event (e.g. `(event)="handler()"`) or an animation trigger event (e.g.
82 * `(@trigger.phase)="callback($event)"`).
83 */
84export declare class BoundEventAst implements TemplateAst {
85 name: string;
86 target: string | null;
87 phase: string | null;
88 handler: ASTWithSource;
89 sourceSpan: ParseSourceSpan;
90 handlerSpan: ParseSourceSpan;
91 readonly fullName: string;
92 readonly isAnimation: boolean;
93 constructor(name: string, target: string | null, phase: string | null, handler: ASTWithSource, sourceSpan: ParseSourceSpan, handlerSpan: ParseSourceSpan);
94 static calcFullName(name: string, target: string | null, phase: string | null): string;
95 static fromParsedEvent(event: ParsedEvent): BoundEventAst;
96 visit(visitor: TemplateAstVisitor, context: any): any;
97}
98/**
99 * A reference declaration on an element (e.g. `let someName="expression"`).
100 */
101export declare class ReferenceAst implements TemplateAst {
102 name: string;
103 value: CompileTokenMetadata;
104 originalValue: string;
105 sourceSpan: ParseSourceSpan;
106 constructor(name: string, value: CompileTokenMetadata, originalValue: string, sourceSpan: ParseSourceSpan);
107 visit(visitor: TemplateAstVisitor, context: any): any;
108}
109/**
110 * A variable declaration on a <ng-template> (e.g. `var-someName="someLocalName"`).
111 */
112export declare class VariableAst implements TemplateAst {
113 readonly name: string;
114 readonly value: string;
115 readonly sourceSpan: ParseSourceSpan;
116 readonly valueSpan?: ParseSourceSpan | undefined;
117 constructor(name: string, value: string, sourceSpan: ParseSourceSpan, valueSpan?: ParseSourceSpan | undefined);
118 static fromParsedVariable(v: ParsedVariable): VariableAst;
119 visit(visitor: TemplateAstVisitor, context: any): any;
120}
121/**
122 * An element declaration in a template.
123 */
124export declare class ElementAst implements TemplateAst {
125 name: string;
126 attrs: AttrAst[];
127 inputs: BoundElementPropertyAst[];
128 outputs: BoundEventAst[];
129 references: ReferenceAst[];
130 directives: DirectiveAst[];
131 providers: ProviderAst[];
132 hasViewContainer: boolean;
133 queryMatches: QueryMatch[];
134 children: TemplateAst[];
135 ngContentIndex: number | null;
136 sourceSpan: ParseSourceSpan;
137 endSourceSpan: ParseSourceSpan | null;
138 constructor(name: string, attrs: AttrAst[], inputs: BoundElementPropertyAst[], outputs: BoundEventAst[], references: ReferenceAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, queryMatches: QueryMatch[], children: TemplateAst[], ngContentIndex: number | null, sourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null);
139 visit(visitor: TemplateAstVisitor, context: any): any;
140}
141/**
142 * A `<ng-template>` element included in an Angular template.
143 */
144export declare class EmbeddedTemplateAst implements TemplateAst {
145 attrs: AttrAst[];
146 outputs: BoundEventAst[];
147 references: ReferenceAst[];
148 variables: VariableAst[];
149 directives: DirectiveAst[];
150 providers: ProviderAst[];
151 hasViewContainer: boolean;
152 queryMatches: QueryMatch[];
153 children: TemplateAst[];
154 ngContentIndex: number;
155 sourceSpan: ParseSourceSpan;
156 constructor(attrs: AttrAst[], outputs: BoundEventAst[], references: ReferenceAst[], variables: VariableAst[], directives: DirectiveAst[], providers: ProviderAst[], hasViewContainer: boolean, queryMatches: QueryMatch[], children: TemplateAst[], ngContentIndex: number, sourceSpan: ParseSourceSpan);
157 visit(visitor: TemplateAstVisitor, context: any): any;
158}
159/**
160 * A directive property with a bound value (e.g. `*ngIf="condition").
161 */
162export declare class BoundDirectivePropertyAst implements TemplateAst {
163 directiveName: string;
164 templateName: string;
165 value: ASTWithSource;
166 sourceSpan: ParseSourceSpan;
167 constructor(directiveName: string, templateName: string, value: ASTWithSource, sourceSpan: ParseSourceSpan);
168 visit(visitor: TemplateAstVisitor, context: any): any;
169}
170/**
171 * A directive declared on an element.
172 */
173export declare class DirectiveAst implements TemplateAst {
174 directive: CompileDirectiveSummary;
175 inputs: BoundDirectivePropertyAst[];
176 hostProperties: BoundElementPropertyAst[];
177 hostEvents: BoundEventAst[];
178 contentQueryStartId: number;
179 sourceSpan: ParseSourceSpan;
180 constructor(directive: CompileDirectiveSummary, inputs: BoundDirectivePropertyAst[], hostProperties: BoundElementPropertyAst[], hostEvents: BoundEventAst[], contentQueryStartId: number, sourceSpan: ParseSourceSpan);
181 visit(visitor: TemplateAstVisitor, context: any): any;
182}
183/**
184 * A provider declared on an element
185 */
186export declare class ProviderAst implements TemplateAst {
187 token: CompileTokenMetadata;
188 multiProvider: boolean;
189 eager: boolean;
190 providers: CompileProviderMetadata[];
191 providerType: ProviderAstType;
192 lifecycleHooks: LifecycleHooks[];
193 sourceSpan: ParseSourceSpan;
194 readonly isModule: boolean;
195 constructor(token: CompileTokenMetadata, multiProvider: boolean, eager: boolean, providers: CompileProviderMetadata[], providerType: ProviderAstType, lifecycleHooks: LifecycleHooks[], sourceSpan: ParseSourceSpan, isModule: boolean);
196 visit(visitor: TemplateAstVisitor, context: any): any;
197}
198export declare enum ProviderAstType {
199 PublicService = 0,
200 PrivateService = 1,
201 Component = 2,
202 Directive = 3,
203 Builtin = 4
204}
205/**
206 * Position where content is to be projected (instance of `<ng-content>` in a template).
207 */
208export declare class NgContentAst implements TemplateAst {
209 index: number;
210 ngContentIndex: number;
211 sourceSpan: ParseSourceSpan;
212 constructor(index: number, ngContentIndex: number, sourceSpan: ParseSourceSpan);
213 visit(visitor: TemplateAstVisitor, context: any): any;
214}
215export interface QueryMatch {
216 queryId: number;
217 value: CompileTokenMetadata;
218}
219/**
220 * A visitor for {@link TemplateAst} trees that will process each node.
221 */
222export interface TemplateAstVisitor {
223 visit?(ast: TemplateAst, context: any): any;
224 visitNgContent(ast: NgContentAst, context: any): any;
225 visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any;
226 visitElement(ast: ElementAst, context: any): any;
227 visitReference(ast: ReferenceAst, context: any): any;
228 visitVariable(ast: VariableAst, context: any): any;
229 visitEvent(ast: BoundEventAst, context: any): any;
230 visitElementProperty(ast: BoundElementPropertyAst, context: any): any;
231 visitAttr(ast: AttrAst, context: any): any;
232 visitBoundText(ast: BoundTextAst, context: any): any;
233 visitText(ast: TextAst, context: any): any;
234 visitDirective(ast: DirectiveAst, context: any): any;
235 visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): any;
236}
237/**
238 * A visitor that accepts each node but doesn't do anything. It is intended to be used
239 * as the base class for a visitor that is only interested in a subset of the node types.
240 */
241export declare class NullTemplateVisitor implements TemplateAstVisitor {
242 visitNgContent(ast: NgContentAst, context: any): void;
243 visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): void;
244 visitElement(ast: ElementAst, context: any): void;
245 visitReference(ast: ReferenceAst, context: any): void;
246 visitVariable(ast: VariableAst, context: any): void;
247 visitEvent(ast: BoundEventAst, context: any): void;
248 visitElementProperty(ast: BoundElementPropertyAst, context: any): void;
249 visitAttr(ast: AttrAst, context: any): void;
250 visitBoundText(ast: BoundTextAst, context: any): void;
251 visitText(ast: TextAst, context: any): void;
252 visitDirective(ast: DirectiveAst, context: any): void;
253 visitDirectiveProperty(ast: BoundDirectivePropertyAst, context: any): void;
254}
255/**
256 * Base class that can be used to build a visitor that visits each node
257 * in an template ast recursively.
258 */
259export declare class RecursiveTemplateAstVisitor extends NullTemplateVisitor implements TemplateAstVisitor {
260 constructor();
261 visitEmbeddedTemplate(ast: EmbeddedTemplateAst, context: any): any;
262 visitElement(ast: ElementAst, context: any): any;
263 visitDirective(ast: DirectiveAst, context: any): any;
264 protected visitChildren(context: any, cb: (visit: (<V extends TemplateAst>(children: V[] | undefined) => void)) => void): any[];
265}
266/**
267 * Visit every node in a list of {@link TemplateAst}s with the given {@link TemplateAstVisitor}.
268 */
269export declare function templateVisitAll(visitor: TemplateAstVisitor, asts: TemplateAst[], context?: any): any[];
270export declare type TemplateAstPath = AstPath<TemplateAst>;
Note: See TracBrowser for help on using the repository browser.