Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. 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
import { StaticSymbol } from '@angular/compiler';
9
/**
10
 * The range of a span of text in a source file.
11
 *
12
 * @experimental
13
 */
14
export interface Span {
15
    /**
16
     * The first code-point of the span as an offset relative to the beginning of the source assuming
17
     * a UTF-16 encoding.
18
     */
19
    start: number;
20
    /**
21
     * The first code-point after the span as an offset relative to the beginning of the source
22
     * assuming a UTF-16 encoding.
23
     */
24
    end: number;
25
}
26
/**
27
 * A file and span.
28
 */
29
export interface Location {
30
    fileName: string;
31
    span: Span;
32
}
33
/**
34
 * A defnition location(s).
35
 */
36
export declare type Definition = Location[] | undefined;
37
/**
38
 * A symbol describing a language element that can be referenced by expressions
39
 * in an Angular template.
40
 *
41
 * @experimental
42
 */
43
export interface Symbol {
44
    /**
45
     * The name of the symbol as it would be referenced in an Angular expression.
46
     */
47
    readonly name: string;
48
    /**
49
     * The kind of completion this symbol should generate if included.
50
     */
51
    readonly kind: string;
52
    /**
53
     * The language of the source that defines the symbol. (e.g. typescript for TypeScript,
54
     * ng-template for an Angular template, etc.)
55
     */
56
    readonly language: string;
57
    /**
58
     * A symbol representing type of the symbol.
59
     */
60
    readonly type: Symbol | undefined;
61
    /**
62
     * A symbol for the container of this symbol. For example, if this is a method, the container
63
     * is the class or interface of the method. If no container is appropriate, undefined is
64
     * returned.
65
     */
66
    readonly container: Symbol | undefined;
67
    /**
68
     * The symbol is public in the container.
69
     */
70
    readonly public: boolean;
71
    /**
72
     * `true` if the symbol can be the target of a call.
73
     */
74
    readonly callable: boolean;
75
    /**
76
     * The location of the definition of the symbol
77
     */
78
    readonly definition: Definition | undefined;
79
    /**
80
     * `true` if the symbol is a type that is nullable (can be null or undefined).
81
     */
82
    readonly nullable: boolean;
83
    /**
84
     * A table of the members of the symbol; that is, the members that can appear
85
     * after a `.` in an Angular expression.
86
     */
87
    members(): SymbolTable;
88
    /**
89
     * The list of overloaded signatures that can be used if the symbol is the
90
     * target of a call.
91
     */
92
    signatures(): Signature[];
93
    /**
94
     * Return which signature of returned by `signatures()` would be used selected
95
     * given the `types` supplied. If no signature would match, this method should
96
     * return `undefined`.
97
     */
98
    selectSignature(types: Symbol[]): Signature | undefined;
99
    /**
100
     * Return the type of the expression if this symbol is indexed by `argument`.
101
     * If the symbol cannot be indexed, this method should return `undefined`.
102
     */
103
    indexed(argument: Symbol): Symbol | undefined;
104
}
105
/**
106
 * A table of `Symbol`s accessible by name.
107
 *
108
 * @experimental
109
 */
110
export interface SymbolTable {
111
    /**
112
     * The number of symbols in the table.
113
     */
114
    readonly size: number;
115
    /**
116
     * Get the symbol corresponding to `key` or `undefined` if there is no symbol in the
117
     * table by the name `key`.
118
     */
119
    get(key: string): Symbol | undefined;
120
    /**
121
     * Returns `true` if the table contains a `Symbol` with the name `key`.
122
     */
123
    has(key: string): boolean;
124
    /**
125
     * Returns all the `Symbol`s in the table. The order should be, but is not required to be,
126
     * in declaration order.
127
     */
128
    values(): Symbol[];
129
}
130
/**
131
 * A description of a function or method signature.
132
 *
133
 * @experimental
134
 */
135
export interface Signature {
136
    /**
137
     * The arguments of the signture. The order of `argumetnts.symbols()` must be in the order
138
     * of argument declaration.
139
     */
140
    readonly arguments: SymbolTable;
141
    /**
142
     * The symbol of the signature result type.
143
     */
144
    readonly result: Symbol;
145
}
146
/**
147
 * An enumeration of basic types.
148
 *
149
 * @experimental
150
 */
