@volar/language-service 1.1.0-alpha.2 → 1.2.0-alpha.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/out/baseLanguageService.d.ts +4 -14
- package/out/baseLanguageService.js +33 -27
- package/out/documentFeatures/colorPresentations.d.ts +2 -2
- package/out/documentFeatures/documentColors.d.ts +2 -2
- package/out/documentFeatures/documentSymbols.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/format.d.ts +2 -4
- package/out/documentFeatures/format.js +27 -124
- package/out/documentFeatures/linkedEditingRanges.d.ts +2 -2
- package/out/documentFeatures/selectionRanges.d.ts +2 -2
- package/out/index.d.ts +1 -1
- package/out/index.js +3 -3
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.d.ts +4 -4
- package/out/languageFeatures/callHierarchy.js +16 -17
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +28 -17
- package/out/languageFeatures/codeActions.d.ts +16 -7
- package/out/languageFeatures/codeActions.js +101 -21
- package/out/languageFeatures/codeLens.d.ts +11 -4
- package/out/languageFeatures/codeLens.js +31 -15
- package/out/languageFeatures/codeLensResolve.d.ts +4 -2
- package/out/languageFeatures/codeLensResolve.js +22 -8
- package/out/languageFeatures/complete.d.ts +4 -4
- package/out/languageFeatures/complete.js +39 -20
- package/out/languageFeatures/completeResolve.d.ts +2 -2
- package/out/languageFeatures/completeResolve.js +4 -17
- package/out/languageFeatures/definition.d.ts +2 -2
- package/out/languageFeatures/documentHighlights.d.ts +2 -2
- package/out/languageFeatures/documentLinks.d.ts +2 -2
- package/out/languageFeatures/documentSemanticTokens.d.ts +2 -2
- package/out/languageFeatures/fileReferences.d.ts +2 -2
- package/out/languageFeatures/fileRename.d.ts +2 -2
- package/out/languageFeatures/fileRename.js +2 -2
- package/out/languageFeatures/hover.d.ts +2 -2
- package/out/languageFeatures/inlayHints.d.ts +2 -2
- package/out/languageFeatures/references.d.ts +2 -2
- package/out/languageFeatures/rename.d.ts +3 -3
- package/out/languageFeatures/rename.js +64 -44
- package/out/languageFeatures/renamePrepare.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/validation.d.ts +12 -2
- package/out/languageFeatures/validation.js +169 -39
- package/out/languageFeatures/workspaceSymbols.d.ts +2 -2
- package/out/languageFeatures/workspaceSymbols.js +1 -1
- package/out/transformer/foldingRanges.js +6 -6
- package/out/types.d.ts +108 -24
- package/out/types.js +0 -1
- package/out/utils/featureWorkers.d.ts +4 -3
- package/out/utils/featureWorkers.js +120 -5
- package/package.json +9 -9
- package/out/languageFeatures/executeCommand.d.ts +0 -11
- package/out/languageFeatures/executeCommand.js +0 -32
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageContext, LanguageServiceHost } from '@volar/language-core';
|
|
1
|
+
import { LanguageContext, LanguageModule, LanguageServiceHost } from '@volar/language-core';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
import type { DocumentContext, FileSystemProvider } from 'vscode-html-languageservice';
|
|
4
4
|
import type { SchemaRequestService } from 'vscode-json-languageservice';
|
|
@@ -6,9 +6,9 @@ import type * as vscode from 'vscode-languageserver-protocol';
|
|
|
6
6
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
7
7
|
import { URI } from 'vscode-uri';
|
|
8
8
|
import { DocumentsAndSourceMaps } from './documents';
|
|
9
|
-
import { LanguageService } from '@volar/language-service';
|
|
10
9
|
export * from 'vscode-languageserver-protocol';
|
|
11
|
-
export interface
|
|
10
|
+
export interface LanguageServicePluginContext {
|
|
11
|
+
config: Config;
|
|
12
12
|
typescript: {
|
|
13
13
|
module: typeof import('typescript/lib/tsserverlibrary');
|
|
14
14
|
languageServiceHost: ts.LanguageServiceHost;
|
|
@@ -16,21 +16,34 @@ export interface LanguageServiceRuntimeContext<Host extends LanguageServiceHost
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
env: {
|
|
18
18
|
rootUri: URI;
|
|
19
|
+
locale?: string;
|
|
19
20
|
configurationHost?: ConfigurationHost;
|
|
20
21
|
documentContext: DocumentContext;
|
|
21
22
|
fileSystemProvider?: FileSystemProvider;
|
|
22
23
|
schemaRequestService?: SchemaRequestService;
|
|
23
24
|
};
|
|
25
|
+
uriToFileName(uri: string): string;
|
|
26
|
+
fileNameToUri(fileName: string): string;
|
|
24
27
|
/** @private */
|
|
25
|
-
host:
|
|
28
|
+
host: LanguageServiceHost;
|
|
26
29
|
/** @private */
|
|
27
30
|
core: LanguageContext;
|
|
28
31
|
/** @private */
|
|
29
32
|
documents: DocumentsAndSourceMaps;
|
|
30
33
|
/** @private */
|
|
31
|
-
plugins:
|
|
34
|
+
plugins: {
|
|
35
|
+
[id: string]: LanguageServicePluginInstance;
|
|
36
|
+
};
|
|
32
37
|
/** @private */
|
|
33
38
|
getTextDocument(uri: string): TextDocument | undefined;
|
|
39
|
+
/** @private */
|
|
40
|
+
ruleFixes?: {
|
|
41
|
+
[uri: string]: {
|
|
42
|
+
[ruleId: string]: {
|
|
43
|
+
[ruleFixId: number]: [vscode.Diagnostic, RuleFix[]];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
34
47
|
}
|
|
35
48
|
export interface ConfigurationHost {
|
|
36
49
|
getConfiguration: (<T>(section: string, scopeUri?: string) => Promise<T | undefined>);
|
|
@@ -42,25 +55,16 @@ export interface ConfigurationHost {
|
|
|
42
55
|
export type NotNullableResult<T> = T | Thenable<T>;
|
|
43
56
|
export type NullableResult<T> = NotNullableResult<T | undefined | null>;
|
|
44
57
|
export type SemanticToken = [number, number, number, number, number];
|
|
45
|
-
export interface
|
|
46
|
-
|
|
47
|
-
workDoneProgress: {
|
|
48
|
-
begin(title: string, percentage?: number, message?: string, cancellable?: boolean): void;
|
|
49
|
-
report(percentage: number): void;
|
|
50
|
-
report(message: string): void;
|
|
51
|
-
report(percentage: number, message: string): void;
|
|
52
|
-
done(): void;
|
|
53
|
-
};
|
|
54
|
-
showReferences(params: {
|
|
55
|
-
textDocument: vscode.TextDocumentIdentifier;
|
|
56
|
-
position: vscode.Position;
|
|
57
|
-
references: vscode.Location[];
|
|
58
|
-
}): Promise<void>;
|
|
59
|
-
applyEdit(paramOrEdit: vscode.ApplyWorkspaceEditParams | vscode.WorkspaceEdit): Promise<vscode.ApplyWorkspaceEditResult>;
|
|
58
|
+
export interface LanguageServicePlugin<T = {}> {
|
|
59
|
+
(context: LanguageServicePluginContext): LanguageServicePluginInstance & T;
|
|
60
60
|
}
|
|
61
|
-
export type LanguageServicePlugin<T = {}> = ((context: LanguageServiceRuntimeContext, service: LanguageService) => LanguageServicePluginInstance & T);
|
|
62
61
|
export interface LanguageServicePluginInstance {
|
|
63
|
-
|
|
62
|
+
rules?: {
|
|
63
|
+
onAny?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
64
|
+
onFormat?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
65
|
+
onSyntax?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
66
|
+
onSemantic?(context: RuleContext): NotNullableResult<RuleContext>;
|
|
67
|
+
};
|
|
64
68
|
validation?: {
|
|
65
69
|
onSemantic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
66
70
|
onSyntactic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
@@ -76,14 +80,15 @@ export interface LanguageServicePluginInstance {
|
|
|
76
80
|
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.SymbolInformation[]>;
|
|
77
81
|
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend): NullableResult<SemanticToken[]>;
|
|
78
82
|
findWorkspaceSymbols?(query: string): NullableResult<vscode.SymbolInformation[]>;
|
|
79
|
-
doExecuteCommand?(command: string, args: any[], context: ExecuteCommandContext): NotNullableResult<void>;
|
|
80
83
|
findDocumentColors?(document: TextDocument): NullableResult<vscode.ColorInformation[]>;
|
|
81
84
|
getColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range): NullableResult<vscode.ColorPresentation[]>;
|
|
82
85
|
doFileRename?(oldUri: string, newUri: string): NullableResult<vscode.WorkspaceEdit>;
|
|
83
86
|
getFoldingRanges?(document: TextDocument): NullableResult<vscode.FoldingRange[]>;
|
|
84
87
|
getSelectionRanges?(document: TextDocument, positions: vscode.Position[]): NullableResult<vscode.SelectionRange[]>;
|
|
85
88
|
getSignatureHelp?(document: TextDocument, position: vscode.Position, context?: vscode.SignatureHelpContext): NullableResult<vscode.SignatureHelp>;
|
|
86
|
-
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions
|
|
89
|
+
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions & {
|
|
90
|
+
initialIndent: boolean;
|
|
91
|
+
}): NullableResult<vscode.TextEdit[]>;
|
|
87
92
|
formatOnType?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
88
93
|
definition?: {
|
|
89
94
|
on?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
@@ -107,6 +112,10 @@ export interface LanguageServicePluginInstance {
|
|
|
107
112
|
on?(document: TextDocument): NullableResult<vscode.CodeLens[]>;
|
|
108
113
|
resolve?(codeLens: vscode.CodeLens): NotNullableResult<vscode.CodeLens>;
|
|
109
114
|
};
|
|
115
|
+
referencesCodeLens?: {
|
|
116
|
+
on?(document: TextDocument): NullableResult<vscode.Location[]>;
|
|
117
|
+
resolve?(document: TextDocument, location: vscode.Location, references: vscode.Location[]): NotNullableResult<vscode.Location[]>;
|
|
118
|
+
};
|
|
110
119
|
callHierarchy?: {
|
|
111
120
|
prepare(document: TextDocument, position: vscode.Position): NullableResult<vscode.CallHierarchyItem[]>;
|
|
112
121
|
onIncomingCalls(item: vscode.CallHierarchyItem): NotNullableResult<vscode.CallHierarchyIncomingCall[]>;
|
|
@@ -129,3 +138,78 @@ export interface LanguageServicePluginInstance {
|
|
|
129
138
|
*/
|
|
130
139
|
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
131
140
|
}
|
|
141
|
+
export interface Rule {
|
|
142
|
+
onFormat?(ctx: RuleContext): void;
|
|
143
|
+
onSyntax?(ctx: RuleContext): void;
|
|
144
|
+
onSemantic?(ctx: RuleContext): void;
|
|
145
|
+
}
|
|
146
|
+
export interface RuleContext {
|
|
147
|
+
/**
|
|
148
|
+
* Shared modules.
|
|
149
|
+
*/
|
|
150
|
+
modules: {
|
|
151
|
+
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* IDE or user define locale.
|
|
155
|
+
* You can use it to localize your rule.
|
|
156
|
+
*/
|
|
157
|
+
locale?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Project root path.
|
|
160
|
+
*/
|
|
161
|
+
rootUri: URI;
|
|
162
|
+
uriToFileName(uri: string): string;
|
|
163
|
+
fileNameToUri(fileName: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Get configuration from IDE.
|
|
166
|
+
*
|
|
167
|
+
* For VSCode, it's .vscode/settings.json
|
|
168
|
+
*/
|
|
169
|
+
getConfiguration?: <T>(section: string) => Promise<T | undefined>;
|
|
170
|
+
onDidChangeConfiguration?: (cb: () => void) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Global settings from config.
|
|
173
|
+
*/
|
|
174
|
+
settings: any;
|
|
175
|
+
ruleId: string;
|
|
176
|
+
document: TextDocument;
|
|
177
|
+
report(error: vscode.Diagnostic, ...fixes: RuleFix[]): void;
|
|
178
|
+
}
|
|
179
|
+
export interface RuleFix {
|
|
180
|
+
/**
|
|
181
|
+
* Code action kind, like `quickfix` or `refactor`.
|
|
182
|
+
*
|
|
183
|
+
* See https://code.visualstudio.com/api/references/vscode-api#CodeActionKind
|
|
184
|
+
*/
|
|
185
|
+
kinds?: vscode.CodeActionKind[];
|
|
186
|
+
/**
|
|
187
|
+
* Title of the code action.
|
|
188
|
+
*/
|
|
189
|
+
title?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Edit to apply to the document.
|
|
192
|
+
*/
|
|
193
|
+
getEdits?(diagnostic: vscode.Diagnostic): NullableResult<vscode.TextEdit[]>;
|
|
194
|
+
/**
|
|
195
|
+
* Cross-file edits to apply to the workspace.
|
|
196
|
+
*/
|
|
197
|
+
getWorkspaceEdit?(diagnostic: vscode.Diagnostic): NullableResult<vscode.WorkspaceEdit>;
|
|
198
|
+
}
|
|
199
|
+
export interface Config {
|
|
200
|
+
languages?: {
|
|
201
|
+
[id: string]: LanguageModule | undefined;
|
|
202
|
+
};
|
|
203
|
+
plugins?: {
|
|
204
|
+
[id: string]: LanguageServicePlugin | LanguageServicePluginInstance | undefined;
|
|
205
|
+
};
|
|
206
|
+
lint?: {
|
|
207
|
+
rules?: {
|
|
208
|
+
[id: string]: Rule | undefined;
|
|
209
|
+
};
|
|
210
|
+
severities?: {
|
|
211
|
+
[id: string]: vscode.DiagnosticSeverity;
|
|
212
|
+
};
|
|
213
|
+
settings?: any;
|
|
214
|
+
};
|
|
215
|
+
}
|
package/out/types.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
-
import type { LanguageServicePluginInstance,
|
|
2
|
+
import type { LanguageServicePluginInstance, LanguageServicePluginContext, Rule, RuleContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, VirtualFile } from '@volar/language-service';
|
|
4
4
|
import { SourceMapWithDocuments } from '../documents';
|
|
5
|
-
export declare function documentFeatureWorker<T>(context:
|
|
6
|
-
export declare function languageFeatureWorker<T, K>(context:
|
|
5
|
+
export declare function documentFeatureWorker<T>(context: LanguageServicePluginContext, uri: string, isValidSourceMap: (file: VirtualFile, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>) => boolean, worker: (plugin: LanguageServicePluginInstance, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
6
|
+
export declare function languageFeatureWorker<T, K>(context: LanguageServicePluginContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>, file: VirtualFile) => Generator<K> | K[], worker: (plugin: LanguageServicePluginInstance, document: TextDocument, arg: K, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined, file: VirtualFile | undefined) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
7
|
+
export declare function ruleWorker<T>(context: LanguageServicePluginContext, api: 'onSyntax' | 'onSemantic' | 'onFormat', uri: string, isValidSourceMap: (file: VirtualFile) => boolean, worker: (ruleName: string, rule: Rule, ruleCtx: RuleContext) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities> | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
@@ -8,13 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
|
|
11
|
+
exports.ruleWorker = exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
|
|
12
12
|
const definePlugin_1 = require("./definePlugin");
|
|
13
|
+
const shared = require("@volar/shared");
|
|
13
14
|
function documentFeatureWorker(context, uri, isValidSourceMap, worker, transform, combineResult) {
|
|
14
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
return languageFeatureWorker(context, uri,
|
|
16
|
+
return languageFeatureWorker(context, uri, undefined, (_, map, file) => {
|
|
16
17
|
if (isValidSourceMap(file, map)) {
|
|
17
|
-
return [
|
|
18
|
+
return [undefined];
|
|
18
19
|
}
|
|
19
20
|
return [];
|
|
20
21
|
}, worker, transform, combineResult);
|
|
@@ -30,7 +31,7 @@ function languageFeatureWorker(context, uri, arg, transformArg, worker, transfor
|
|
|
30
31
|
if (virtualFile) {
|
|
31
32
|
yield (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, (file, map) => __awaiter(this, void 0, void 0, function* () {
|
|
32
33
|
for (const mappedArg of transformArg(arg, map, file)) {
|
|
33
|
-
for (const plugin of context.plugins) {
|
|
34
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
34
35
|
const embeddedResult = yield worker(plugin, map.virtualFileDocument, mappedArg, map, file);
|
|
35
36
|
if (!embeddedResult)
|
|
36
37
|
continue;
|
|
@@ -50,7 +51,7 @@ function languageFeatureWorker(context, uri, arg, transformArg, worker, transfor
|
|
|
50
51
|
}));
|
|
51
52
|
}
|
|
52
53
|
else if (document) {
|
|
53
|
-
for (const plugin of context.plugins) {
|
|
54
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
54
55
|
const embeddedResult = yield worker(plugin, document, arg, undefined, undefined);
|
|
55
56
|
if (!embeddedResult)
|
|
56
57
|
continue;
|
|
@@ -75,4 +76,118 @@ function languageFeatureWorker(context, uri, arg, transformArg, worker, transfor
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
exports.languageFeatureWorker = languageFeatureWorker;
|
|
79
|
+
function ruleWorker(context, api, uri, isValidSourceMap, worker, transform, combineResult, reportProgress) {
|
|
80
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const document = context.getTextDocument(uri);
|
|
83
|
+
const virtualFile = (_a = context.documents.getSourceByUri(uri)) === null || _a === void 0 ? void 0 : _a.root;
|
|
84
|
+
let results = [];
|
|
85
|
+
if (virtualFile) {
|
|
86
|
+
yield (0, definePlugin_1.visitEmbedded)(context.documents, virtualFile, (file, map) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
var _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
88
|
+
if (!isValidSourceMap(file)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
let ruleCtx = {
|
|
92
|
+
// project context
|
|
93
|
+
modules: { typescript: (_l = context.typescript) === null || _l === void 0 ? void 0 : _l.module },
|
|
94
|
+
uriToFileName: shared.uriToFileName,
|
|
95
|
+
fileNameToUri: shared.fileNameToUri,
|
|
96
|
+
rootUri: context.env.rootUri,
|
|
97
|
+
locale: context.env.locale,
|
|
98
|
+
getConfiguration: (_m = context.env.configurationHost) === null || _m === void 0 ? void 0 : _m.getConfiguration,
|
|
99
|
+
onDidChangeConfiguration: (_o = context.env.configurationHost) === null || _o === void 0 ? void 0 : _o.onDidChangeConfiguration,
|
|
100
|
+
settings: (_q = (_p = context.config.lint) === null || _p === void 0 ? void 0 : _p.settings) !== null && _q !== void 0 ? _q : {},
|
|
101
|
+
// document context
|
|
102
|
+
ruleId: '',
|
|
103
|
+
document: map.virtualFileDocument,
|
|
104
|
+
report: () => { },
|
|
105
|
+
};
|
|
106
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
107
|
+
const fn = (_r = plugin.rules) === null || _r === void 0 ? void 0 : _r[api];
|
|
108
|
+
if (fn) {
|
|
109
|
+
ruleCtx = yield fn(ruleCtx);
|
|
110
|
+
}
|
|
111
|
+
else if ((_s = plugin.rules) === null || _s === void 0 ? void 0 : _s.onAny) {
|
|
112
|
+
ruleCtx = yield plugin.rules.onAny(ruleCtx);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const ruleName in (_t = context.config.lint) === null || _t === void 0 ? void 0 : _t.rules) {
|
|
116
|
+
const rule = (_u = context.config.lint) === null || _u === void 0 ? void 0 : _u.rules[ruleName];
|
|
117
|
+
if (!rule) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
ruleCtx.ruleId = ruleName;
|
|
121
|
+
const embeddedResult = yield worker(ruleName, rule, ruleCtx);
|
|
122
|
+
if (!embeddedResult)
|
|
123
|
+
continue;
|
|
124
|
+
const result = transform(embeddedResult, map);
|
|
125
|
+
if (!result)
|
|
126
|
+
continue;
|
|
127
|
+
results.push(result);
|
|
128
|
+
if (!combineResult)
|
|
129
|
+
return false;
|
|
130
|
+
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
131
|
+
if (reportProgress && !isEmptyArray) {
|
|
132
|
+
reportProgress(combineResult(results));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return true;
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
else if (document) {
|
|
139
|
+
let ruleCtx = {
|
|
140
|
+
// project context
|
|
141
|
+
modules: { typescript: (_b = context.typescript) === null || _b === void 0 ? void 0 : _b.module },
|
|
142
|
+
uriToFileName: shared.uriToFileName,
|
|
143
|
+
fileNameToUri: shared.fileNameToUri,
|
|
144
|
+
rootUri: context.env.rootUri,
|
|
145
|
+
locale: context.env.locale,
|
|
146
|
+
getConfiguration: (_c = context.env.configurationHost) === null || _c === void 0 ? void 0 : _c.getConfiguration,
|
|
147
|
+
onDidChangeConfiguration: (_d = context.env.configurationHost) === null || _d === void 0 ? void 0 : _d.onDidChangeConfiguration,
|
|
148
|
+
settings: (_f = (_e = context.config.lint) === null || _e === void 0 ? void 0 : _e.settings) !== null && _f !== void 0 ? _f : {},
|
|
149
|
+
// document context
|
|
150
|
+
ruleId: '',
|
|
151
|
+
document,
|
|
152
|
+
report: () => { },
|
|
153
|
+
};
|
|
154
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
155
|
+
const fn = (_g = plugin.rules) === null || _g === void 0 ? void 0 : _g[api];
|
|
156
|
+
if (fn) {
|
|
157
|
+
ruleCtx = yield fn(ruleCtx);
|
|
158
|
+
}
|
|
159
|
+
else if ((_h = plugin.rules) === null || _h === void 0 ? void 0 : _h.onAny) {
|
|
160
|
+
ruleCtx = yield plugin.rules.onAny(ruleCtx);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
for (const ruleName in (_j = context.config.lint) === null || _j === void 0 ? void 0 : _j.rules) {
|
|
164
|
+
const rule = (_k = context.config.lint) === null || _k === void 0 ? void 0 : _k.rules[ruleName];
|
|
165
|
+
if (!rule) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
ruleCtx.ruleId = ruleName;
|
|
169
|
+
const embeddedResult = yield worker(ruleName, rule, ruleCtx);
|
|
170
|
+
if (!embeddedResult)
|
|
171
|
+
continue;
|
|
172
|
+
const result = transform(embeddedResult, undefined);
|
|
173
|
+
if (!result)
|
|
174
|
+
continue;
|
|
175
|
+
results.push(result);
|
|
176
|
+
if (!combineResult)
|
|
177
|
+
break;
|
|
178
|
+
const isEmptyArray = Array.isArray(result) && result.length === 0;
|
|
179
|
+
if (reportProgress && !isEmptyArray) {
|
|
180
|
+
reportProgress(combineResult(results));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (combineResult && results.length > 0) {
|
|
185
|
+
return combineResult(results);
|
|
186
|
+
}
|
|
187
|
+
else if (results.length > 0) {
|
|
188
|
+
return results[0];
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
exports.ruleWorker = ruleWorker;
|
|
78
193
|
//# sourceMappingURL=featureWorkers.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha.10",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.
|
|
17
|
-
"@volar/shared": "1.
|
|
18
|
-
"@volar/source-map": "1.
|
|
19
|
-
"@volar/typescript-faster": "1.
|
|
20
|
-
"vscode-html-languageservice": "^5.0.
|
|
21
|
-
"vscode-json-languageservice": "^5.
|
|
22
|
-
"vscode-languageserver-protocol": "^3.17.
|
|
16
|
+
"@volar/language-core": "1.2.0-alpha.10",
|
|
17
|
+
"@volar/shared": "1.2.0-alpha.10",
|
|
18
|
+
"@volar/source-map": "1.2.0-alpha.10",
|
|
19
|
+
"@volar/typescript-faster": "1.2.0-alpha.10",
|
|
20
|
+
"vscode-html-languageservice": "^5.0.4",
|
|
21
|
+
"vscode-json-languageservice": "^5.2.0",
|
|
22
|
+
"vscode-languageserver-protocol": "^3.17.3",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "c0b7580b14966d28d7c6df5da9baa41111f9f8d9"
|
|
27
27
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LanguageServiceRuntimeContext } from '../types';
|
|
2
|
-
import { ExecuteCommandContext } from '@volar/language-service';
|
|
3
|
-
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
|
-
export declare const executePluginCommand: string;
|
|
5
|
-
export type ExecutePluginCommandArgs = [
|
|
6
|
-
string,
|
|
7
|
-
// uri
|
|
8
|
-
number | undefined,
|
|
9
|
-
vscode.Command
|
|
10
|
-
];
|
|
11
|
-
export declare function register(context: LanguageServiceRuntimeContext): (command: string, args: ExecutePluginCommandArgs, executeCommandContext: ExecuteCommandContext) => Promise<void>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.register = exports.executePluginCommand = void 0;
|
|
12
|
-
const randomCommandId = Math.random().toString(36).slice(2); // TODO
|
|
13
|
-
exports.executePluginCommand = `volar.${randomCommandId}.executePluginCommand`;
|
|
14
|
-
function register(context) {
|
|
15
|
-
return (command, args, executeCommandContext) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
if (command === exports.executePluginCommand) {
|
|
18
|
-
const [_uri, pluginId, originalCommand] = args;
|
|
19
|
-
if (pluginId !== undefined) {
|
|
20
|
-
const plugin = context.plugins[pluginId];
|
|
21
|
-
yield ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.doExecuteCommand) === null || _a === void 0 ? void 0 : _a.call(plugin, originalCommand.command, originalCommand.arguments, executeCommandContext));
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
for (const plugin of context.plugins) {
|
|
25
|
-
yield ((_b = plugin.doExecuteCommand) === null || _b === void 0 ? void 0 : _b.call(plugin, originalCommand.command, originalCommand.arguments, executeCommandContext));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
exports.register = register;
|
|
32
|
-
//# sourceMappingURL=executeCommand.js.map
|