UNPKG

4.06 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/ivy/completions" />
9import { AST, TmplAstNode, TmplAstTemplate } from '@angular/compiler';
10import { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
11import * as ts from 'typescript';
12export declare enum CompletionNodeContext {
13 None = 0,
14 ElementTag = 1,
15 ElementAttributeKey = 2,
16 ElementAttributeValue = 3,
17 EventValue = 4,
18 TwoWayBinding = 5
19}
20/**
21 * Performs autocompletion operations on a given node in the template.
22 *
23 * This class acts as a closure around all of the context required to perform the 3 autocompletion
24 * operations (completions, get details, and get symbol) at a specific node.
25 *
26 * The generic `N` type for the template node is narrowed internally for certain operations, as the
27 * compiler operations required to implement completion may be different for different node types.
28 *
29 * @param N type of the template node in question, narrowed accordingly.
30 */
31export declare class CompletionBuilder<N extends TmplAstNode | AST> {
32 private readonly tsLS;
33 private readonly compiler;
34 private readonly component;
35 private readonly node;
36 private readonly nodeContext;
37 private readonly nodeParent;
38 private readonly template;
39 private readonly typeChecker;
40 private readonly templateTypeChecker;
41 constructor(tsLS: ts.LanguageService, compiler: NgCompiler, component: ts.ClassDeclaration, node: N, nodeContext: CompletionNodeContext, nodeParent: TmplAstNode | AST | null, template: TmplAstTemplate | null);
42 /**
43 * Analogue for `ts.LanguageService.getCompletionsAtPosition`.
44 */
45 getCompletionsAtPosition(options: ts.GetCompletionsAtPositionOptions | undefined): ts.WithMetadata<ts.CompletionInfo> | undefined;
46 /**
47 * Analogue for `ts.LanguageService.getCompletionEntryDetails`.
48 */
49 getCompletionEntryDetails(entryName: string, formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined, preferences: ts.UserPreferences | undefined): ts.CompletionEntryDetails | undefined;
50 /**
51 * Analogue for `ts.LanguageService.getCompletionEntrySymbol`.
52 */
53 getCompletionEntrySymbol(name: string): ts.Symbol | undefined;
54 /**
55 * Determine if the current node is the completion of a property expression, and narrow the type
56 * of `this.node` if so.
57 *
58 * This narrowing gives access to additional methods related to completion of property
59 * expressions.
60 */
61 private isPropertyExpressionCompletion;
62 /**
63 * Get completions for property expressions.
64 */
65 private getPropertyExpressionCompletion;
66 /**
67 * Get the details of a specific completion for a property expression.
68 */
69 private getPropertyExpressionCompletionDetails;
70 /**
71 * Get the `ts.Symbol` for a specific completion for a property expression.
72 */
73 private getPropertyExpressionCompletionSymbol;
74 /**
75 * Get completions for a property expression in a global context (e.g. `{{y|}}`).
76 */
77 private getGlobalPropertyExpressionCompletion;
78 /**
79 * Get the details of a specific completion for a property expression in a global context (e.g.
80 * `{{y|}}`).
81 */
82 private getGlobalPropertyExpressionCompletionDetails;
83 /**
84 * Get the `ts.Symbol` of a specific completion for a property expression in a global context
85 * (e.g.
86 * `{{y|}}`).
87 */
88 private getGlobalPropertyExpressionCompletionSymbol;
89 private isElementTagCompletion;
90 private getElementTagCompletion;
91 private getElementTagCompletionDetails;
92 private getElementTagCompletionSymbol;
93 private isElementAttributeCompletion;
94 private getElementAttributeCompletions;
95 private getElementAttributeCompletionDetails;
96 private getElementAttributeCompletionSymbol;
97 private isPipeCompletion;
98 private getPipeCompletions;
99}