@angular/language-service 22.0.0-next.5 → 22.0.0-next.6
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/bundles/language-service.js +56 -37
- package/package.json +1 -1
- package/private_bundle.js +2 -6
- package/private_bundle.js.map +1 -1
- package/src/adapters.d.ts +68 -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 +29 -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 +13 -0
- package/src/refactorings/convert_to_signal_input/apply_input_refactoring.d.ts +13 -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 +38 -0
- package/src/refactorings/convert_to_signal_input/individual_input_refactoring.d.ts +39 -0
- package/src/refactorings/convert_to_signal_queries/apply_query_refactoring.d.ts +13 -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 +38 -0
- package/src/refactorings/convert_to_signal_queries/individual_query_refactoring.d.ts +39 -0
- package/src/refactorings/refactoring.d.ts +45 -0
- package/src/references_and_rename.d.ts +28 -0
- package/src/references_and_rename_utils.d.ts +72 -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 +89 -0
- package/src/utils/ts_utils.d.ts +141 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export declare class ReferencesBuilder {
|
|
4
|
+
private readonly tsLS;
|
|
5
|
+
private readonly compiler;
|
|
6
|
+
private readonly ttc;
|
|
7
|
+
constructor(tsLS: ts.LanguageService, compiler: NgCompiler);
|
|
8
|
+
getReferencesAtPosition(filePath: string, position: number): ts.ReferenceEntry[] | undefined;
|
|
9
|
+
private getReferencesAtTemplatePosition;
|
|
10
|
+
private getReferencesAtTypescriptPosition;
|
|
11
|
+
}
|
|
12
|
+
export declare class RenameBuilder {
|
|
13
|
+
private readonly tsLS;
|
|
14
|
+
private readonly compiler;
|
|
15
|
+
private readonly ttc;
|
|
16
|
+
constructor(tsLS: ts.LanguageService, compiler: NgCompiler);
|
|
17
|
+
getRenameInfo(filePath: string, position: number): Omit<ts.RenameInfoSuccess, 'kind' | 'kindModifiers'> | ts.RenameInfoFailure;
|
|
18
|
+
findRenameLocations(filePath: string, position: number): readonly ts.RenameLocation[] | null;
|
|
19
|
+
private findRenameLocationsAtTemplatePosition;
|
|
20
|
+
private findRenameLocationsAtTypescriptPosition;
|
|
21
|
+
private getTsNodeAtPosition;
|
|
22
|
+
private buildRenameRequestsFromTemplateDetails;
|
|
23
|
+
private buildRenameRequestAtTypescriptPosition;
|
|
24
|
+
private buildPipeRenameRequest;
|
|
25
|
+
private buildSelectorlessRenameRequest;
|
|
26
|
+
/** Gets the rename locations for a selectorless request. */
|
|
27
|
+
private getSelectorlessRenameLocations;
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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, TmplAstNode, TmplAstComponent, TmplAstDirective, TmplAstRecursiveVisitor } from '@angular/compiler';
|
|
9
|
+
import { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
|
|
10
|
+
import { DirectiveMeta, PipeMeta } from '@angular/compiler-cli/src/ngtsc/metadata';
|
|
11
|
+
import { Symbol, TemplateTypeChecker } from '@angular/compiler-cli/src/ngtsc/typecheck/api';
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
import { TypeCheckInfo } from './utils';
|
|
14
|
+
/** Represents a location in a file. */
|
|
15
|
+
export interface FilePosition {
|
|
16
|
+
fileName: string;
|
|
17
|
+
position: number;
|
|
18
|
+
}
|
|
19
|
+
export interface TemplateLocationDetails {
|
|
20
|
+
/**
|
|
21
|
+
* A target node in a template.
|
|
22
|
+
*/
|
|
23
|
+
templateTarget: TmplAstNode | AST;
|
|
24
|
+
/**
|
|
25
|
+
* TypeScript locations which the template node maps to. A given template node might map to
|
|
26
|
+
* several TS nodes. For example, a template node for an attribute might resolve to several
|
|
27
|
+
* directives or a directive and one of its inputs.
|
|
28
|
+
*/
|
|
29
|
+
typescriptLocations: FilePosition[];
|
|
30
|
+
/**
|
|
31
|
+
* The resolved Symbol for the template target.
|
|
32
|
+
*/
|
|
33
|
+
symbol: Symbol;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Takes a position in a template and finds equivalent targets in TS files as well as details about
|
|
37
|
+
* the targeted template node.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getTargetDetailsAtTemplatePosition(info: TypeCheckInfo, position: number, templateTypeChecker: TemplateTypeChecker): TemplateLocationDetails[] | null;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a "key" for a rename/reference location by concatenating file name, span start, and span
|
|
42
|
+
* length. This allows us to de-duplicate template results when an item may appear several times
|
|
43
|
+
* in the TCB but map back to the same template location.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createLocationKey(ds: ts.DocumentSpan): string;
|
|
46
|
+
/**
|
|
47
|
+
* Converts a given `ts.DocumentSpan` in a shim file to its equivalent `ts.DocumentSpan` in the
|
|
48
|
+
* template.
|
|
49
|
+
*
|
|
50
|
+
* You can optionally provide a `requiredNodeText` that ensures the equivalent template node's text
|
|
51
|
+
* matches. If it does not, this function will return `null`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function convertToTemplateDocumentSpan<T extends ts.DocumentSpan>(shimDocumentSpan: T, templateTypeChecker: TemplateTypeChecker, program: ts.Program, requiredNodeText?: string): T | null;
|
|
54
|
+
/**
|
|
55
|
+
* Finds the text and `ts.TextSpan` for the node at a position in a template.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getRenameTextAndSpanAtPosition(node: TmplAstNode | AST, position: number): {
|
|
58
|
+
text: string;
|
|
59
|
+
span: ts.TextSpan;
|
|
60
|
+
} | null;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the `PipeMeta` or `DirectiveMeta` of the given `ts.Node`'s parent class.
|
|
63
|
+
*
|
|
64
|
+
* Returns `null` if the node has no parent class or there is no meta associated with the class.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getParentClassMeta(requestNode: ts.Node, compiler: NgCompiler): PipeMeta | DirectiveMeta | null;
|
|
67
|
+
/** Visitor that collects all selectorless AST nodes from a template. */
|
|
68
|
+
export declare class SelectorlessCollector extends TmplAstRecursiveVisitor {
|
|
69
|
+
private nodes;
|
|
70
|
+
static getSelectorlessNodes(nodes: TmplAstNode[]): (TmplAstComponent | TmplAstDirective)[];
|
|
71
|
+
visit(node: TmplAstNode): void;
|
|
72
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
import { TypeCheckInfo } from './utils';
|
|
11
|
+
/**
|
|
12
|
+
* see https://github.com/microsoft/TypeScript/blob/c85e626d8e17427a6865521737b45ccbbe9c78ef/src/services/classifier2020.ts#L49
|
|
13
|
+
*/
|
|
14
|
+
export declare const enum TokenEncodingConsts {
|
|
15
|
+
typeOffset = 8,
|
|
16
|
+
modifierMask = 255
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Token types extended from TypeScript
|
|
20
|
+
* see https://github.com/microsoft/TypeScript/blob/c85e626d8e17427a6865521737b45ccbbe9c78ef/src/services/classifier2020.ts#L55
|
|
21
|
+
*/
|
|
22
|
+
export declare const enum TokenType {
|
|
23
|
+
class = 0,
|
|
24
|
+
enum = 1,
|
|
25
|
+
interface = 2,
|
|
26
|
+
namespace = 3,
|
|
27
|
+
typeParameter = 4,
|
|
28
|
+
type = 5,
|
|
29
|
+
parameter = 6,
|
|
30
|
+
variable = 7,
|
|
31
|
+
enumMember = 8,
|
|
32
|
+
property = 9,
|
|
33
|
+
function = 10,
|
|
34
|
+
member = 11
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Token modifiers extended from TypeScript
|
|
38
|
+
* see https://github.com/microsoft/TypeScript/blob/c85e626d8e17427a6865521737b45ccbbe9c78ef/src/services/classifier2020.ts#L71
|
|
39
|
+
*/
|
|
40
|
+
export declare const enum TokenModifier {
|
|
41
|
+
declaration = 0,
|
|
42
|
+
static = 1,
|
|
43
|
+
async = 2,
|
|
44
|
+
readonly = 3,
|
|
45
|
+
defaultLibrary = 4,
|
|
46
|
+
local = 5
|
|
47
|
+
}
|
|
48
|
+
export declare function getClassificationsForTemplate(compiler: NgCompiler, typeCheckInfo: TypeCheckInfo, range: ts.TextSpan): ts.Classifications;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
/**
|
|
11
|
+
* Queries the TypeScript Language Service to get signature help for a template position.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getSignatureHelp(compiler: NgCompiler, tsLS: ts.LanguageService, fileName: string, position: number, options: ts.SignatureHelpItemsOptions | undefined): ts.SignatureHelpItems | undefined;
|
|
@@ -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/src/ngtsc/reflection';
|
|
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, VariableSymbol } from '@angular/compiler-cli/src/ngtsc/typecheck/api';
|
|
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): 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,89 @@
|
|
|
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 { NgCompiler } from '@angular/compiler-cli/src/ngtsc/core';
|
|
10
|
+
import { AbsoluteFsPath } from '@angular/compiler-cli/src/ngtsc/file_system';
|
|
11
|
+
import { DirectiveSymbol, TemplateTypeChecker } from '@angular/compiler-cli/src/ngtsc/typecheck/api';
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
import { DisplayInfoKind } from './display_parts';
|
|
14
|
+
export declare function getTextSpanOfNode(node: TmplAstNode | AST): ts.TextSpan;
|
|
15
|
+
export declare function toTextSpan(span: AbsoluteSourceSpan | ParseSourceSpan | ParseSpan): ts.TextSpan;
|
|
16
|
+
interface NodeWithKeyAndValue extends TmplAstNode {
|
|
17
|
+
keySpan: ParseSourceSpan;
|
|
18
|
+
valueSpan?: ParseSourceSpan;
|
|
19
|
+
}
|
|
20
|
+
export declare function isTemplateNodeWithKeyAndValue(node: TmplAstNode | AST): node is NodeWithKeyAndValue;
|
|
21
|
+
export declare function isWithinKey(position: number, node: NodeWithKeyAndValue): boolean;
|
|
22
|
+
export declare function isWithinKeyValue(position: number, node: NodeWithKeyAndValue): boolean;
|
|
23
|
+
export declare function isTemplateNode(node: TmplAstNode | AST): node is TmplAstNode;
|
|
24
|
+
export declare function isExpressionNode(node: TmplAstNode | AST): node is AST;
|
|
25
|
+
export interface TypeCheckInfo {
|
|
26
|
+
nodes: TmplAstNode[];
|
|
27
|
+
declaration: ts.ClassDeclaration;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the `ts.ClassDeclaration` at a location along with its template AST nodes.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTypeCheckInfoAtPosition(fileName: string, position: number, compiler: NgCompiler): TypeCheckInfo | undefined;
|
|
33
|
+
export declare function getFirstComponentForTemplateFile(fileName: string, compiler: NgCompiler): TypeCheckInfo | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Given an element or template, determines which directives match because the tag is present. For
|
|
36
|
+
* example, if a directive selector is `div[myAttr]`, this would match div elements but would not if
|
|
37
|
+
* the selector were just `[myAttr]`. We find which directives are applied because of this tag by
|
|
38
|
+
* elimination: compare the directive matches with the tag present against the directive matches
|
|
39
|
+
* without it. The difference would be the directives which match because the tag is present.
|
|
40
|
+
*
|
|
41
|
+
* @param element The element or template node that the attribute/tag is part of.
|
|
42
|
+
* @param directives The list of directives to match against.
|
|
43
|
+
* @returns The list of directives matching the tag name via the strategy described above.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getDirectiveMatchesForElementTag<T extends {
|
|
46
|
+
selector: string | null;
|
|
47
|
+
}>(element: TmplAstTemplate | TmplAstElement, directives: T[]): Set<T>;
|
|
48
|
+
export declare function makeElementSelector(element: TmplAstElement | TmplAstTemplate): string;
|
|
49
|
+
/**
|
|
50
|
+
* Given an attribute name, determines which directives match because the attribute is present. We
|
|
51
|
+
* find which directives are applied because of this attribute by elimination: compare the directive
|
|
52
|
+
* matches with the attribute present against the directive matches without it. The difference would
|
|
53
|
+
* be the directives which match because the attribute is present.
|
|
54
|
+
*
|
|
55
|
+
* @param name The name of the attribute
|
|
56
|
+
* @param hostNode The node which the attribute appears on
|
|
57
|
+
* @param directives The list of directives to match against.
|
|
58
|
+
* @returns The list of directives matching the tag name via the strategy described above.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getDirectiveMatchesForAttribute(name: string, hostNode: TmplAstTemplate | TmplAstElement, directives: DirectiveSymbol[]): Set<DirectiveSymbol>;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new `ts.SymbolDisplayPart` array which has the alias imports from the tcb filtered
|
|
63
|
+
* out, i.e. `i0.NgForOf`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function filterAliasImports(displayParts: ts.SymbolDisplayPart[]): ts.SymbolDisplayPart[];
|
|
66
|
+
export declare function isDollarEvent(n: TmplAstNode | AST): n is PropertyRead;
|
|
67
|
+
export declare function isTypeScriptFile(fileName: string): boolean;
|
|
68
|
+
export declare function isExternalTemplate(fileName: string): boolean;
|
|
69
|
+
export declare function isWithin(position: number, span: AbsoluteSourceSpan | ParseSourceSpan): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* For a given location in a shim file, retrieves the corresponding file url for the template and
|
|
72
|
+
* the span in the template.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getTemplateLocationFromTcbLocation(templateTypeChecker: TemplateTypeChecker, tcbPath: AbsoluteFsPath, tcbIsShim: boolean, positionInFile: number): {
|
|
75
|
+
templateUrl: AbsoluteFsPath;
|
|
76
|
+
span: ParseSourceSpan;
|
|
77
|
+
} | null;
|
|
78
|
+
export declare function isBoundEventWithSyntheticHandler(event: TmplAstBoundEvent): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Construct a QuickInfo object taking into account its container and type.
|
|
81
|
+
* @param name Name of the QuickInfo target
|
|
82
|
+
* @param kind component, directive, pipe, etc.
|
|
83
|
+
* @param textSpan span of the target
|
|
84
|
+
* @param containerName either the Symbol's container or the NgModule that contains the directive
|
|
85
|
+
* @param type user-friendly name of the type
|
|
86
|
+
* @param documentation docstring or comment
|
|
87
|
+
*/
|
|
88
|
+
export declare function createQuickInfo(name: string, kind: DisplayInfoKind, textSpan: ts.TextSpan, containerName?: string, type?: string, documentation?: ts.SymbolDisplayPart[], tags?: ts.JSDocTagInfo[]): ts.QuickInfo;
|
|
89
|
+
export {};
|