@volar/language-service 2.3.0-alpha.1 → 2.3.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/lib/features/provideCodeActions.js +1 -1
- package/lib/features/provideCodeLenses.d.ts +1 -1
- package/lib/features/provideCodeLenses.js +1 -1
- package/lib/features/provideDiagnostics.d.ts +1 -1
- package/lib/features/provideDiagnostics.js +2 -2
- package/lib/features/provideDocumentFormattingEdits.js +4 -13
- package/lib/features/provideDocumentSemanticTokens.js +5 -2
- package/lib/features/provideDocumentSymbols.js +1 -1
- package/lib/languageService.js +1 -1
- package/lib/utils/dedupe.d.ts +1 -1
- package/lib/utils/featureWorkers.js +1 -1
- package/lib/utils/transform.js +26 -30
- package/package.json +3 -3
|
@@ -39,7 +39,7 @@ function register(context) {
|
|
|
39
39
|
if (data && data.version !== document.version) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
|
-
return data?.
|
|
42
|
+
return data?.pluginIndex === pluginIndex;
|
|
43
43
|
}).map(diagnostic => {
|
|
44
44
|
const data = diagnostic.data;
|
|
45
45
|
return {
|
|
@@ -12,6 +12,6 @@ export interface ServiceReferencesCodeLensData {
|
|
|
12
12
|
sourceFileUri: string;
|
|
13
13
|
workerFileUri: string;
|
|
14
14
|
workerFileRange: vscode.Range;
|
|
15
|
-
|
|
15
|
+
pluginIndex: number;
|
|
16
16
|
}
|
|
17
17
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -137,7 +137,7 @@ function register(context) {
|
|
|
137
137
|
errorsUpdated = false;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
function collectErrors() {
|
|
141
141
|
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
142
142
|
}
|
|
143
143
|
async function worker(api, cacheMap, cache) {
|
|
@@ -162,7 +162,7 @@ function register(context) {
|
|
|
162
162
|
error.data = {
|
|
163
163
|
uri: uri.toString(),
|
|
164
164
|
version: document.version,
|
|
165
|
-
|
|
165
|
+
pluginIndex: pluginIndex,
|
|
166
166
|
isFormat: false,
|
|
167
167
|
original: {
|
|
168
168
|
data: error.data,
|
|
@@ -8,7 +8,6 @@ const documents_1 = require("../documents");
|
|
|
8
8
|
const cancellation_1 = require("../utils/cancellation");
|
|
9
9
|
const common_1 = require("../utils/common");
|
|
10
10
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
11
|
-
const uriMap_1 = require("../utils/uriMap");
|
|
12
11
|
function register(context) {
|
|
13
12
|
let fakeVersion = 0;
|
|
14
13
|
return async (uri, options, range, onTypeParams, token = cancellation_1.NoneCancellationToken) => {
|
|
@@ -30,7 +29,7 @@ function register(context) {
|
|
|
30
29
|
const startOffset = document.offsetAt(range.start);
|
|
31
30
|
const endOffset = document.offsetAt(range.end);
|
|
32
31
|
for (const code of (0, language_core_1.forEachEmbeddedCode)(sourceScript.generated.root)) {
|
|
33
|
-
const map = context.language.maps.get(code);
|
|
32
|
+
const map = context.language.maps.get(code, sourceScript);
|
|
34
33
|
if (map) {
|
|
35
34
|
const embeddedRange = (0, common_1.findOverlapCodeRange)(startOffset, endOffset, map, language_core_1.isFormattingEnabled);
|
|
36
35
|
if (embeddedRange) {
|
|
@@ -179,17 +178,9 @@ function register(context) {
|
|
|
179
178
|
}
|
|
180
179
|
};
|
|
181
180
|
function createDocMap(virtualCode, documentUri, sourceLanguageId, _sourceSnapshot) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
return [documentUri, _sourceSnapshot];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
if (mapOfMap.has(documentUri) && mapOfMap.get(documentUri)[0] === _sourceSnapshot) {
|
|
189
|
-
const map = mapOfMap.get(documentUri);
|
|
190
|
-
const version = fakeVersion++;
|
|
191
|
-
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1], virtualCode);
|
|
192
|
-
}
|
|
181
|
+
const map = new language_core_1.SourceMap(virtualCode.mappings);
|
|
182
|
+
const version = fakeVersion++;
|
|
183
|
+
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map, virtualCode);
|
|
193
184
|
}
|
|
194
185
|
}
|
|
195
186
|
exports.register = register;
|
|
@@ -7,7 +7,8 @@ const cancellation_1 = require("../utils/cancellation");
|
|
|
7
7
|
const common_1 = require("../utils/common");
|
|
8
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
9
|
function register(context) {
|
|
10
|
-
return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress
|
|
10
|
+
return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress // TODO
|
|
11
|
+
) => {
|
|
11
12
|
const sourceScript = context.language.scripts.get(uri);
|
|
12
13
|
if (!sourceScript) {
|
|
13
14
|
return;
|
|
@@ -47,7 +48,9 @@ function register(context) {
|
|
|
47
48
|
}
|
|
48
49
|
})
|
|
49
50
|
.filter(common_1.notEmpty);
|
|
50
|
-
}, tokens => tokens.flat()
|
|
51
|
+
}, tokens => tokens.flat()
|
|
52
|
+
// tokens => reportProgress?.(buildTokens(tokens)), // TODO: this has no effect with LSP
|
|
53
|
+
);
|
|
51
54
|
if (tokens) {
|
|
52
55
|
return buildTokens(tokens);
|
|
53
56
|
}
|
|
@@ -8,7 +8,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
8
8
|
const transform_1 = require("../utils/transform");
|
|
9
9
|
function register(context) {
|
|
10
10
|
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)),
|
|
11
|
+
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), (plugin, document) => {
|
|
12
12
|
if (token.isCancellationRequested) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
package/lib/languageService.js
CHANGED
|
@@ -60,7 +60,7 @@ function createLanguageService(language, plugins, env) {
|
|
|
60
60
|
return map.get(uri);
|
|
61
61
|
},
|
|
62
62
|
*getMaps(virtualCode) {
|
|
63
|
-
for (const [uri,
|
|
63
|
+
for (const [uri, snapshot, map] of context.language.maps.forEach(virtualCode)) {
|
|
64
64
|
if (!map2DocMap.has(map)) {
|
|
65
65
|
const embeddedUri = context.encodeEmbeddedDocumentUri(uri, virtualCode.id);
|
|
66
66
|
map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(uri, context.language.scripts.get(uri).languageId, snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
|
package/lib/utils/dedupe.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function createLocationSet(): {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function withCodeAction<T extends vscode.CodeAction>(items: T[]): T[];
|
|
7
7
|
export declare function withTextEdits<T extends vscode.TextEdit>(items: T[]): T[];
|
|
8
|
-
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.
|
|
8
|
+
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.CreateFile | vscode.TextDocumentEdit | vscode.RenameFile | vscode.DeleteFile)[];
|
|
9
9
|
export declare function withDiagnostics<T extends vscode.Diagnostic>(items: T[]): T[];
|
|
10
10
|
export declare function withLocations<T extends vscode.Location>(items: T[]): T[];
|
|
11
11
|
export declare function withLocationLinks<T extends vscode.LocationLink>(items: T[]): T[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEmbeddedFilesByLevel = exports.forEachEmbeddedDocument = exports.safeCall = exports.languageFeatureWorker = exports.documentFeatureWorker = void 0;
|
|
4
|
-
|
|
4
|
+
function documentFeatureWorker(context, uri, valid, worker, transformResult, combineResult) {
|
|
5
5
|
return languageFeatureWorker(context, uri, () => void 0, function* (map) {
|
|
6
6
|
if (valid(map)) {
|
|
7
7
|
yield;
|
package/lib/utils/transform.js
CHANGED
|
@@ -10,43 +10,39 @@ function transformDocumentLinkTarget(_target, context) {
|
|
|
10
10
|
if (!decoded) {
|
|
11
11
|
return target;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const sourceScript = context.language.scripts.get(
|
|
13
|
+
const embeddedRange = target.fragment.match(/^L(\d+)(,(\d+))?(-L(\d+)(,(\d+))?)?$/);
|
|
14
|
+
const sourceScript = context.language.scripts.get(decoded[0]);
|
|
15
15
|
const virtualCode = sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
16
|
-
|
|
16
|
+
target = decoded[0];
|
|
17
|
+
if (embeddedRange && virtualCode) {
|
|
17
18
|
for (const map of context.documents.getMaps(virtualCode)) {
|
|
18
19
|
if (!map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data))) {
|
|
19
20
|
continue;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
const startLine = Number(embeddedRange[1]) - 1;
|
|
23
|
+
const startCharacter = Number(embeddedRange[3] ?? 1) - 1;
|
|
24
|
+
if (embeddedRange[5] !== undefined) {
|
|
25
|
+
const endLine = Number(embeddedRange[5]) - 1;
|
|
26
|
+
const endCharacter = Number(embeddedRange[7] ?? 1) - 1;
|
|
27
|
+
const sourceRange = map.getSourceRange({
|
|
28
|
+
start: { line: startLine, character: startCharacter },
|
|
29
|
+
end: { line: endLine, character: endCharacter },
|
|
30
|
+
});
|
|
31
|
+
if (sourceRange) {
|
|
32
|
+
target = target.with({
|
|
33
|
+
fragment: 'L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1)
|
|
34
|
+
+ '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1),
|
|
33
35
|
});
|
|
34
|
-
|
|
35
|
-
target = target.with({
|
|
36
|
-
fragment: 'L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1)
|
|
37
|
-
+ '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1),
|
|
38
|
-
});
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
36
|
+
break;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const sourcePos = map.getSourcePosition({ line: startLine, character: startCharacter });
|
|
41
|
+
if (sourcePos) {
|
|
42
|
+
target = target.with({
|
|
43
|
+
fragment: 'L' + (sourcePos.line + 1) + ',' + (sourcePos.character + 1),
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/language-service"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.3.0-alpha.
|
|
15
|
+
"@volar/language-core": "2.3.0-alpha.10",
|
|
16
16
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
17
17
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
18
18
|
"vscode-uri": "^3.0.8"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "44fffdc323ca3ff55818a8656a2726867df53a76"
|
|
21
21
|
}
|