@volar/language-service 1.0.0-beta.0 → 1.0.0-beta.2
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 +4 -4
- package/out/baseDocumentService.js +1 -1
- package/out/baseLanguageService.d.ts +5 -5
- package/out/baseLanguageService.js +2 -2
- package/out/documentFeatures/autoInsert.d.ts +2 -2
- 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 +23 -49
- package/out/documents.js +105 -73
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/autoInsert.js +20 -21
- package/out/languageFeatures/callHierarchy.js +17 -13
- package/out/languageFeatures/codeActions.js +10 -9
- package/out/languageFeatures/codeLens.js +1 -2
- package/out/languageFeatures/complete.js +13 -9
- 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.js +21 -23
- 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.js +31 -33
- package/out/languageFeatures/workspaceSymbols.js +9 -2
- package/out/plugin.d.ts +4 -4
- package/out/types.d.ts +6 -6
- package/out/utils/featureWorkers.d.ts +4 -4
- package/out/utils/featureWorkers.js +1 -4
- package/package.json +7 -7
|
@@ -117,15 +117,15 @@ function register(context) {
|
|
|
117
117
|
}
|
|
118
118
|
let shouldSend = false;
|
|
119
119
|
let lastCheckCancelAt = 0;
|
|
120
|
-
yield worker(
|
|
120
|
+
yield worker(0 /* EmbeddedFileKind.TextFile */, 'onFull', nonTsCache, cache.nonTs);
|
|
121
121
|
doResponse();
|
|
122
|
-
yield worker(
|
|
122
|
+
yield worker(1 /* EmbeddedFileKind.TypeScriptHostFile */, 'onSyntactic', scriptTsCache_syntactic, cache.tsSyntactic);
|
|
123
123
|
doResponse();
|
|
124
|
-
yield worker(
|
|
124
|
+
yield worker(1 /* EmbeddedFileKind.TypeScriptHostFile */, 'onSuggestion', scriptTsCache_suggestion, cache.tsSuggestion);
|
|
125
125
|
doResponse();
|
|
126
|
-
yield worker(
|
|
126
|
+
yield worker(1 /* EmbeddedFileKind.TypeScriptHostFile */, 'onSemantic', scriptTsCache_semantic, cache.tsSemantic);
|
|
127
127
|
doResponse();
|
|
128
|
-
yield worker(
|
|
128
|
+
yield worker(1 /* EmbeddedFileKind.TypeScriptHostFile */, 'onDeclaration', scriptTsCache_declaration, cache.tsDeclaration);
|
|
129
129
|
return getErrors();
|
|
130
130
|
function doResponse() {
|
|
131
131
|
if (shouldSend) {
|
|
@@ -136,10 +136,10 @@ function register(context) {
|
|
|
136
136
|
function getErrors() {
|
|
137
137
|
return Object.values(cache).flatMap(({ errors }) => errors);
|
|
138
138
|
}
|
|
139
|
-
function worker(
|
|
139
|
+
function worker(kind, mode, cacheMap, cache) {
|
|
140
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
141
|
const result = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, true, function* (arg, sourceMap) {
|
|
142
|
-
if (sourceMap.embeddedFile.capabilities.
|
|
142
|
+
if (sourceMap.embeddedFile.capabilities.diagnostic && sourceMap.embeddedFile.kind === kind) {
|
|
143
143
|
yield arg;
|
|
144
144
|
}
|
|
145
145
|
}, (plugin, document, arg, sourceMap) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -153,13 +153,13 @@ function register(context) {
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
// avoid duplicate errors from vue plugin & typescript plugin
|
|
156
|
-
if (isTsDocument(document) !==
|
|
156
|
+
if (isTsDocument(document) !== (kind === 1 /* EmbeddedFileKind.TypeScriptHostFile */))
|
|
157
157
|
return;
|
|
158
158
|
const pluginId = context.plugins.indexOf(plugin);
|
|
159
159
|
const pluginCache = (_a = cacheMap.get(pluginId)) !== null && _a !== void 0 ? _a : cacheMap.set(pluginId, new Map()).get(pluginId);
|
|
160
160
|
const cache = pluginCache.get(document.uri);
|
|
161
|
-
const tsProjectVersion =
|
|
162
|
-
if (
|
|
161
|
+
const tsProjectVersion = kind === 1 /* EmbeddedFileKind.TypeScriptHostFile */ ? (_c = (_b = context.core.typescriptLanguageServiceHost).getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(_b) : undefined;
|
|
162
|
+
if (kind !== 1 /* EmbeddedFileKind.TypeScriptHostFile */) {
|
|
163
163
|
if (cache && cache.documentVersion === document.version) {
|
|
164
164
|
return cache.errors;
|
|
165
165
|
}
|
|
@@ -193,37 +193,35 @@ function register(context) {
|
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
function transformErrorRange(sourceMap, errors) {
|
|
196
|
-
var _a, _b, _c;
|
|
197
196
|
const result = [];
|
|
198
197
|
for (const error of errors) {
|
|
199
|
-
|
|
198
|
+
// clone it to avoid modify cache
|
|
199
|
+
let _error = Object.assign({}, error);
|
|
200
200
|
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)
|
|
201
|
+
const range = sourceMap.toSourceRange(error.range, data => !!data.diagnostic);
|
|
202
|
+
if (!range) {
|
|
212
203
|
continue;
|
|
213
|
-
|
|
204
|
+
}
|
|
205
|
+
_error.range = range;
|
|
214
206
|
}
|
|
215
207
|
if (_error.relatedInformation) {
|
|
216
208
|
const relatedInfos = [];
|
|
217
209
|
for (const info of _error.relatedInformation) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
210
|
+
const map = context.documents.sourceMapFromEmbeddedDocumentUri(info.location.uri);
|
|
211
|
+
if (map) {
|
|
212
|
+
const range = map.toSourceRange(info.location.range, data => !!data.diagnostic);
|
|
213
|
+
if (range) {
|
|
214
|
+
relatedInfos.push({
|
|
215
|
+
location: {
|
|
216
|
+
uri: map.sourceDocument.uri,
|
|
217
|
+
range,
|
|
218
|
+
},
|
|
219
|
+
message: info.message,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
relatedInfos.push(info);
|
|
227
225
|
}
|
|
228
226
|
}
|
|
229
227
|
_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/plugin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
-
import {
|
|
3
|
+
import { LanguageServicePluginContext } from './types';
|
|
4
4
|
export type NotNullableResult<T> = T | Thenable<T>;
|
|
5
5
|
export type NullableResult<T> = NotNullableResult<T | undefined | null>;
|
|
6
6
|
export type SemanticToken = [number, number, number, number, number];
|
|
@@ -20,8 +20,8 @@ export interface ExecuteCommandContext {
|
|
|
20
20
|
}): Promise<void>;
|
|
21
21
|
applyEdit(paramOrEdit: vscode.ApplyWorkspaceEditParams | vscode.WorkspaceEdit): Promise<vscode.ApplyWorkspaceEditResult>;
|
|
22
22
|
}
|
|
23
|
-
export interface
|
|
24
|
-
setup?(context:
|
|
23
|
+
export interface LanguageServicePlugin {
|
|
24
|
+
setup?(context: LanguageServicePluginContext): void;
|
|
25
25
|
validation?: {
|
|
26
26
|
onFull?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
27
27
|
onSemantic?(document: TextDocument): NullableResult<vscode.Diagnostic[]>;
|
|
@@ -55,7 +55,7 @@ export interface EmbeddedLanguageServicePlugin {
|
|
|
55
55
|
triggerCharacters?: string[];
|
|
56
56
|
isAdditional?: boolean;
|
|
57
57
|
on?(document: TextDocument, position: vscode.Position, context?: vscode.CompletionContext): NullableResult<vscode.CompletionList>;
|
|
58
|
-
resolve?(item: vscode.CompletionItem
|
|
58
|
+
resolve?(item: vscode.CompletionItem): NotNullableResult<vscode.CompletionItem>;
|
|
59
59
|
};
|
|
60
60
|
rename?: {
|
|
61
61
|
prepare?(document: TextDocument, position: vscode.Position): NullableResult<vscode.Range | vscode.ResponseError<void>>;
|
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageServicePlugin } from '@volar/language-service';
|
|
2
2
|
import { EmbeddedLanguageModule, LanguageServiceHost, EmbeddedLanguageContext, SourceFile } from '@volar/language-core';
|
|
3
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
4
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
@@ -8,8 +8,8 @@ import type { SchemaRequestService } from 'vscode-json-languageservice';
|
|
|
8
8
|
import { URI } from 'vscode-uri';
|
|
9
9
|
export interface DocumentServiceRuntimeContext {
|
|
10
10
|
typescript: typeof import('typescript/lib/tsserverlibrary');
|
|
11
|
-
plugins:
|
|
12
|
-
pluginContext:
|
|
11
|
+
plugins: LanguageServicePlugin[];
|
|
12
|
+
pluginContext: LanguageServicePluginContext;
|
|
13
13
|
getSourceFileDocument(document: TextDocument): [SourceFileDocument, EmbeddedLanguageModule] | undefined;
|
|
14
14
|
updateSourceFile(sourceFile: SourceFile, snapshot: ts.IScriptSnapshot): void;
|
|
15
15
|
prepareLanguageServices(document: TextDocument): void;
|
|
@@ -19,11 +19,11 @@ export interface LanguageServiceRuntimeContext {
|
|
|
19
19
|
core: EmbeddedLanguageContext;
|
|
20
20
|
typescriptLanguageService: ts.LanguageService;
|
|
21
21
|
documents: SourceFileDocuments;
|
|
22
|
-
plugins:
|
|
23
|
-
pluginContext:
|
|
22
|
+
plugins: LanguageServicePlugin[];
|
|
23
|
+
pluginContext: LanguageServicePluginContext;
|
|
24
24
|
getTextDocument(uri: string): TextDocument | undefined;
|
|
25
25
|
}
|
|
26
|
-
export interface
|
|
26
|
+
export interface LanguageServicePluginContext {
|
|
27
27
|
typescript: {
|
|
28
28
|
module: typeof import('typescript/lib/tsserverlibrary');
|
|
29
29
|
languageServiceHost: ts.LanguageServiceHost;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
2
|
import type { DocumentServiceRuntimeContext, LanguageServiceRuntimeContext } from '../types';
|
|
3
|
-
import {
|
|
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:
|
|
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:
|
|
7
|
-
export declare function languageFeatureWorker<T, K>(context: LanguageServiceRuntimeContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | K[], worker: (plugin:
|
|
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
|
+
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.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -16,11 +16,11 @@
|
|
|
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.2",
|
|
20
|
+
"@volar/shared": "1.0.0-beta.2",
|
|
21
|
+
"@volar/source-map": "1.0.0-beta.2",
|
|
22
|
+
"@volar/transforms": "1.0.0-beta.2",
|
|
23
|
+
"@volar/typescript-faster": "1.0.0-beta.2",
|
|
24
24
|
"@vue/reactivity": "^3.2.38",
|
|
25
25
|
"upath": "^2.0.1",
|
|
26
26
|
"vscode-html-languageservice": "^5.0.1",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
30
30
|
"vscode-uri": "^3.0.3"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "a523013ad349e28c9d0a7d9ad3f0c0834e0067e7"
|
|
33
33
|
}
|