@angular/language-service 22.0.0-next.1 → 22.0.0-next.10
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 +30254 -26648
- package/package.json +5 -1
- 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 +13 -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,132 @@
|
|
|
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 { CompilerOptions } from '@angular/compiler-cli';
|
|
9
|
+
import { AngularInlayHint, ApplyRefactoringProgressFn, ApplyRefactoringResult, GetComponentLocationsForTemplateResponse, GetTcbResponse, GetTemplateLocationForComponentResponse, InlayHintsConfig, LinkedEditingRanges, PluginConfig } from '../api';
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import { CompilerFactory } from './compiler_factory';
|
|
12
|
+
import { DocumentSymbolsOptions, TemplateDocumentSymbol } from './document_symbols';
|
|
13
|
+
export declare class LanguageService {
|
|
14
|
+
private readonly project;
|
|
15
|
+
private readonly tsLS;
|
|
16
|
+
private readonly config;
|
|
17
|
+
private options;
|
|
18
|
+
readonly compilerFactory: CompilerFactory;
|
|
19
|
+
private readonly codeFixes;
|
|
20
|
+
private readonly activeRefactorings;
|
|
21
|
+
constructor(project: ts.server.Project, tsLS: ts.LanguageService, config: Omit<PluginConfig, 'angularOnly'>);
|
|
22
|
+
getCompilerOptions(): CompilerOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Triggers the Angular compiler's analysis pipeline without performing
|
|
25
|
+
* per-file type checking.
|
|
26
|
+
*/
|
|
27
|
+
ensureProjectAnalyzed(): void;
|
|
28
|
+
getSemanticDiagnostics(fileName: string): ts.Diagnostic[];
|
|
29
|
+
getSuggestionDiagnostics(fileName: string): ts.DiagnosticWithLocation[];
|
|
30
|
+
getDefinitionAndBoundSpan(fileName: string, position: number): ts.DefinitionInfoAndBoundSpan | undefined;
|
|
31
|
+
getTypeDefinitionAtPosition(fileName: string, position: number): readonly ts.DefinitionInfo[] | undefined;
|
|
32
|
+
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Provide Angular-specific inlay hints for templates.
|
|
35
|
+
*
|
|
36
|
+
* This returns hints for:
|
|
37
|
+
* - @for loop variable types: `@for (user: User of users)`
|
|
38
|
+
* - @if alias types: `@if (data; as result: ApiResult)`
|
|
39
|
+
* - Event parameter types: `(click)="onClick($event: MouseEvent)"`
|
|
40
|
+
* - Pipe output types: `{{ value | async: Observable<T> }}`
|
|
41
|
+
* - @let declaration types
|
|
42
|
+
*
|
|
43
|
+
* @param fileName The file to get inlay hints for
|
|
44
|
+
* @param span The text span to get hints within
|
|
45
|
+
* @param config Optional configuration for which hints to show
|
|
46
|
+
*/
|
|
47
|
+
provideInlayHints(fileName: string, span: ts.TextSpan, config?: InlayHintsConfig): AngularInlayHint[];
|
|
48
|
+
private getQuickInfoAtPositionImpl;
|
|
49
|
+
getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] | undefined;
|
|
50
|
+
getRenameInfo(fileName: string, position: number): ts.RenameInfo;
|
|
51
|
+
findRenameLocations(fileName: string, position: number): readonly ts.RenameLocation[] | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Gets linked editing ranges for synchronized editing of HTML tag pairs.
|
|
54
|
+
*
|
|
55
|
+
* When the cursor is on an element tag name, returns both the opening and closing
|
|
56
|
+
* tag name spans so they can be edited simultaneously.
|
|
57
|
+
*
|
|
58
|
+
* @param fileName The file to check
|
|
59
|
+
* @param position The cursor position in the file
|
|
60
|
+
* @returns LinkedEditingRanges if on a tag name, undefined otherwise
|
|
61
|
+
*/
|
|
62
|
+
getLinkedEditingRangeAtPosition(fileName: string, position: number): LinkedEditingRanges | undefined;
|
|
63
|
+
private getCompletionBuilder;
|
|
64
|
+
getEncodedSemanticClassifications(fileName: string, span: ts.TextSpan, format: ts.SemanticClassificationFormat | undefined): ts.Classifications;
|
|
65
|
+
private getEncodedSemanticClassificationsImpl;
|
|
66
|
+
getTokenTypeFromClassification(classification: number): number | undefined;
|
|
67
|
+
getTokenModifierFromClassification(classification: number): number;
|
|
68
|
+
getCompletionsAtPosition(fileName: string, position: number, options: ts.GetCompletionsAtPositionOptions | undefined): ts.WithMetadata<ts.CompletionInfo> | undefined;
|
|
69
|
+
private getCompletionsAtPositionImpl;
|
|
70
|
+
getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: ts.FormatCodeOptions | ts.FormatCodeSettings | undefined, preferences: ts.UserPreferences | undefined, data: ts.CompletionEntryData | undefined): ts.CompletionEntryDetails | undefined;
|
|
71
|
+
getSignatureHelpItems(fileName: string, position: number, options?: ts.SignatureHelpItemsOptions): ts.SignatureHelpItems | undefined;
|
|
72
|
+
getOutliningSpans(fileName: string): ts.OutliningSpan[];
|
|
73
|
+
/**
|
|
74
|
+
* Gets document symbols for Angular templates, including control flow blocks,
|
|
75
|
+
* elements, components, template references, and @let declarations.
|
|
76
|
+
* Returns symbols in NavigationTree format for compatibility with TypeScript.
|
|
77
|
+
*
|
|
78
|
+
* @param fileName The file path to get template symbols for
|
|
79
|
+
* @param options Optional configuration for document symbols behavior
|
|
80
|
+
*/
|
|
81
|
+
getTemplateDocumentSymbols(fileName: string, options?: DocumentSymbolsOptions): TemplateDocumentSymbol[];
|
|
82
|
+
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Performance helper that can help make quick decisions for
|
|
85
|
+
* the VSCode language server to decide whether a code fix exists
|
|
86
|
+
* for the given error code.
|
|
87
|
+
*
|
|
88
|
+
* Related context: https://github.com/angular/vscode-ng-language-service/pull/2050#discussion_r1673079263
|
|
89
|
+
*/
|
|
90
|
+
hasCodeFixesForErrorCode(errorCode: number): boolean;
|
|
91
|
+
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences): readonly ts.CodeFixAction[];
|
|
92
|
+
getCombinedCodeFix(scope: ts.CombinedCodeFixScope, fixId: string, formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences): ts.CombinedCodeActions;
|
|
93
|
+
getComponentLocationsForTemplate(fileName: string): GetComponentLocationsForTemplateResponse;
|
|
94
|
+
getTemplateLocationForComponent(fileName: string, position: number): GetTemplateLocationForComponentResponse;
|
|
95
|
+
getTcb(fileName: string, position: number): GetTcbResponse | undefined;
|
|
96
|
+
getPossibleRefactorings(fileName: string, positionOrRange: number | ts.TextRange): ts.ApplicableRefactorInfo[];
|
|
97
|
+
/**
|
|
98
|
+
* Computes edits for applying the specified refactoring.
|
|
99
|
+
*
|
|
100
|
+
* VSCode explicitly split code actions into two stages:
|
|
101
|
+
*
|
|
102
|
+
* - 1) what actions are active?
|
|
103
|
+
* - 2) what are the edits? <- if the user presses the button
|
|
104
|
+
*
|
|
105
|
+
* The latter stage may take longer to compute complex edits, perform
|
|
106
|
+
* analysis. This stage is currently implemented via our non-LSP standard
|
|
107
|
+
* `applyRefactoring` method. We implemented it in a way to support asynchronous
|
|
108
|
+
* computation, so that it can easily integrate with migrations that aren't
|
|
109
|
+
* synchronous/or compute edits in parallel.
|
|
110
|
+
*/
|
|
111
|
+
applyRefactoring(fileName: string, positionOrRange: number | ts.TextRange, refactorName: string, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult | undefined>;
|
|
112
|
+
/**
|
|
113
|
+
* Provides an instance of the `NgCompiler` and traces perf results. Perf results are logged only
|
|
114
|
+
* if the log level is verbose or higher. This method is intended to be called once per public
|
|
115
|
+
* method call.
|
|
116
|
+
*
|
|
117
|
+
* Here is an example of the log output.
|
|
118
|
+
*
|
|
119
|
+
* Perf 245 [16:16:39.353] LanguageService#getQuickInfoAtPosition(): {"events":{},"phases":{
|
|
120
|
+
* "Unaccounted":379,"TtcSymbol":4},"memory":{}}
|
|
121
|
+
*
|
|
122
|
+
* Passing name of caller instead of using `arguments.caller` because 'caller', 'callee', and
|
|
123
|
+
* 'arguments' properties may not be accessed in strict mode.
|
|
124
|
+
*
|
|
125
|
+
* @param phase the `PerfPhase` to execute the `p` callback in
|
|
126
|
+
* @param p callback to be run synchronously with an instance of the `NgCompiler` as argument
|
|
127
|
+
* @return the result of running the `p` callback
|
|
128
|
+
*/
|
|
129
|
+
private withCompilerAndPerfTracing;
|
|
130
|
+
getCompilerOptionsDiagnostics(): ts.Diagnostic[];
|
|
131
|
+
private watchConfigFile;
|
|
132
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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';
|
|
9
|
+
import { LinkedEditingRanges } from '../api';
|
|
10
|
+
/**
|
|
11
|
+
* Gets linked editing ranges for synchronized editing of HTML tag pairs.
|
|
12
|
+
*
|
|
13
|
+
* When the cursor is on an element tag name, returns both the opening and closing
|
|
14
|
+
* tag name spans so they can be edited simultaneously.
|
|
15
|
+
*
|
|
16
|
+
* @param compiler The Angular compiler instance
|
|
17
|
+
* @param fileName The file to check
|
|
18
|
+
* @param position The cursor position in the file
|
|
19
|
+
* @returns LinkedEditingRanges if on a tag name, null otherwise
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLinkedEditingRangeAtPosition(compiler: NgCompiler, fileName: string, position: number): LinkedEditingRanges | null;
|
|
@@ -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 { NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
export declare function getOutliningSpans(compiler: NgCompiler, fileName: string): ts.OutliningSpan[];
|
|
@@ -0,0 +1,34 @@
|
|
|
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 } from '@angular/compiler';
|
|
9
|
+
import { NgCompiler } from '@angular/compiler-cli';
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import { TemplateTarget } from './template_target';
|
|
12
|
+
export declare class QuickInfoBuilder {
|
|
13
|
+
private readonly tsLS;
|
|
14
|
+
private readonly compiler;
|
|
15
|
+
private readonly component;
|
|
16
|
+
private node;
|
|
17
|
+
private readonly positionDetails;
|
|
18
|
+
private readonly typeChecker;
|
|
19
|
+
private readonly parent;
|
|
20
|
+
constructor(tsLS: ts.LanguageService, compiler: NgCompiler, component: ts.ClassDeclaration, node: TmplAstNode | AST, positionDetails: TemplateTarget);
|
|
21
|
+
get(): ts.QuickInfo | undefined;
|
|
22
|
+
private getQuickInfoForSymbol;
|
|
23
|
+
private getQuickInfoForBindingSymbol;
|
|
24
|
+
private getQuickInfoForElementSymbol;
|
|
25
|
+
private getQuickInfoForVariableSymbol;
|
|
26
|
+
private getQuickInfoForLetDeclarationSymbol;
|
|
27
|
+
private getQuickInfoForReferenceSymbol;
|
|
28
|
+
private getQuickInfoForPipeSymbol;
|
|
29
|
+
private getQuickInfoForDomBinding;
|
|
30
|
+
private getQuickInfoForDirectiveSymbol;
|
|
31
|
+
private getQuickInfoForSelectorlessSymbol;
|
|
32
|
+
private getQuickInfoFromTypeDefAtLocation;
|
|
33
|
+
private getQuickInfoAtTcbLocation;
|
|
34
|
+
}
|
|
@@ -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 { AST, Call, TmplAstBlockNode, TmplAstDeferredTrigger, TmplAstNode } from '@angular/compiler';
|
|
9
|
+
import type ts from 'typescript';
|
|
10
|
+
export declare function isDollarAny(node: TmplAstNode | AST): node is Call;
|
|
11
|
+
export declare function createDollarAnyQuickInfo(node: Call): ts.QuickInfo;
|
|
12
|
+
export declare function createNgTemplateQuickInfo(node: TmplAstNode | AST): ts.QuickInfo;
|
|
13
|
+
export declare function createQuickInfoForBuiltIn(node: TmplAstDeferredTrigger | TmplAstBlockNode, cursorPositionInTemplate: number): ts.QuickInfo | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import type ts from 'typescript';
|
|
10
|
+
import { KnownInputInfo, MigrationConfig } from '@angular/core/schematics/migrations/signal-migration/src';
|
|
11
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
12
|
+
export declare function applySignalInputRefactoring(compiler: NgCompiler, compilerOptions: CompilerOptions, config: MigrationConfig, project: ts.server.Project, reportProgress: ApplyRefactoringProgressFn, shouldMigrateInput: (input: KnownInputInfo) => boolean, multiMode: boolean): Promise<ApplyRefactoringResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 isDecoratorInputClassField(node: ts.ClassElement, reflector: ReflectionHost): boolean;
|
|
11
|
+
export declare function isDirectiveOrComponentWithInputs(node: ts.ClassDeclaration, reflector: ReflectionHost): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import { MigrationConfig } from '@angular/core/schematics/migrations/signal-migration/src';
|
|
10
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
11
|
+
import ts from 'typescript';
|
|
12
|
+
import type { ActiveRefactoring } from '../refactoring';
|
|
13
|
+
/**
|
|
14
|
+
* Base language service refactoring action that can convert `@Input()`
|
|
15
|
+
* declarations of a full class to signal inputs.
|
|
16
|
+
*
|
|
17
|
+
* The user can click on an class with `@Input`s and ask for all the input to be migrated.
|
|
18
|
+
* All references, imports and the declaration are updated automatically.
|
|
19
|
+
*/
|
|
20
|
+
declare abstract class BaseConvertFullClassToSignalInputsRefactoring implements ActiveRefactoring {
|
|
21
|
+
private project;
|
|
22
|
+
abstract config: MigrationConfig;
|
|
23
|
+
constructor(project: ts.server.Project);
|
|
24
|
+
static isApplicable(compiler: NgCompiler, fileName: string, positionOrRange: number | ts.TextRange): boolean;
|
|
25
|
+
computeEditsForFix(compiler: NgCompiler, compilerOptions: CompilerOptions, fileName: string, positionOrRange: number | ts.TextRange, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ConvertFullClassToSignalInputsRefactoring extends BaseConvertFullClassToSignalInputsRefactoring {
|
|
28
|
+
static id: string;
|
|
29
|
+
static description: string;
|
|
30
|
+
config: MigrationConfig;
|
|
31
|
+
}
|
|
32
|
+
export declare class ConvertFullClassToSignalInputsBestEffortRefactoring extends BaseConvertFullClassToSignalInputsRefactoring {
|
|
33
|
+
static id: string;
|
|
34
|
+
static description: string;
|
|
35
|
+
config: MigrationConfig;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import { MigrationConfig } from '@angular/core/schematics/migrations/signal-migration/src';
|
|
10
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
11
|
+
import ts from 'typescript';
|
|
12
|
+
import type { ActiveRefactoring } from '../refactoring';
|
|
13
|
+
/**
|
|
14
|
+
* Base language service refactoring action that can convert a
|
|
15
|
+
* single individual `@Input()` declaration to a signal inputs
|
|
16
|
+
*
|
|
17
|
+
* The user can click on an `@Input` property declaration in e.g. the VSCode
|
|
18
|
+
* extension and ask for the input to be migrated. All references, imports and
|
|
19
|
+
* the declaration are updated automatically.
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class BaseConvertFieldToSignalInputRefactoring implements ActiveRefactoring {
|
|
22
|
+
private project;
|
|
23
|
+
abstract config: MigrationConfig;
|
|
24
|
+
constructor(project: ts.server.Project);
|
|
25
|
+
static isApplicable(compiler: NgCompiler, fileName: string, positionOrRange: number | ts.TextRange): boolean;
|
|
26
|
+
computeEditsForFix(compiler: NgCompiler, compilerOptions: CompilerOptions, fileName: string, positionOrRange: number | ts.TextRange, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult>;
|
|
27
|
+
}
|
|
28
|
+
export declare class ConvertFieldToSignalInputRefactoring extends BaseConvertFieldToSignalInputRefactoring {
|
|
29
|
+
static id: string;
|
|
30
|
+
static description: string;
|
|
31
|
+
config: MigrationConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare class ConvertFieldToSignalInputBestEffortRefactoring extends BaseConvertFieldToSignalInputRefactoring {
|
|
34
|
+
static id: string;
|
|
35
|
+
static description: string;
|
|
36
|
+
config: MigrationConfig;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import ts from 'typescript';
|
|
10
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
11
|
+
import { MigrationConfig } from '@angular/core/schematics/migrations/signal-queries-migration';
|
|
12
|
+
export declare function applySignalQueriesRefactoring(compiler: NgCompiler, compilerOptions: CompilerOptions, config: MigrationConfig, project: ts.server.Project, reportProgress: ApplyRefactoringProgressFn, shouldMigrateQuery: NonNullable<MigrationConfig['shouldMigrateQuery']>, multiMode: boolean): Promise<ApplyRefactoringResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 isDecoratorQueryClassField(node: ts.ClassElement, reflector: ReflectionHost): boolean;
|
|
11
|
+
export declare function isDirectiveOrComponentWithQueries(node: ts.ClassDeclaration, reflector: ReflectionHost): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import { MigrationConfig } from '@angular/core/schematics/migrations/signal-migration/src';
|
|
10
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
11
|
+
import ts from 'typescript';
|
|
12
|
+
import type { ActiveRefactoring } from '../refactoring';
|
|
13
|
+
/**
|
|
14
|
+
* Base language service refactoring action that can convert decorator
|
|
15
|
+
* queries of a full class to signal queries.
|
|
16
|
+
*
|
|
17
|
+
* The user can click on an class with decorator queries and ask for all the queries
|
|
18
|
+
* to be migrated. All references, imports and the declaration are updated automatically.
|
|
19
|
+
*/
|
|
20
|
+
declare abstract class BaseConvertFullClassToSignalQueriesRefactoring implements ActiveRefactoring {
|
|
21
|
+
private project;
|
|
22
|
+
abstract config: MigrationConfig;
|
|
23
|
+
constructor(project: ts.server.Project);
|
|
24
|
+
static isApplicable(compiler: NgCompiler, fileName: string, positionOrRange: number | ts.TextRange): boolean;
|
|
25
|
+
computeEditsForFix(compiler: NgCompiler, compilerOptions: CompilerOptions, fileName: string, positionOrRange: number | ts.TextRange, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ConvertFullClassToSignalQueriesRefactoring extends BaseConvertFullClassToSignalQueriesRefactoring {
|
|
28
|
+
static id: string;
|
|
29
|
+
static description: string;
|
|
30
|
+
config: MigrationConfig;
|
|
31
|
+
}
|
|
32
|
+
export declare class ConvertFullClassToSignalQueriesBestEffortRefactoring extends BaseConvertFullClassToSignalQueriesRefactoring {
|
|
33
|
+
static id: string;
|
|
34
|
+
static description: string;
|
|
35
|
+
config: MigrationConfig;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
9
|
+
import { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../../api';
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import type { ActiveRefactoring } from '../refactoring';
|
|
12
|
+
import { MigrationConfig } from '../../../../core/schematics/migrations/signal-queries-migration';
|
|
13
|
+
/**
|
|
14
|
+
* Base language service refactoring action that can convert a
|
|
15
|
+
* single individual decorator query declaration to a signal query
|
|
16
|
+
*
|
|
17
|
+
* The user can click on an `@ViewChild` property declaration in e.g. the VSCode
|
|
18
|
+
* extension and ask for the query to be migrated. All references, imports and
|
|
19
|
+
* the declaration are updated automatically.
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class BaseConvertFieldToSignalQueryRefactoring implements ActiveRefactoring {
|
|
22
|
+
private project;
|
|
23
|
+
abstract config: MigrationConfig;
|
|
24
|
+
constructor(project: ts.server.Project);
|
|
25
|
+
static isApplicable(compiler: NgCompiler, fileName: string, positionOrRange: number | ts.TextRange): boolean;
|
|
26
|
+
computeEditsForFix(compiler: NgCompiler, compilerOptions: CompilerOptions, fileName: string, positionOrRange: number | ts.TextRange, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult>;
|
|
27
|
+
}
|
|
28
|
+
export declare class ConvertFieldToSignalQueryRefactoring extends BaseConvertFieldToSignalQueryRefactoring {
|
|
29
|
+
static id: string;
|
|
30
|
+
static description: string;
|
|
31
|
+
config: MigrationConfig;
|
|
32
|
+
}
|
|
33
|
+
export declare class ConvertFieldToSignalQueryBestEffortRefactoring extends BaseConvertFieldToSignalQueryRefactoring {
|
|
34
|
+
static id: string;
|
|
35
|
+
static description: string;
|
|
36
|
+
config: MigrationConfig;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { ApplyRefactoringProgressFn, ApplyRefactoringResult } from '../../api';
|
|
9
|
+
import { CompilerOptions, NgCompiler } from '@angular/compiler-cli';
|
|
10
|
+
import type ts from 'typescript';
|
|
11
|
+
/**
|
|
12
|
+
* Interface exposing static metadata for a {@link Refactoring},
|
|
13
|
+
* exposed via static fields.
|
|
14
|
+
*
|
|
15
|
+
* A refactoring may be applicable at a given position inside
|
|
16
|
+
* a file. If it becomes applicable, the language service will suggest
|
|
17
|
+
* it as a code action.
|
|
18
|
+
*
|
|
19
|
+
* Later, the user can request edits for the refactoring lazily, upon
|
|
20
|
+
* e.g. click. The refactoring class is then instantiated and will be
|
|
21
|
+
* re-used for future applications, allowing for efficient re-use of e.g
|
|
22
|
+
* analysis data.
|
|
23
|
+
*/
|
|
24
|
+
export interface Refactoring {
|
|
25
|
+
new (project: ts.server.Project): ActiveRefactoring;
|
|
26
|
+
/** Unique id of the refactoring. */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Description of the refactoring. Shown in e.g. VSCode as the code action. */
|
|
29
|
+
description: string;
|
|
30
|
+
/** Whether the refactoring is applicable at the given location. */
|
|
31
|
+
isApplicable(compiler: NgCompiler, fileName: string, positionOrRange: number | ts.TextRange): boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Interface that describes an active refactoring instance. A
|
|
35
|
+
* refactoring may be lazily instantiated whenever the refactoring
|
|
36
|
+
* is requested to be applied.
|
|
37
|
+
*
|
|
38
|
+
* More information can be found in {@link Refactoring}
|
|
39
|
+
*/
|
|
40
|
+
export interface ActiveRefactoring {
|
|
41
|
+
/** Computes the edits for the refactoring. */
|
|
42
|
+
computeEditsForFix(compiler: NgCompiler, compilerOptions: CompilerOptions, fileName: string, positionOrRange: number | ts.TextRange, reportProgress: ApplyRefactoringProgressFn): Promise<ApplyRefactoringResult>;
|
|
43
|
+
}
|
|
44
|
+
export declare const allRefactorings: Refactoring[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NgCompiler } from '@angular/compiler-cli';
|
|
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,70 @@
|
|
|
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, TmplAstComponent, TmplAstDirective, TmplAstNode, TmplAstRecursiveVisitor } from '@angular/compiler';
|
|
9
|
+
import { DirectiveMeta, NgCompiler, PipeMeta, Symbol, TemplateTypeChecker } from '@angular/compiler-cli';
|
|
10
|
+
import ts from 'typescript';
|
|
11
|
+
import { TypeCheckInfo } from './utils';
|
|
12
|
+
/** Represents a location in a file. */
|
|
13
|
+
export interface FilePosition {
|
|
14
|
+
fileName: string;
|
|
15
|
+
position: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TemplateLocationDetails {
|
|
18
|
+
/**
|
|
19
|
+
* A target node in a template.
|
|
20
|
+
*/
|
|
21
|
+
templateTarget: TmplAstNode | AST;
|
|
22
|
+
/**
|
|
23
|
+
* TypeScript locations which the template node maps to. A given template node might map to
|
|
24
|
+
* several TS nodes. For example, a template node for an attribute might resolve to several
|
|
25
|
+
* directives or a directive and one of its inputs.
|
|
26
|
+
*/
|
|
27
|
+
typescriptLocations: FilePosition[];
|
|
28
|
+
/**
|
|
29
|
+
* The resolved Symbol for the template target.
|
|
30
|
+
*/
|
|
31
|
+
symbol: Symbol;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Takes a position in a template and finds equivalent targets in TS files as well as details about
|
|
35
|
+
* the targeted template node.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getTargetDetailsAtTemplatePosition(info: TypeCheckInfo, position: number, templateTypeChecker: TemplateTypeChecker): TemplateLocationDetails[] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a "key" for a rename/reference location by concatenating file name, span start, and span
|
|
40
|
+
* length. This allows us to de-duplicate template results when an item may appear several times
|
|
41
|
+
* in the TCB but map back to the same template location.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createLocationKey(ds: ts.DocumentSpan): string;
|
|
44
|
+
/**
|
|
45
|
+
* Converts a given `ts.DocumentSpan` in a shim file to its equivalent `ts.DocumentSpan` in the
|
|
46
|
+
* template.
|
|
47
|
+
*
|
|
48
|
+
* You can optionally provide a `requiredNodeText` that ensures the equivalent template node's text
|
|
49
|
+
* matches. If it does not, this function will return `null`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function convertToTemplateDocumentSpan<T extends ts.DocumentSpan>(shimDocumentSpan: T, templateTypeChecker: TemplateTypeChecker, program: ts.Program, requiredNodeText?: string): T | null;
|
|
52
|
+
/**
|
|
53
|
+
* Finds the text and `ts.TextSpan` for the node at a position in a template.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getRenameTextAndSpanAtPosition(node: TmplAstNode | AST, position: number): {
|
|
56
|
+
text: string;
|
|
57
|
+
span: ts.TextSpan;
|
|
58
|
+
} | null;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves the `PipeMeta` or `DirectiveMeta` of the given `ts.Node`'s parent class.
|
|
61
|
+
*
|
|
62
|
+
* Returns `null` if the node has no parent class or there is no meta associated with the class.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getParentClassMeta(requestNode: ts.Node, compiler: NgCompiler): PipeMeta | DirectiveMeta | null;
|
|
65
|
+
/** Visitor that collects all selectorless AST nodes from a template. */
|
|
66
|
+
export declare class SelectorlessCollector extends TmplAstRecursiveVisitor {
|
|
67
|
+
private nodes;
|
|
68
|
+
static getSelectorlessNodes(nodes: TmplAstNode[]): (TmplAstComponent | TmplAstDirective)[];
|
|
69
|
+
visit(node: TmplAstNode): void;
|
|
70
|
+
}
|
|
@@ -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';
|
|
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';
|
|
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;
|