@volar/language-service 1.0.0-beta.1 → 1.0.0-beta.3
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/baseDocumentService.d.ts +15 -16
- package/out/baseDocumentService.js +5 -5
- package/out/baseLanguageService.d.ts +35 -36
- package/out/baseLanguageService.js +6 -6
- package/out/documentFeatures/autoInsert.js +2 -9
- package/out/documentFeatures/colorPresentations.js +7 -14
- package/out/documentFeatures/documentColors.js +1 -4
- package/out/documentFeatures/documentSymbols.js +3 -6
- package/out/documentFeatures/foldingRanges.js +1 -6
- package/out/documentFeatures/format.js +23 -30
- package/out/documentFeatures/linkedEditingRanges.js +2 -11
- package/out/documentFeatures/selectionRanges.js +3 -8
- package/out/documents.d.ts +31 -57
- package/out/documents.js +105 -73
- package/out/index.d.ts +0 -1
- package/out/index.js +0 -1
- package/out/languageFeatures/autoInsert.js +20 -21
- package/out/languageFeatures/callHierarchy.js +18 -14
- package/out/languageFeatures/codeActions.js +10 -9
- package/out/languageFeatures/codeLens.js +1 -2
- package/out/languageFeatures/complete.js +11 -7
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +8 -8
- package/out/languageFeatures/definition.js +17 -20
- package/out/languageFeatures/documentHighlights.js +7 -10
- package/out/languageFeatures/documentLinks.js +4 -5
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -1
- package/out/languageFeatures/documentSemanticTokens.js +21 -25
- package/out/languageFeatures/executeCommand.d.ts +1 -1
- package/out/languageFeatures/executeCommand.js +1 -1
- package/out/languageFeatures/fileReferences.js +13 -11
- package/out/languageFeatures/fileRename.js +1 -1
- package/out/languageFeatures/hover.js +6 -13
- package/out/languageFeatures/inlayHints.js +12 -11
- package/out/languageFeatures/references.js +14 -13
- package/out/languageFeatures/rename.d.ts +0 -13
- package/out/languageFeatures/rename.js +49 -37
- package/out/languageFeatures/renamePrepare.js +6 -8
- package/out/languageFeatures/signatureHelp.js +1 -5
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +35 -55
- package/out/languageFeatures/workspaceSymbols.js +9 -2
- package/out/types.d.ts +93 -1
- package/out/types.js +1 -0
- package/out/utils/featureWorkers.d.ts +2 -2
- package/out/utils/featureWorkers.js +1 -4
- package/package.json +7 -8
- package/out/plugin.d.ts +0 -93
- package/out/plugin.js +0 -3
|
@@ -13,12 +13,6 @@ const shared = require("@volar/shared");
|
|
|
13
13
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
15
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
16
|
-
function isTsDocument(document) {
|
|
17
|
-
return document.languageId === 'javascript' ||
|
|
18
|
-
document.languageId === 'typescript' ||
|
|
19
|
-
document.languageId === 'javascriptreact' ||
|
|
20
|
-
document.languageId === 'typescriptreact';
|
|
21
|
-
}
|
|
22
16
|
function updateRange(range, change) {
|
|
23
17
|
updatePosition(range.start, change, false);
|
|
24
18
|
updatePosition(range.end, change, true);
|
|
@@ -86,7 +80,7 @@ function register(context) {
|
|
|
86
80
|
const scriptTsCache_declaration = new Map();
|
|
87
81
|
const scriptTsCache_syntactic = new Map();
|
|
88
82
|
const scriptTsCache_suggestion = new Map();
|
|
89
|
-
return (uri,
|
|
83
|
+
return (uri, token, response) => __awaiter(this, void 0, void 0, function* () {
|
|
90
84
|
var _a;
|
|
91
85
|
const cache = (_a = responseCache.get(uri)) !== null && _a !== void 0 ? _a : responseCache.set(uri, {
|
|
92
86
|
nonTs: { snapshot: undefined, errors: [] },
|
|
@@ -117,15 +111,13 @@ function register(context) {
|
|
|
117
111
|
}
|
|
118
112
|
let shouldSend = false;
|
|
119
113
|
let lastCheckCancelAt = 0;
|
|
120
|
-
yield worker(
|
|
121
|
-
doResponse();
|
|
122
|
-
yield worker(true, 'onSyntactic', scriptTsCache_syntactic, cache.tsSyntactic);
|
|
114
|
+
yield worker('onSyntactic', scriptTsCache_syntactic, cache.tsSyntactic);
|
|
123
115
|
doResponse();
|
|
124
|
-
yield worker(
|
|
116
|
+
yield worker('onSuggestion', scriptTsCache_suggestion, cache.tsSuggestion);
|
|
125
117
|
doResponse();
|
|
126
|
-
yield worker(
|
|
118
|
+
yield worker('onSemantic', scriptTsCache_semantic, cache.tsSemantic);
|
|
127
119
|
doResponse();
|
|
128
|
-
yield worker(
|
|
120
|
+
yield worker('onDeclaration', scriptTsCache_declaration, cache.tsDeclaration);
|
|
129
121
|
return getErrors();
|
|
130
122
|
function doResponse() {
|
|
131
123
|
if (shouldSend) {
|
|
@@ -136,44 +128,34 @@ function register(context) {
|
|
|
136
128
|
function getErrors() {
|
|
137
129
|
return Object.values(cache).flatMap(({ errors }) => errors);
|
|
138
130
|
}
|
|
139
|
-
function worker(
|
|
131
|
+
function worker(mode, cacheMap, cache) {
|
|
140
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
133
|
const result = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, true, function* (arg, sourceMap) {
|
|
142
|
-
if (sourceMap.embeddedFile.capabilities.
|
|
134
|
+
if (sourceMap.embeddedFile.capabilities.diagnostic) {
|
|
143
135
|
yield arg;
|
|
144
136
|
}
|
|
145
137
|
}, (plugin, document, arg, sourceMap) => __awaiter(this, void 0, void 0, function* () {
|
|
146
138
|
var _a, _b, _c, _d, _e;
|
|
147
|
-
if (
|
|
139
|
+
if (token) {
|
|
148
140
|
if (Date.now() - lastCheckCancelAt >= 5) {
|
|
149
141
|
yield shared.sleep(5); // wait for LSP event polling
|
|
150
142
|
lastCheckCancelAt = Date.now();
|
|
151
143
|
}
|
|
152
|
-
if (
|
|
144
|
+
if (token.isCancellationRequested)
|
|
153
145
|
return;
|
|
154
146
|
}
|
|
155
|
-
// avoid duplicate errors from vue plugin & typescript plugin
|
|
156
|
-
if (isTsDocument(document) !== isTs)
|
|
157
|
-
return;
|
|
158
147
|
const pluginId = context.plugins.indexOf(plugin);
|
|
159
148
|
const pluginCache = (_a = cacheMap.get(pluginId)) !== null && _a !== void 0 ? _a : cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
160
149
|
const cache = pluginCache.get(document.uri);
|
|
161
|
-
const tsProjectVersion =
|
|
162
|
-
if (
|
|
163
|
-
if (cache && cache.documentVersion === document.version) {
|
|
150
|
+
const tsProjectVersion = (mode === 'onDeclaration' || mode === 'onSemantic') ? (_c = (_b = context.core.typescriptLanguageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
151
|
+
if (mode === 'onDeclaration' || mode === 'onSemantic') {
|
|
152
|
+
if (cache && cache.documentVersion === document.version && cache.tsProjectVersion === tsProjectVersion) {
|
|
164
153
|
return cache.errors;
|
|
165
154
|
}
|
|
166
155
|
}
|
|
167
156
|
else {
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
return cache.errors;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (cache && cache.documentVersion === document.version) {
|
|
175
|
-
return cache.errors;
|
|
176
|
-
}
|
|
157
|
+
if (cache && cache.documentVersion === document.version) {
|
|
158
|
+
return cache.errors;
|
|
177
159
|
}
|
|
178
160
|
}
|
|
179
161
|
const errors = yield ((_e = (_d = plugin.validation) === null || _d === void 0 ? void 0 : _d[mode]) === null || _e === void 0 ? void 0 : _e.call(_d, document));
|
|
@@ -193,37 +175,35 @@ function register(context) {
|
|
|
193
175
|
}
|
|
194
176
|
});
|
|
195
177
|
function transformErrorRange(sourceMap, errors) {
|
|
196
|
-
var _a, _b, _c;
|
|
197
178
|
const result = [];
|
|
198
179
|
for (const error of errors) {
|
|
199
|
-
|
|
180
|
+
// clone it to avoid modify cache
|
|
181
|
+
let _error = Object.assign({}, error);
|
|
200
182
|
if (sourceMap) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// fix https://github.com/johnsoncodehk/volar/issues/1264
|
|
204
|
-
if (!sourceRange) {
|
|
205
|
-
const start = (_b = sourceMap.getSourceRange(error.range.start, error.range.start, data => !!data.diagnostic)) === null || _b === void 0 ? void 0 : _b[0].start;
|
|
206
|
-
const end = (_c = sourceMap.getSourceRange(error.range.end, error.range.end, data => !!data.diagnostic)) === null || _c === void 0 ? void 0 : _c[0].end;
|
|
207
|
-
if (start && end) {
|
|
208
|
-
sourceRange = { start, end };
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
if (!sourceRange)
|
|
183
|
+
const range = sourceMap.toSourceRange(error.range, data => !!data.diagnostic);
|
|
184
|
+
if (!range) {
|
|
212
185
|
continue;
|
|
213
|
-
|
|
186
|
+
}
|
|
187
|
+
_error.range = range;
|
|
214
188
|
}
|
|
215
189
|
if (_error.relatedInformation) {
|
|
216
190
|
const relatedInfos = [];
|
|
217
191
|
for (const info of _error.relatedInformation) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
192
|
+
const map = context.documents.sourceMapFromEmbeddedDocumentUri(info.location.uri);
|
|
193
|
+
if (map) {
|
|
194
|
+
const range = map.toSourceRange(info.location.range, data => !!data.diagnostic);
|
|
195
|
+
if (range) {
|
|
196
|
+
relatedInfos.push({
|
|
197
|
+
location: {
|
|
198
|
+
uri: map.sourceDocument.uri,
|
|
199
|
+
range,
|
|
200
|
+
},
|
|
201
|
+
message: info.message,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
relatedInfos.push(info);
|
|
227
207
|
}
|
|
228
208
|
}
|
|
229
209
|
_error.relatedInformation = relatedInfos;
|
|
@@ -21,8 +21,15 @@ function register(context) {
|
|
|
21
21
|
if (!embeddedSymbols)
|
|
22
22
|
continue;
|
|
23
23
|
const symbols = (0, transforms_1.transformSymbolInformations)(embeddedSymbols, loc => {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const sourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(loc.uri);
|
|
25
|
+
if (sourceMap) {
|
|
26
|
+
const range = sourceMap.toSourceRange(loc.range);
|
|
27
|
+
if (range) {
|
|
28
|
+
return vscode.Location.create(sourceMap.sourceDocument.uri, range);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return loc;
|
|
26
33
|
}
|
|
27
34
|
});
|
|
28
35
|
symbolsList.push(symbols);
|
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LanguageServicePlugin } from '@volar/language-service';
|
|
2
1
|
import { EmbeddedLanguageModule, LanguageServiceHost, EmbeddedLanguageContext, SourceFile } from '@volar/language-core';
|
|
3
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
3
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
@@ -6,6 +5,7 @@ import { SourceFileDocument, SourceFileDocuments } from './documents';
|
|
|
6
5
|
import type { DocumentContext, FileSystemProvider } from 'vscode-html-languageservice';
|
|
7
6
|
import type { SchemaRequestService } from 'vscode-json-languageservice';
|
|
8
7
|
import { URI } from 'vscode-uri';
|
|
8
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
9
9
|
export interface DocumentServiceRuntimeContext {
|
|
10
10
|
typescript: typeof import('typescript/lib/tsserverlibrary');
|
|
11
11
|
plugins: LanguageServicePlugin[];
|
|
@@ -41,3 +41,95 @@ export interface ConfigurationHost {
|
|
|
41
41
|
getConfiguration: (<T>(section: string, scopeUri?: string) => Promise<T | undefined>);
|
|
42
42
|
onDidChangeConfiguration: (cb: () => void) => void;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* LanguageServicePlugin
|
|
46
|
+
*/
|
|
47
|
+
export type NotNullableResult<T> = T | Thenable<T>;
|
|
48
|
+
export type NullableResult<T> = NotNullableResult<T | undefined | null>;
|
|
49
|
+
export type SemanticToken = [number, number, number, number, number];
|
|
50
|
+
export interface ExecuteCommandContext {
|
|
51
|
+
token: vscode.CancellationToken;
|
|
52
|
+
workDoneProgress: {
|
|
53
|
+
begin(title: string, percentage?: number, message?: string, cancellable?: boolean): void;
|
|
54
|
+
report(percentage: number): void;
|
|
55
|
+
report(message: string): void;
|
|
56
|
+
report(percentage: number, message: string): void;
|
|
57
|
+
done(): void;
|
|
58
|
+
};
|
|
59
|
+
showReferences(params: {
|
|
60
|
+
textDocument: vscode.TextDocumentIdentifier;
|
|
61
|
+
position: vscode.Position;
|
|
62
|
+
references: vscode.Location[];
|
|
63
|
+
}): Promise<void>;
|
|
64
|
+
applyEdit(paramOrEdit: vscode.ApplyWorkspaceEditParams | vscode.WorkspaceEdit): Promise<vscode.ApplyWorkspaceEditResult>;
|
|
65
|
+
}
|
|
66
|
+
export interface LanguageServicePlugin {
|
|
67
|
+
setup?(context: LanguageServicePluginContext): void;
|
|
68
|
+
validation?: {
|
|
69
|
+
onSemantic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
70
|
+
onSyntactic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
71
|
+
onSuggestion?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
72
|
+
onDeclaration?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
73
|
+
};
|
|
74
|
+
doHover?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Hover>;
|
|
75
|
+
findImplementations?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
76
|
+
findReferences?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Location[]>;
|
|
77
|
+
findFileReferences?(document: TextDocument): NullableResult<vscode.Location[]>;
|
|
78
|
+
findDocumentHighlights?(document: TextDocument, position: vscode.Position): NullableResult<vscode.DocumentHighlight[]>;
|
|
79
|
+
findDocumentLinks?(document: TextDocument): NullableResult<vscode.DocumentLink[]>;
|
|
80
|
+
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.SymbolInformation[]>;
|
|
81
|
+
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range): NullableResult<SemanticToken[]>;
|
|
82
|
+
findWorkspaceSymbols?(query: string): NullableResult<vscode.SymbolInformation[]>;
|
|
83
|
+
doExecuteCommand?(command: string, args: any[], context: ExecuteCommandContext): NotNullableResult<void>;
|
|
84
|
+
findDocumentColors?(document: TextDocument): NullableResult<vscode.ColorInformation[]>;
|
|
85
|
+
getColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range): NullableResult<vscode.ColorPresentation[]>;
|
|
86
|
+
doFileRename?(oldUri: string, newUri: string): NullableResult<vscode.WorkspaceEdit>;
|
|
87
|
+
getFoldingRanges?(document: TextDocument): NullableResult<vscode.FoldingRange[]>;
|
|
88
|
+
getSelectionRanges?(document: TextDocument, positions: vscode.Position[]): NullableResult<vscode.SelectionRange[]>;
|
|
89
|
+
getSignatureHelp?(document: TextDocument, position: vscode.Position, context?: vscode.SignatureHelpContext): NullableResult<vscode.SignatureHelp>;
|
|
90
|
+
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
91
|
+
formatOnType?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
92
|
+
definition?: {
|
|
93
|
+
on?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
94
|
+
onType?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
95
|
+
};
|
|
96
|
+
complete?: {
|
|
97
|
+
triggerCharacters?: string[];
|
|
98
|
+
isAdditional?: boolean;
|
|
99
|
+
on?(document: TextDocument, position: vscode.Position, context?: vscode.CompletionContext): NullableResult<vscode.CompletionList>;
|
|
100
|
+
resolve?(item: vscode.CompletionItem): NotNullableResult<vscode.CompletionItem>;
|
|
101
|
+
};
|
|
102
|
+
rename?: {
|
|
103
|
+
prepare?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Range | vscode.ResponseError<void>>;
|
|
104
|
+
on?(document: TextDocument, position: vscode.Position, newName: string): NullableResult<vscode.WorkspaceEdit>;
|
|
105
|
+
};
|
|
106
|
+
codeAction?: {
|
|
107
|
+
on?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext): NullableResult<vscode.CodeAction[]>;
|
|
108
|
+
resolve?(codeAction: vscode.CodeAction): NotNullableResult<vscode.CodeAction>;
|
|
109
|
+
};
|
|
110
|
+
codeLens?: {
|
|
111
|
+
on?(document: TextDocument): NullableResult<vscode.CodeLens[]>;
|
|
112
|
+
resolve?(codeLens: vscode.CodeLens): NotNullableResult<vscode.CodeLens>;
|
|
113
|
+
};
|
|
114
|
+
callHierarchy?: {
|
|
115
|
+
prepare(document: TextDocument, position: vscode.Position): NullableResult<vscode.CallHierarchyItem[]>;
|
|
116
|
+
onIncomingCalls(item: vscode.CallHierarchyItem): NotNullableResult<vscode.CallHierarchyIncomingCall[]>;
|
|
117
|
+
onOutgoingCalls(item: vscode.CallHierarchyItem): NotNullableResult<vscode.CallHierarchyOutgoingCall[]>;
|
|
118
|
+
};
|
|
119
|
+
inlayHints?: {
|
|
120
|
+
on?(document: TextDocument, range: vscode.Range): NullableResult<vscode.InlayHint[]>;
|
|
121
|
+
};
|
|
122
|
+
findLinkedEditingRanges?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LinkedEditingRanges>;
|
|
123
|
+
doAutoInsert?(document: TextDocument, position: vscode.Position, context: {
|
|
124
|
+
lastChange: {
|
|
125
|
+
range: vscode.Range;
|
|
126
|
+
rangeOffset: number;
|
|
127
|
+
rangeLength: number;
|
|
128
|
+
text: string;
|
|
129
|
+
};
|
|
130
|
+
}): NullableResult<string | vscode.TextEdit>;
|
|
131
|
+
/**
|
|
132
|
+
* TODO: only support to doCompleteResolve for now
|
|
133
|
+
*/
|
|
134
|
+
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
135
|
+
}
|
package/out/types.js
CHANGED
|
@@ -2,6 +2,6 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
|
2
2
|
import type { DocumentServiceRuntimeContext, LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
import { LanguageServicePlugin } from '@volar/language-service';
|
|
4
4
|
import { EmbeddedDocumentSourceMap, SourceFileDocument } from '../documents';
|
|
5
|
-
export declare function documentFeatureWorker<T>(context: DocumentServiceRuntimeContext, document: TextDocument, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, worker: (plugin: LanguageServicePlugin, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap
|
|
6
|
-
export declare function documentArgFeatureWorker<T, K>(context: DocumentServiceRuntimeContext, document: TextDocument, arg: K, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | [K], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap
|
|
5
|
+
export declare function documentFeatureWorker<T>(context: DocumentServiceRuntimeContext, document: TextDocument, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, worker: (plugin: LanguageServicePlugin, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap) => T | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
6
|
+
export declare function documentArgFeatureWorker<T, K>(context: DocumentServiceRuntimeContext, document: TextDocument, arg: K, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | [K], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap) => T | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
7
7
|
export declare function languageFeatureWorker<T, K>(context: LanguageServiceRuntimeContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | K[], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K, sourceMap: EmbeddedDocumentSourceMap | undefined, vueDocument: SourceFileDocument | undefined) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
@@ -44,10 +44,7 @@ function documentArgFeatureWorker(context, document, arg, isValidSourceMap, tran
|
|
|
44
44
|
if (results.length === 0 || !!combineResult) {
|
|
45
45
|
context.prepareLanguageServices(document);
|
|
46
46
|
for (const plugin of context.plugins) {
|
|
47
|
-
const
|
|
48
|
-
if (!embeddedResult)
|
|
49
|
-
continue;
|
|
50
|
-
const result = yield transform(embeddedResult, undefined);
|
|
47
|
+
const result = yield worker(plugin, document, arg);
|
|
51
48
|
if (!result)
|
|
52
49
|
continue;
|
|
53
50
|
results.push(result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -16,18 +16,17 @@
|
|
|
16
16
|
"typescript": "beta"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@volar/language-core": "1.0.0-beta.
|
|
20
|
-
"@volar/shared": "1.0.0-beta.
|
|
21
|
-
"@volar/source-map": "1.0.0-beta.
|
|
22
|
-
"@volar/transforms": "1.0.0-beta.
|
|
23
|
-
"@volar/typescript-faster": "1.0.0-beta.
|
|
19
|
+
"@volar/language-core": "1.0.0-beta.3",
|
|
20
|
+
"@volar/shared": "1.0.0-beta.3",
|
|
21
|
+
"@volar/source-map": "1.0.0-beta.3",
|
|
22
|
+
"@volar/transforms": "1.0.0-beta.3",
|
|
23
|
+
"@volar/typescript-faster": "1.0.0-beta.3",
|
|
24
24
|
"@vue/reactivity": "^3.2.38",
|
|
25
|
-
"upath": "^2.0.1",
|
|
26
25
|
"vscode-html-languageservice": "^5.0.1",
|
|
27
26
|
"vscode-json-languageservice": "^5.1.0",
|
|
28
27
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
29
28
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
30
29
|
"vscode-uri": "^3.0.3"
|
|
31
30
|
},
|
|
32
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "b7242f995970b4eedfcf068619497eb845e9ac73"
|
|
33
32
|
}
|
package/out/plugin.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
import { LanguageServicePluginContext } from './types';
|
|
4
|
-
export type NotNullableResult<T> = T | Thenable<T>;
|
|
5
|
-
export type NullableResult<T> = NotNullableResult<T | undefined | null>;
|
|
6
|
-
export type SemanticToken = [number, number, number, number, number];
|
|
7
|
-
export interface ExecuteCommandContext {
|
|
8
|
-
token: vscode.CancellationToken;
|
|
9
|
-
workDoneProgress: {
|
|
10
|
-
begin(title: string, percentage?: number, message?: string, cancellable?: boolean): void;
|
|
11
|
-
report(percentage: number): void;
|
|
12
|
-
report(message: string): void;
|
|
13
|
-
report(percentage: number, message: string): void;
|
|
14
|
-
done(): void;
|
|
15
|
-
};
|
|
16
|
-
showReferences(params: {
|
|
17
|
-
textDocument: vscode.TextDocumentIdentifier;
|
|
18
|
-
position: vscode.Position;
|
|
19
|
-
references: vscode.Location[];
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
applyEdit(paramOrEdit: vscode.ApplyWorkspaceEditParams | vscode.WorkspaceEdit): Promise<vscode.ApplyWorkspaceEditResult>;
|
|
22
|
-
}
|
|
23
|
-
export interface LanguageServicePlugin {
|
|
24
|
-
setup?(context: LanguageServicePluginContext): void;
|
|
25
|
-
validation?: {
|
|
26
|
-
onFull?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
27
|
-
onSemantic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
28
|
-
onSyntactic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
29
|
-
onSuggestion?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
30
|
-
onDeclaration?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
31
|
-
};
|
|
32
|
-
doHover?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Hover>;
|
|
33
|
-
findImplementations?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
34
|
-
findReferences?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Location[]>;
|
|
35
|
-
findFileReferences?(document: TextDocument): NullableResult<vscode.Location[]>;
|
|
36
|
-
findDocumentHighlights?(document: TextDocument, position: vscode.Position): NullableResult<vscode.DocumentHighlight[]>;
|
|
37
|
-
findDocumentLinks?(document: TextDocument): NullableResult<vscode.DocumentLink[]>;
|
|
38
|
-
findDocumentSymbols?(document: TextDocument): NullableResult<vscode.SymbolInformation[]>;
|
|
39
|
-
findDocumentSemanticTokens?(document: TextDocument, range?: vscode.Range, cancleToken?: vscode.CancellationToken): NullableResult<SemanticToken[]>;
|
|
40
|
-
findWorkspaceSymbols?(query: string): NullableResult<vscode.SymbolInformation[]>;
|
|
41
|
-
doExecuteCommand?(command: string, args: any[], context: ExecuteCommandContext): NotNullableResult<void>;
|
|
42
|
-
findDocumentColors?(document: TextDocument): NullableResult<vscode.ColorInformation[]>;
|
|
43
|
-
getColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range): NullableResult<vscode.ColorPresentation[]>;
|
|
44
|
-
doFileRename?(oldUri: string, newUri: string): NullableResult<vscode.WorkspaceEdit>;
|
|
45
|
-
getFoldingRanges?(document: TextDocument): NullableResult<vscode.FoldingRange[]>;
|
|
46
|
-
getSelectionRanges?(document: TextDocument, positions: vscode.Position[]): NullableResult<vscode.SelectionRange[]>;
|
|
47
|
-
getSignatureHelp?(document: TextDocument, position: vscode.Position, context?: vscode.SignatureHelpContext): NullableResult<vscode.SignatureHelp>;
|
|
48
|
-
format?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
49
|
-
formatOnType?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions): NullableResult<vscode.TextEdit[]>;
|
|
50
|
-
definition?: {
|
|
51
|
-
on?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
52
|
-
onType?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LocationLink[]>;
|
|
53
|
-
};
|
|
54
|
-
complete?: {
|
|
55
|
-
triggerCharacters?: string[];
|
|
56
|
-
isAdditional?: boolean;
|
|
57
|
-
on?(document: TextDocument, position: vscode.Position, context?: vscode.CompletionContext): NullableResult<vscode.CompletionList>;
|
|
58
|
-
resolve?(item: vscode.CompletionItem, newPosition?: vscode.Position): NotNullableResult<vscode.CompletionItem>;
|
|
59
|
-
};
|
|
60
|
-
rename?: {
|
|
61
|
-
prepare?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Range | vscode.ResponseError<void>>;
|
|
62
|
-
on?(document: TextDocument, position: vscode.Position, newName: string): NullableResult<vscode.WorkspaceEdit>;
|
|
63
|
-
};
|
|
64
|
-
codeAction?: {
|
|
65
|
-
on?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext): NullableResult<vscode.CodeAction[]>;
|
|
66
|
-
resolve?(codeAction: vscode.CodeAction): NotNullableResult<vscode.CodeAction>;
|
|
67
|
-
};
|
|
68
|
-
codeLens?: {
|
|
69
|
-
on?(document: TextDocument): NullableResult<vscode.CodeLens[]>;
|
|
70
|
-
resolve?(codeLens: vscode.CodeLens): NotNullableResult<vscode.CodeLens>;
|
|
71
|
-
};
|
|
72
|
-
callHierarchy?: {
|
|
73
|
-
prepare(document: TextDocument, position: vscode.Position): NullableResult<vscode.CallHierarchyItem[]>;
|
|
74
|
-
onIncomingCalls(item: vscode.CallHierarchyItem): NotNullableResult<vscode.CallHierarchyIncomingCall[]>;
|
|
75
|
-
onOutgoingCalls(item: vscode.CallHierarchyItem): NotNullableResult<vscode.CallHierarchyOutgoingCall[]>;
|
|
76
|
-
};
|
|
77
|
-
inlayHints?: {
|
|
78
|
-
on?(document: TextDocument, range: vscode.Range): NullableResult<vscode.InlayHint[]>;
|
|
79
|
-
};
|
|
80
|
-
findLinkedEditingRanges?(document: TextDocument, position: vscode.Position): NullableResult<vscode.LinkedEditingRanges>;
|
|
81
|
-
doAutoInsert?(document: TextDocument, position: vscode.Position, context: {
|
|
82
|
-
lastChange: {
|
|
83
|
-
range: vscode.Range;
|
|
84
|
-
rangeOffset: number;
|
|
85
|
-
rangeLength: number;
|
|
86
|
-
text: string;
|
|
87
|
-
};
|
|
88
|
-
}): NullableResult<string | vscode.TextEdit>;
|
|
89
|
-
/**
|
|
90
|
-
* TODO: only support to doCompleteResolve for now
|
|
91
|
-
*/
|
|
92
|
-
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
|
93
|
-
}
|
package/out/plugin.js
DELETED