/
context.ts
60 lines (51 loc) 路 1.65 KB
/
context.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {BoundTarget, DirectiveMeta, ParseSourceFile} from '@angular/compiler';
import {Reference} from '../../imports';
import {ClassDeclaration} from '../../reflection';
export interface ComponentMeta extends DirectiveMeta {
ref: Reference<ClassDeclaration>;
/**
* Unparsed selector of the directive, or null if the directive does not have a selector.
*/
selector: string|null;
}
/**
* An intermediate representation of a component.
*/
export interface ComponentInfo {
/** Component TypeScript class declaration */
declaration: ClassDeclaration;
/** Component template selector if it exists, otherwise null. */
selector: string|null;
/**
* BoundTarget containing the parsed template. Can also be used to query for directives used in
* the template.
*/
boundTemplate: BoundTarget<ComponentMeta>;
/** Metadata about the template */
templateMeta: {
/** Whether the component template is inline */
isInline: boolean;
/** Template file recorded by template parser */
file: ParseSourceFile;
};
}
/**
* A context for storing indexing infromation about components of a program.
*
* An `IndexingContext` collects component and template analysis information from
* `DecoratorHandler`s and exposes them to be indexed.
*/
export class IndexingContext {
readonly components = new Set<ComponentInfo>();
/**
* Adds a component to the context.
*/
addComponent(info: ComponentInfo) { this.components.add(info); }
}