151
export declare enum BuiltinType {
152
    /**
153
     * The type is a type that can hold any other type.
154
     */
155
    Any = 0,
156
    /**
157
     * The type of a string literal.
158
     */
159
    String = 1,
160
    /**
161
     * The type of a numeric literal.
162
     */
163
    Number = 2,
164
    /**
165
     * The type of the `true` and `false` literals.
166
     */
167
    Boolean = 3,
168
    /**
169
     * The type of the `undefined` literal.
170
     */
171
    Undefined = 4,
172
    /**
173
     * the type of the `null` literal.
174
     */
175
    Null = 5,
176
    /**
177
     * the type is an unbound type parameter.
178
     */
179
    Unbound = 6,
180
    /**
181
     * Not a built-in type.
182
     */
183
    Other = 7,
184
}
185
/**
186
 * The kinds of defintion.
187
 *
188
 * @experimental
189
 */
190
export declare type DeclarationKind = 'attribute' | 'html attribute' | 'component' | 'element' | 'entity' | 'key' | 'method' | 'pipe' | 'property' | 'type' | 'reference' | 'variable';
191
/**
192
 * Describes a symbol to type binding used to build a symbol table.
193
 *
194
 * @experimental
195
 */
196
export interface SymbolDeclaration {
197
    /**
198
     * The name of the symbol in table.
199
     */
200
    readonly name: string;
201
    /**
202
     * The kind of symbol to declare.
203
     */
204
    readonly kind: DeclarationKind;
205
    /**
206
     * Type of the symbol. The type symbol should refer to a symbol for a type.
207
     */
208
    readonly type: Symbol;
209
    /**
210
     * The definion of the symbol if one exists.
211
     */
212
    readonly definition?: Definition;
213
}
214
/**
215
 * Information about the pipes that are available for use in a template.
216
 *
217
 * @experimental
218
 */
219
export interface PipeInfo {
220
    /**
221
     * The name of the pipe.
222
     */
223
    name: string;
224
    /**
225
     * The static symbol for the pipe's constructor.
226
     */
227
    symbol: StaticSymbol;
228
}
229
/**
230
 * A sequence of pipe information.
231
 *
232
 * @experimental
233
 */
234
export declare type Pipes = PipeInfo[] | undefined;
235
/**
236
 * Describes the language context in which an Angular expression is evaluated.
237
 *
238
 * @experimental
239
 */
240
export interface SymbolQuery {
241
    /**
242
     * Return the built-in type this symbol represents or Other if it is not a built-in type.
243
     */
244
    getTypeKind(symbol: Symbol): BuiltinType;
245
    /**
246
     * Return a symbol representing the given built-in type.
247
     */
248
    getBuiltinType(kind: BuiltinType): Symbol;
249
    /**
250
     * Return the symbol for a type that represents the union of all the types given. Any value
251
     * of one of the types given should be assignable to the returned type. If no one type can
252
     * be constructed then this should be the Any type.
253
     */
254
    getTypeUnion(...types: Symbol[]): Symbol;
255
    /**
256
     * Return a symbol for an array type that has the `type` as its element type.
257
     */
258
    getArrayType(type: Symbol): Symbol;
259
    /**
260
     * Return element type symbol for an array type if the `type` is an array type. Otherwise return
261
     * undefined.
262
     */
263
    getElementType(type: Symbol): Symbol | undefined;
264
    /**
265
     * Return a type that is the non-nullable version of the given type. If `type` is already
266
     * non-nullable, return `type`.
267
     */
268
    getNonNullableType(type: Symbol): Symbol;
269
    /**
270
     * Return a symbol table for the pipes that are in scope.
271
     */
272
    getPipes(): SymbolTable;
273
    /**
274
     * Return the type symbol for the given static symbol.
275
     */
276
    getTypeSymbol(type: StaticSymbol): Symbol | undefined;
277
    /**
278
     * Return the members that are in the context of a type's template reference.
279
     */
280
    getTemplateContext(type: StaticSymbol): SymbolTable | undefined;
281
    /**
282
     * Produce a symbol table with the given symbols. Used to produce a symbol table
283
     * for use with mergeSymbolTables().
284
     */
285
    createSymbolTable(symbols: SymbolDeclaration[]): SymbolTable;
286
    /**
287
     * Produce a merged symbol table. If the symbol tables contain duplicate entries
288
     * the entries of the latter symbol tables will obscure the entries in the prior
289
     * symbol tables.
290
     *
291
     * The symbol tables passed to this routine MUST be produces by the same instance
292
     * of SymbolQuery that is being called.
293
     */
294
    mergeSymbolTable(symbolTables: SymbolTable[]): SymbolTable;
295
    /**
296
     * Return the span of the narrowest non-token node at the given location.
297
     */
298
    getSpanAt(line: number, column: number): Span | undefined;
299
}
(10-10/15)