UNPKG

2.45 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 */
8import { TmplAstReference, TmplAstVariable } from '@angular/compiler';
9import { TcbLocation } from './symbols';
10/**
11 * An autocompletion source of any kind.
12 */
13export type Completion = ReferenceCompletion | VariableCompletion;
14/**
15 * Discriminant of an autocompletion source (a `Completion`).
16 */
17export declare enum CompletionKind {
18 Reference = 0,
19 Variable = 1
20}
21/**
22 * An autocompletion result representing a local reference declared in the template.
23 */
24export interface ReferenceCompletion {
25 kind: CompletionKind.Reference;
26 /**
27 * The `TmplAstReference` from the template which should be available as a completion.
28 */
29 node: TmplAstReference;
30}
31/**
32 * An autocompletion result representing a variable declared in the template.
33 */
34export interface VariableCompletion {
35 kind: CompletionKind.Variable;
36 /**
37 * The `TmplAstVariable` from the template which should be available as a completion.
38 */
39 node: TmplAstVariable;
40}
41/**
42 * Autocompletion data for an expression in the global scope.
43 *
44 * Global completion is accomplished by merging data from two sources:
45 * * TypeScript completion of the component's class members.
46 * * Local references and variables that are in scope at a given template level.
47 */
48export interface GlobalCompletion {
49 /**
50 * A location within the type-checking shim where TypeScript's completion APIs can be used to
51 * access completions for the template's component context (component class members).
52 */
53 componentContext: TcbLocation;
54 /**
55 * `Map` of local references and variables that are visible at the requested level of the
56 * template.
57 *
58 * Shadowing of references/variables from multiple levels of the template has already been
59 * accounted for in the preparation of `templateContext`. Entries here shadow component members of
60 * the same name (from the `componentContext` completions).
61 */
62 templateContext: Map<string, ReferenceCompletion | VariableCompletion>;
63 /**
64 * A location within the type-checking shim where TypeScript's completion APIs can be used to
65 * access completions for the AST node of the cursor position (primitive constants).
66 */
67 nodeContext: TcbLocation | null;
68}