@angular/language-service 22.0.0-next.1 → 22.0.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.d.ts +271 -0
- package/api_bundle.js +10 -0
- package/api_bundle.js.map +2 -2
- package/bundles/language-service.js +33509 -29720
- package/package.json +6 -2
- package/private.d.ts +8 -0
- package/private_bundle.js +505 -0
- package/private_bundle.js.map +6 -0
- package/src/adapters.d.ts +66 -0
- package/src/attribute_completions.d.ts +195 -0
- package/src/codefixes/all_codefixes_metas.d.ts +9 -0
- package/src/codefixes/code_fixes.d.ts +30 -0
- package/src/codefixes/fix_invalid_banana_in_box.d.ts +12 -0
- package/src/codefixes/fix_missing_import.d.ts +12 -0
- package/src/codefixes/fix_missing_member.d.ts +13 -0
- package/src/codefixes/fix_missing_required_inputs.d.ts +12 -0
- package/src/codefixes/fix_unused_standalone_imports.d.ts +12 -0
- package/src/codefixes/index.d.ts +9 -0
- package/src/codefixes/utils.d.ts +67 -0
- package/src/compiler_factory.d.ts +27 -0
- package/src/completions.d.ts +113 -0
- package/src/definitions.d.ts +28 -0
- package/src/document_symbols.d.ts +20 -0
- package/src/inlay_hints.d.ts +16 -0
- package/src/language_service.d.ts +132 -0
- package/src/linked_editing_range.d.ts +21 -0
- package/src/outlining_spans.d.ts +10 -0
- package/src/quick_info.d.ts +34 -0
- package/src/quick_info_built_ins.d.ts +15 -0
- package/src/refactorings/convert_to_signal_input/apply_input_refactoring.d.ts +12 -0
- package/src/refactorings/convert_to_signal_input/decorators.d.ts +11 -0
- package/src/refactorings/convert_to_signal_input/full_class_input_refactoring.d.ts +37 -0
- package/src/refactorings/convert_to_signal_input/individual_input_refactoring.d.ts +38 -0
- package/src/refactorings/convert_to_signal_queries/apply_query_refactoring.d.ts +12 -0
- package/src/refactorings/convert_to_signal_queries/decorators.d.ts +11 -0
- package/src/refactorings/convert_to_signal_queries/full_class_query_refactoring.d.ts +37 -0
- package/src/refactorings/convert_to_signal_queries/individual_query_refactoring.d.ts +38 -0
- package/src/refactorings/refactoring.d.ts +44 -0
- package/src/references_and_rename.d.ts +28 -0
- package/src/references_and_rename_utils.d.ts +70 -0
- package/src/semantic_tokens.d.ts +48 -0
- package/src/signature_help.d.ts +13 -0
- package/src/template_target.d.ts +178 -0
- package/src/ts_plugin.d.ts +14 -0
- package/src/utils/decorators.d.ts +10 -0
- package/src/utils/display_parts.d.ts +62 -0
- package/src/utils/format.d.ts +17 -0
- package/src/utils/index.d.ts +87 -0
- package/src/utils/ts_utils.d.ts +138 -0
|
@@ -0,0 +1,178 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { AST, Call, SafeCall, TmplAstBoundAttribute, TmplAstBoundEvent, TmplAstComponent, TmplAstDirective, TmplAstElement, TmplAstNode, TmplAstTemplate, TmplAstTextAttribute } from '@angular/compiler';
|
|
9
|
+
import tss from 'typescript';
|
|
10
|
+
/**
|
|
11
|
+
* Contextual information for a target position within the template.
|
|
12
|
+
*/
|
|
13
|
+
export interface TemplateTarget {
|
|
14
|
+
/**
|
|
15
|
+
* Target position within the template.
|
|
16
|
+
*/
|
|
17
|
+
position: number;
|
|
18
|
+
/**
|
|
19
|
+
* The template (or AST expression) node or nodes closest to the search position.
|
|
20
|
+
*/
|
|
21
|
+
context: TargetContext;
|
|
22
|
+
/**
|
|
23
|
+
* The `TmplAstTemplate` which contains the found node or expression (or `null` if in the root
|
|
24
|
+
* template).
|
|
25
|
+
*/
|
|
26
|
+
template: TmplAstTemplate | null;
|
|
27
|
+
/**
|
|
28
|
+
* The immediate parent node of the targeted node.
|
|
29
|
+
*/
|
|
30
|
+
parent: TmplAstNode | AST | null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A node or nodes targeted at a given position in the template, including potential contextual
|
|
34
|
+
* information about the specific aspect of the node being referenced.
|
|
35
|
+
*
|
|
36
|
+
* Some nodes have multiple interior contexts. For example, `TmplAstElement` nodes have both a tag
|
|
37
|
+
* name as well as a body, and a given position definitively points to one or the other.
|
|
38
|
+
* `TargetNode` captures the node itself, as well as this additional contextual disambiguation.
|
|
39
|
+
*/
|
|
40
|
+
export type TargetContext = SingleNodeTarget | MultiNodeTarget;
|
|
41
|
+
/** Contexts which logically target only a single node in the template AST. */
|
|
42
|
+
export type SingleNodeTarget = RawExpression | CallExpressionInArgContext | RawTemplateNode | ElementInBodyContext | ElementInTagContext | AttributeInKeyContext | AttributeInValueContext | ComponentInBodyContext | ComponentInTagContext | DirectiveInNameContext | DirectiveInBodyContext;
|
|
43
|
+
/**
|
|
44
|
+
* Contexts which logically target multiple nodes in the template AST, which cannot be
|
|
45
|
+
* disambiguated given a single position because they are all equally relevant. For example, in the
|
|
46
|
+
* banana-in-a-box syntax `[(ngModel)]="formValues.person"`, the position in the template for the
|
|
47
|
+
* key `ngModel` refers to both the bound event `ngModelChange` and the input `ngModel`.
|
|
48
|
+
*/
|
|
49
|
+
export type MultiNodeTarget = TwoWayBindingContext;
|
|
50
|
+
/**
|
|
51
|
+
* Differentiates the various kinds of `TargetNode`s.
|
|
52
|
+
*/
|
|
53
|
+
export declare enum TargetNodeKind {
|
|
54
|
+
RawExpression = 0,
|
|
55
|
+
CallExpressionInArgContext = 1,
|
|
56
|
+
RawTemplateNode = 2,
|
|
57
|
+
ElementInTagContext = 3,
|
|
58
|
+
ElementInBodyContext = 4,
|
|
59
|
+
AttributeInKeyContext = 5,
|
|
60
|
+
AttributeInValueContext = 6,
|
|
61
|
+
TwoWayBindingContext = 7,
|
|
62
|
+
ComponentInTagContext = 8,
|
|
63
|
+
ComponentInBodyContext = 9,
|
|
64
|
+
DirectiveInNameContext = 10,
|
|
65
|
+
DirectiveInBodyContext = 11
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* An `AST` expression that's targeted at a given position, with no additional context.
|
|
69
|
+
*/
|
|
70
|
+
export interface RawExpression {
|
|
71
|
+
kind: TargetNodeKind.RawExpression;
|
|
72
|
+
node: AST;
|
|
73
|
+
parents: AST[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An `e.Call` expression with the cursor in a position where an argument could appear.
|
|
77
|
+
*
|
|
78
|
+
* This is returned when the only matching node is the method call expression, but the cursor is
|
|
79
|
+
* within the method call parentheses. For example, in the expression `foo(|)` there is no argument
|
|
80
|
+
* expression that the cursor could be targeting, but the cursor is in a position where one could
|
|
81
|
+
* appear.
|
|
82
|
+
*/
|
|
83
|
+
export interface CallExpressionInArgContext {
|
|
84
|
+
kind: TargetNodeKind.CallExpressionInArgContext;
|
|
85
|
+
node: Call | SafeCall;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A `TmplAstNode` template node that's targeted at a given position, with no additional context.
|
|
89
|
+
*/
|
|
90
|
+
export interface RawTemplateNode {
|
|
91
|
+
kind: TargetNodeKind.RawTemplateNode;
|
|
92
|
+
node: TmplAstNode;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A `TmplAstElement` (or `TmplAstTemplate`) element node that's targeted, where the given position
|
|
96
|
+
* is within the tag name.
|
|
97
|
+
*/
|
|
98
|
+
export interface ElementInTagContext {
|
|
99
|
+
kind: TargetNodeKind.ElementInTagContext;
|
|
100
|
+
node: TmplAstElement | TmplAstTemplate;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A `TmplAstElement` (or `TmplAstTemplate`) element node that's targeted, where the given position
|
|
104
|
+
* is within the element body.
|
|
105
|
+
*/
|
|
106
|
+
export interface ElementInBodyContext {
|
|
107
|
+
kind: TargetNodeKind.ElementInBodyContext;
|
|
108
|
+
node: TmplAstElement | TmplAstTemplate;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A `TmplAstComponent` element node that's targeted, where the given position is within the tag,
|
|
112
|
+
* e.g. `MyComp` in `<MyComp foo="bar"/>`.
|
|
113
|
+
*/
|
|
114
|
+
export interface ComponentInTagContext {
|
|
115
|
+
kind: TargetNodeKind.ComponentInTagContext;
|
|
116
|
+
node: TmplAstComponent;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A `TmplAstComponent` element node that's targeted, where the given position is within the body,
|
|
120
|
+
* e.g. `foo="bar"/>` in `<MyComp foo="bar"/>`.
|
|
121
|
+
*/
|
|
122
|
+
export interface ComponentInBodyContext {
|
|
123
|
+
kind: TargetNodeKind.ComponentInBodyContext;
|
|
124
|
+
node: TmplAstComponent;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A `TmplAstDirective` element node that's targeted, where the given position is within the
|
|
128
|
+
* directive's name (e.g. `MyDir` in `@MyDir`).
|
|
129
|
+
*/
|
|
130
|
+
export interface DirectiveInNameContext {
|
|
131
|
+
kind: TargetNodeKind.DirectiveInNameContext;
|
|
132
|
+
node: TmplAstDirective;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A `TmplAstDirective` element node that's targeted, where the given position is within the body,
|
|
136
|
+
* e.g. `(foo="bar")` in `@MyDir(foo="bar")`.
|
|
137
|
+
*/
|
|
138
|
+
export interface DirectiveInBodyContext {
|
|
139
|
+
kind: TargetNodeKind.DirectiveInBodyContext;
|
|
140
|
+
node: TmplAstDirective;
|
|
141
|
+
}
|
|
142
|
+
export interface AttributeInKeyContext {
|
|
143
|
+
kind: TargetNodeKind.AttributeInKeyContext;
|
|
144
|
+
node: TmplAstTextAttribute | TmplAstBoundAttribute | TmplAstBoundEvent;
|
|
145
|
+
}
|
|
146
|
+
export interface AttributeInValueContext {
|
|
147
|
+
kind: TargetNodeKind.AttributeInValueContext;
|
|
148
|
+
node: TmplAstTextAttribute | TmplAstBoundAttribute | TmplAstBoundEvent;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A `TmplAstBoundAttribute` and `TmplAstBoundEvent` pair that are targeted, where the given
|
|
152
|
+
* position is within the key span of both.
|
|
153
|
+
*/
|
|
154
|
+
export interface TwoWayBindingContext {
|
|
155
|
+
kind: TargetNodeKind.TwoWayBindingContext;
|
|
156
|
+
nodes: [TmplAstBoundAttribute, TmplAstBoundEvent];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Return the template AST node or expression AST node that most accurately
|
|
160
|
+
* represents the node at the specified cursor `position`.
|
|
161
|
+
*
|
|
162
|
+
* @param template AST tree of the template
|
|
163
|
+
* @param position target cursor position
|
|
164
|
+
*/
|
|
165
|
+
export declare function getTargetAtPosition(template: TmplAstNode[], position: number): TemplateTarget | null;
|
|
166
|
+
/**
|
|
167
|
+
* A tcb nodes for the template at a given position, include the tcb node of the template.
|
|
168
|
+
*/
|
|
169
|
+
interface TcbNodesInfoForTemplate {
|
|
170
|
+
componentTcbNode: tss.Node;
|
|
171
|
+
nodes: tss.Node[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Return the nodes in `TCB` of the node at the specified cursor `position`.
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
export declare function getTcbNodesOfTemplateAtPosition(templateNodes: TmplAstNode[], position: number, tcb: tss.Node): TcbNodesInfoForTemplate | null;
|
|
178
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type ts from 'typescript';
|
|
9
|
+
import { NgLanguageService } from '../api';
|
|
10
|
+
export declare function create(info: ts.server.PluginCreateInfo): NgLanguageService;
|
|
11
|
+
/** Implementation of a ts.server.PluginModuleFactory */
|
|
12
|
+
export declare function initialize(mod: {
|
|
13
|
+
typescript: typeof ts;
|
|
14
|
+
}): ts.server.PluginModule;
|
|
@@ -0,0 +1,10 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import type ts from 'typescript';
|
|
9
|
+
import { ReflectionHost } from '@angular/compiler-cli';
|
|
10
|
+
export declare function isDirectiveOrComponent(node: ts.ClassDeclaration, reflector: ReflectionHost): boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { LetDeclarationSymbol, PotentialDirective, ReferenceSymbol, TemplateTypeChecker, VariableSymbol } from '@angular/compiler-cli';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
export declare const ALIAS_NAME: string;
|
|
11
|
+
export declare const SYMBOL_INTERFACE: string;
|
|
12
|
+
export declare const SYMBOL_PUNC: string;
|
|
13
|
+
export declare const SYMBOL_SPACE: string;
|
|
14
|
+
export declare const SYMBOL_TEXT: string;
|
|
15
|
+
/**
|
|
16
|
+
* Label for various kinds of Angular entities for TS display info.
|
|
17
|
+
*/
|
|
18
|
+
export declare enum DisplayInfoKind {
|
|
19
|
+
ATTRIBUTE = "attribute",
|
|
20
|
+
BLOCK = "block",
|
|
21
|
+
TRIGGER = "trigger",
|
|
22
|
+
COMPONENT = "component",
|
|
23
|
+
DIRECTIVE = "directive",
|
|
24
|
+
EVENT = "event",
|
|
25
|
+
REFERENCE = "reference",
|
|
26
|
+
ELEMENT = "element",
|
|
27
|
+
VARIABLE = "variable",
|
|
28
|
+
PIPE = "pipe",
|
|
29
|
+
PROPERTY = "property",
|
|
30
|
+
METHOD = "method",
|
|
31
|
+
TEMPLATE = "template",
|
|
32
|
+
KEYWORD = "keyword",
|
|
33
|
+
LET = "let"
|
|
34
|
+
}
|
|
35
|
+
export interface DisplayInfo {
|
|
36
|
+
kind: DisplayInfoKind;
|
|
37
|
+
displayParts: ts.SymbolDisplayPart[];
|
|
38
|
+
documentation: ts.SymbolDisplayPart[] | undefined;
|
|
39
|
+
tags: ts.JSDocTagInfo[] | undefined;
|
|
40
|
+
}
|
|
41
|
+
export declare function getSymbolDisplayInfo(tsLS: ts.LanguageService, typeChecker: ts.TypeChecker, symbol: ReferenceSymbol | VariableSymbol | LetDeclarationSymbol, templateTypeChecker: TemplateTypeChecker): DisplayInfo;
|
|
42
|
+
/**
|
|
43
|
+
* Construct a compound `ts.SymbolDisplayPart[]` which incorporates the container and type of a
|
|
44
|
+
* target declaration.
|
|
45
|
+
* @param name Name of the target
|
|
46
|
+
* @param kind component, directive, pipe, etc.
|
|
47
|
+
* @param containerName either the Symbol's container or the NgModule that contains the directive
|
|
48
|
+
* @param type user-friendly name of the type
|
|
49
|
+
* @param documentation docstring or comment
|
|
50
|
+
*/
|
|
51
|
+
export declare function createDisplayParts(name: string, kind: DisplayInfoKind, containerName: string | undefined, type: string | undefined): ts.SymbolDisplayPart[];
|
|
52
|
+
/**
|
|
53
|
+
* Convert a `SymbolDisplayInfoKind` to a `ts.ScriptElementKind` type, allowing it to pass through
|
|
54
|
+
* TypeScript APIs.
|
|
55
|
+
*
|
|
56
|
+
* In practice, this is an "illegal" type cast. Since `ts.ScriptElementKind` is a string, this is
|
|
57
|
+
* safe to do if TypeScript only uses the value in a string context. Consumers of this conversion
|
|
58
|
+
* function are responsible for ensuring this is the case.
|
|
59
|
+
*/
|
|
60
|
+
export declare function unsafeCastDisplayInfoKindToScriptElementKind(kind: DisplayInfoKind): ts.ScriptElementKind;
|
|
61
|
+
export declare function getDirectiveDisplayInfo(tsLS: ts.LanguageService, dir: PotentialDirective): DisplayInfo;
|
|
62
|
+
export declare function getTsSymbolDisplayInfo(tsLS: ts.LanguageService, checker: ts.TypeChecker, symbol: ts.Symbol, kind: DisplayInfoKind, ownerName: string | null): DisplayInfo | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import ts from 'typescript';
|
|
9
|
+
/**
|
|
10
|
+
* Try to guess the indentation of the node.
|
|
11
|
+
*
|
|
12
|
+
* This function returns the indentation only if the start character of this node is
|
|
13
|
+
* the first non-whitespace character in a line where the node is, otherwise,
|
|
14
|
+
* it returns `undefined`. When computing the start of the node, it should include
|
|
15
|
+
* the leading comments.
|
|
16
|
+
*/
|
|
17
|
+
export declare function guessIndentationInSingleLine(node: ts.Node, sourceFile: ts.SourceFile): number | undefined;
|
|
@@ -0,0 +1,87 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { AbsoluteSourceSpan, AST, ParseSourceSpan, ParseSpan, PropertyRead, TmplAstBoundEvent, TmplAstElement, TmplAstNode, TmplAstTemplate } from '@angular/compiler';
|
|
9
|
+
import { AbsoluteFsPath, DirectiveSymbol, NgCompiler, TemplateTypeChecker } from '@angular/compiler-cli';
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import { DisplayInfoKind } from './display_parts';
|
|
12
|
+
export declare function getTextSpanOfNode(node: TmplAstNode | AST): ts.TextSpan;
|
|
13
|
+
export declare function toTextSpan(span: AbsoluteSourceSpan | ParseSourceSpan | ParseSpan): ts.TextSpan;
|
|
14
|
+
interface NodeWithKeyAndValue extends TmplAstNode {
|
|
15
|
+
keySpan: ParseSourceSpan;
|
|
16
|
+
valueSpan?: ParseSourceSpan;
|
|
17
|
+
}
|
|
18
|
+
export declare function isTemplateNodeWithKeyAndValue(node: TmplAstNode | AST): node is NodeWithKeyAndValue;
|
|
19
|
+
export declare function isWithinKey(position: number, node: NodeWithKeyAndValue): boolean;
|
|
20
|
+
export declare function isWithinKeyValue(position: number, node: NodeWithKeyAndValue): boolean;
|
|
21
|
+
export declare function isTemplateNode(node: TmplAstNode | AST): node is TmplAstNode;
|
|
22
|
+
export declare function isExpressionNode(node: TmplAstNode | AST): node is AST;
|
|
23
|
+
export interface TypeCheckInfo {
|
|
24
|
+
nodes: TmplAstNode[];
|
|
25
|
+
declaration: ts.ClassDeclaration;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the `ts.ClassDeclaration` at a location along with its template AST nodes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getTypeCheckInfoAtPosition(fileName: string, position: number, compiler: NgCompiler): TypeCheckInfo | undefined;
|
|
31
|
+
export declare function getFirstComponentForTemplateFile(fileName: string, compiler: NgCompiler): TypeCheckInfo | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Given an element or template, determines which directives match because the tag is present. For
|
|
34
|
+
* example, if a directive selector is `div[myAttr]`, this would match div elements but would not if
|
|
35
|
+
* the selector were just `[myAttr]`. We find which directives are applied because of this tag by
|
|
36
|
+
* elimination: compare the directive matches with the tag present against the directive matches
|
|
37
|
+
* without it. The difference would be the directives which match because the tag is present.
|
|
38
|
+
*
|
|
39
|
+
* @param element The element or template node that the attribute/tag is part of.
|
|
40
|
+
* @param directives The list of directives to match against.
|
|
41
|
+
* @returns The list of directives matching the tag name via the strategy described above.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getDirectiveMatchesForElementTag<T extends {
|
|
44
|
+
selector: string | null;
|
|
45
|
+
}>(element: TmplAstTemplate | TmplAstElement, directives: T[]): Set<T>;
|
|
46
|
+
export declare function makeElementSelector(element: TmplAstElement | TmplAstTemplate): string;
|
|
47
|
+
/**
|
|
48
|
+
* Given an attribute name, determines which directives match because the attribute is present. We
|
|
49
|
+
* find which directives are applied because of this attribute by elimination: compare the directive
|
|
50
|
+
* matches with the attribute present against the directive matches without it. The difference would
|
|
51
|
+
* be the directives which match because the attribute is present.
|
|
52
|
+
*
|
|
53
|
+
* @param name The name of the attribute
|
|
54
|
+
* @param hostNode The node which the attribute appears on
|
|
55
|
+
* @param directives The list of directives to match against.
|
|
56
|
+
* @returns The list of directives matching the tag name via the strategy described above.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getDirectiveMatchesForAttribute(name: string, hostNode: TmplAstTemplate | TmplAstElement, directives: DirectiveSymbol[]): Set<DirectiveSymbol>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a new `ts.SymbolDisplayPart` array which has the alias imports from the tcb filtered
|
|
61
|
+
* out, i.e. `i0.NgForOf`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function filterAliasImports(displayParts: ts.SymbolDisplayPart[]): ts.SymbolDisplayPart[];
|
|
64
|
+
export declare function isDollarEvent(n: TmplAstNode | AST): n is PropertyRead;
|
|
65
|
+
export declare function isTypeScriptFile(fileName: string): boolean;
|
|
66
|
+
export declare function isExternalTemplate(fileName: string): boolean;
|
|
67
|
+
export declare function isWithin(position: number, span: AbsoluteSourceSpan | ParseSourceSpan): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* For a given location in a shim file, retrieves the corresponding file url for the template and
|
|
70
|
+
* the span in the template.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getTemplateLocationFromTcbLocation(templateTypeChecker: TemplateTypeChecker, tcbPath: AbsoluteFsPath, tcbIsShim: boolean, positionInFile: number): {
|
|
73
|
+
templateUrl: AbsoluteFsPath;
|
|
74
|
+
span: ParseSourceSpan;
|
|
75
|
+
} | null;
|
|
76
|
+
export declare function isBoundEventWithSyntheticHandler(event: TmplAstBoundEvent): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Construct a QuickInfo object taking into account its container and type.
|
|
79
|
+
* @param name Name of the QuickInfo target
|
|
80
|
+
* @param kind component, directive, pipe, etc.
|
|
81
|
+
* @param textSpan span of the target
|
|
82
|
+
* @param containerName either the Symbol's container or the NgModule that contains the directive
|
|
83
|
+
* @param type user-friendly name of the type
|
|
84
|
+
* @param documentation docstring or comment
|
|
85
|
+
*/
|
|
86
|
+
export declare function createQuickInfo(name: string, kind: DisplayInfoKind, textSpan: ts.TextSpan, containerName?: string, type?: string, documentation?: ts.SymbolDisplayPart[], tags?: ts.JSDocTagInfo[]): ts.QuickInfo;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { NgCompiler, PotentialDirective, PotentialPipe, SymbolReference, TemplateTypeChecker } from '@angular/compiler-cli';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
/**
|
|
4
|
+
* Return the node that most tightly encompasses the specified `position`.
|
|
5
|
+
* @param node The starting node to start the top-down search.
|
|
6
|
+
* @param position The target position within the `node`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function findTightestNode(node: ts.Node, position: number): ts.Node | undefined;
|
|
9
|
+
export interface FindOptions<T extends ts.Node> {
|
|
10
|
+
filter: (node: ts.Node) => node is T;
|
|
11
|
+
position?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Finds TypeScript nodes descending from the provided root which match the given filter.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findAllMatchingNodes<T extends ts.Node>(root: ts.Node, opts: FindOptions<T>): T[];
|
|
17
|
+
/**
|
|
18
|
+
* Finds TypeScript nodes descending from the provided root which match the given filter.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findFirstMatchingNode<T extends ts.Node>(root: ts.Node, opts: FindOptions<T>): T | null;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves a ClassDeclaration from a SymbolReference.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getClassDeclarationFromSymbolReference(ls: ts.LanguageService, ref: SymbolReference): ts.ClassDeclaration | null;
|
|
25
|
+
export declare function getParentClassDeclaration(startNode: ts.Node): ts.ClassDeclaration | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a property assignment from the assignment value if the property name
|
|
28
|
+
* matches the specified `key`, or `null` if there is no match.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getPropertyAssignmentFromValue(value: ts.Node, key: string): ts.PropertyAssignment | null;
|
|
31
|
+
/**
|
|
32
|
+
* Given a decorator property assignment, return the ClassDeclaration node that corresponds to the
|
|
33
|
+
* directive class the property applies to.
|
|
34
|
+
* If the property assignment is not on a class decorator, no declaration is returned.
|
|
35
|
+
*
|
|
36
|
+
* For example,
|
|
37
|
+
*
|
|
38
|
+
* @Component({
|
|
39
|
+
* template: '<div></div>'
|
|
40
|
+
* ^^^^^^^^^^^^^^^^^^^^^^^---- property assignment
|
|
41
|
+
* })
|
|
42
|
+
* class AppComponent {}
|
|
43
|
+
* ^---- class declaration node
|
|
44
|
+
*
|
|
45
|
+
* @param propAsgnNode property assignment
|
|
46
|
+
*/
|
|
47
|
+
export declare function getClassDeclFromDecoratorProp(propAsgnNode: ts.PropertyAssignment): ts.ClassDeclaration | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Collects all member methods, including those from base classes.
|
|
50
|
+
*/
|
|
51
|
+
export declare function collectMemberMethods(clazz: ts.ClassDeclaration, typeChecker: ts.TypeChecker): ts.MethodDeclaration[];
|
|
52
|
+
/**
|
|
53
|
+
* Given an existing array literal expression, update it by pushing a new expression.
|
|
54
|
+
*/
|
|
55
|
+
export declare function addElementToArrayLiteral(arr: ts.ArrayLiteralExpression, elem: ts.Expression): ts.ArrayLiteralExpression;
|
|
56
|
+
/**
|
|
57
|
+
* Given an ObjectLiteralExpression node, extract and return the PropertyAssignment corresponding to
|
|
58
|
+
* the given key. `null` if no such key exists.
|
|
59
|
+
*/
|
|
60
|
+
export declare function objectPropertyAssignmentForKey(obj: ts.ObjectLiteralExpression, key: string): ts.PropertyAssignment | null;
|
|
61
|
+
/**
|
|
62
|
+
* Given an ObjectLiteralExpression node, create or update the specified key, using the provided
|
|
63
|
+
* callback to generate the new value (possibly based on an old value), and return the `ts.PropertyAssignment`
|
|
64
|
+
* for the key.
|
|
65
|
+
*/
|
|
66
|
+
export declare function updateObjectValueForKey(obj: ts.ObjectLiteralExpression, key: string, newValueFn: (oldValue?: ts.Expression) => ts.Expression): ts.PropertyAssignment;
|
|
67
|
+
/**
|
|
68
|
+
* Create a new ArrayLiteralExpression, or accept an existing one.
|
|
69
|
+
* Ensure the array contains the provided identifier.
|
|
70
|
+
* Returns the array, either updated or newly created.
|
|
71
|
+
* If no update is needed, returns `null`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function ensureArrayWithIdentifier(identifierText: string, expression: ts.Expression, arr?: ts.ArrayLiteralExpression): ts.ArrayLiteralExpression | null;
|
|
74
|
+
/**
|
|
75
|
+
* Determine whether this an import of the given `propertyName` from a particular module
|
|
76
|
+
* specifier already exists. If so, return the local name for that import, which might be an
|
|
77
|
+
* alias.
|
|
78
|
+
*/
|
|
79
|
+
export declare function hasImport(importDeclarations: ts.ImportDeclaration[], propName: string, moduleSpecifier: string): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Transform the given import name into an alias that does not collide with any other import
|
|
82
|
+
* symbol.
|
|
83
|
+
*/
|
|
84
|
+
export declare function nonCollidingImportName(importDeclarations: ts.ImportDeclaration[], name: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* If the provided trait is standalone, just return it. Otherwise, returns the owning ngModule.
|
|
87
|
+
*/
|
|
88
|
+
export declare function standaloneTraitOrNgModule(checker: TemplateTypeChecker, trait: ts.ClassDeclaration): ts.ClassDeclaration | null;
|
|
89
|
+
/**
|
|
90
|
+
* Updates the imports on a TypeScript file, by ensuring the provided import is present.
|
|
91
|
+
* Returns the text changes, as well as the name with which the imported symbol can be referred to.
|
|
92
|
+
*
|
|
93
|
+
* When the component is exported by default, the `symbolName` is `default`, and the `declarationName`
|
|
94
|
+
* should be used as the import name.
|
|
95
|
+
*/
|
|
96
|
+
export declare function updateImportsForTypescriptFile(file: ts.SourceFile, symbolName: string, declarationName: string, moduleSpecifier: string): [ts.TextChange[], string];
|
|
97
|
+
/**
|
|
98
|
+
* Updates a given Angular trait, such as an NgModule or standalone Component, by adding
|
|
99
|
+
* `importName` to the list of imports on the decorator arguments.
|
|
100
|
+
*/
|
|
101
|
+
export declare function updateImportsForAngularTrait(checker: TemplateTypeChecker, trait: ts.ClassDeclaration, importName: string, forwardRefName: string | null): ts.TextChange[];
|
|
102
|
+
/**
|
|
103
|
+
* Return whether a given Angular decorator specifies `standalone: true`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function isStandaloneDecorator(decorator: ts.Decorator): boolean | null;
|
|
106
|
+
/**
|
|
107
|
+
* Generate a new import. Follows the format:
|
|
108
|
+
* ```ts
|
|
109
|
+
* import {exportedSpecifierName as localName} from 'rawModuleSpecifier';
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* If the component is exported by default, follows the format:
|
|
113
|
+
*
|
|
114
|
+
* ```ts
|
|
115
|
+
* import exportedSpecifierName from 'rawModuleSpecifier';
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* If `exportedSpecifierName` is null, or is equal to `name`, then the qualified import alias will
|
|
119
|
+
* be omitted.
|
|
120
|
+
*/
|
|
121
|
+
export declare function generateImport(localName: string, exportedSpecifierName: string | null, rawModuleSpecifier: string): ts.ImportDeclaration;
|
|
122
|
+
/**
|
|
123
|
+
* Update an existing named import with a new member.
|
|
124
|
+
* If `exportedSpecifierName` is null, or is equal to `name`, then the qualified import alias will
|
|
125
|
+
* be omitted.
|
|
126
|
+
* If the `localName` is `default` and `exportedSpecifierName` is not null, the `exportedSpecifierName`
|
|
127
|
+
* is used as the default import name.
|
|
128
|
+
*/
|
|
129
|
+
export declare function updateImport(importDeclaration: ts.ImportDeclaration, localName: string, exportedSpecifierName: string | null): ts.ImportClause | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Print a given TypeScript node into a string. Used to serialize entirely synthetic generated AST,
|
|
132
|
+
* which will not have `.text` or `.fullText` set.
|
|
133
|
+
*/
|
|
134
|
+
export declare function printNode(node: ts.Node, sourceFile: ts.SourceFile): string;
|
|
135
|
+
/**
|
|
136
|
+
* Get the code actions to tell the vscode how to import the directive into the standalone component or ng module.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getCodeActionToImportTheDirectiveDeclaration(compiler: NgCompiler, component: ts.ClassDeclaration, importOn: ts.ClassDeclaration, directive: PotentialDirective | PotentialPipe, tsLs: ts.LanguageService, includeCompletionsForModuleExports?: boolean): ts.CodeAction[] | undefined;
|