@volar/language-service 1.0.20 → 1.0.21
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/documentFeatures/colorPresentations.js +2 -2
- package/out/documentFeatures/documentColors.js +2 -2
- package/out/documentFeatures/documentSymbols.js +2 -2
- package/out/documentFeatures/linkedEditingRanges.js +2 -2
- package/out/documentFeatures/selectionRanges.js +1 -1
- package/out/languageFeatures/complete.js +2 -2
- package/out/languageFeatures/completeResolve.js +1 -1
- package/out/languageFeatures/inlayHints.js +1 -1
- package/out/utils/featureWorkers.d.ts +2 -2
- package/out/utils/featureWorkers.js +4 -1
- package/package.json +7 -7
|
@@ -8,7 +8,7 @@ function register(context) {
|
|
|
8
8
|
if (file.capabilities.documentSymbol) // TODO: add color capability setting
|
|
9
9
|
return map.toGeneratedRanges(range);
|
|
10
10
|
return [];
|
|
11
|
-
}, (plugin, document, range) => { var _a; return (_a = plugin.getColorPresentations) === null || _a === void 0 ? void 0 : _a.call(plugin, document, color, range); }, (data, map) => data.map(cp => {
|
|
11
|
+
}, (plugin, document, range) => { var _a; return (_a = plugin.getColorPresentations) === null || _a === void 0 ? void 0 : _a.call(plugin, document, color, range); }, (data, map) => map ? data.map(cp => {
|
|
12
12
|
if (cp.textEdit) {
|
|
13
13
|
const range = map.toSourceRange(cp.textEdit.range);
|
|
14
14
|
if (!range)
|
|
@@ -24,7 +24,7 @@ function register(context) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return cp;
|
|
27
|
-
}).filter(shared.notEmpty));
|
|
27
|
+
}).filter(shared.notEmpty) : data);
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
exports.register = register;
|
|
@@ -6,12 +6,12 @@ const shared = require("@volar/shared");
|
|
|
6
6
|
function register(context) {
|
|
7
7
|
return (uri) => {
|
|
8
8
|
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, // TODO: add color capability setting
|
|
9
|
-
(plugin, document) => { var _a; return (_a = plugin.findDocumentColors) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => data.map(color => {
|
|
9
|
+
(plugin, document) => { var _a; return (_a = plugin.findDocumentColors) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => map ? data.map(color => {
|
|
10
10
|
const range = map.toSourceRange(color.range);
|
|
11
11
|
if (range) {
|
|
12
12
|
return vscode.ColorInformation.create(range, color.color);
|
|
13
13
|
}
|
|
14
|
-
}).filter(shared.notEmpty), arr => arr.flat());
|
|
14
|
+
}).filter(shared.notEmpty) : data, arr => arr.flat());
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
exports.register = register;
|
|
@@ -6,13 +6,13 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
6
6
|
function register(context) {
|
|
7
7
|
return (uri) => {
|
|
8
8
|
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, // TODO: add color capabilitie setting
|
|
9
|
-
(plugin, document) => { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => (0, transforms_1.transformSymbolInformations)(data, location => {
|
|
9
|
+
(plugin, document) => { var _a; return (_a = plugin.findDocumentSymbols) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => map ? (0, transforms_1.transformSymbolInformations)(data, location => {
|
|
10
10
|
const range = map.toSourceRange(location.range);
|
|
11
11
|
if (range) {
|
|
12
12
|
// use document.uri instead of map.sourceDocument.uri to fix https://github.com/johnsoncodehk/volar/issues/1925
|
|
13
13
|
return vscode.Location.create(uri, range);
|
|
14
14
|
}
|
|
15
|
-
}), arr => arr.flat());
|
|
15
|
+
}) : data, arr => arr.flat());
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
exports.register = register;
|
|
@@ -4,10 +4,10 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
4
4
|
const shared = require("@volar/shared");
|
|
5
5
|
function register(context) {
|
|
6
6
|
return (uri, position) => {
|
|
7
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => { var _a; return (_a = plugin.findLinkedEditingRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position); }, (data, map) => ({
|
|
7
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => { var _a; return (_a = plugin.findLinkedEditingRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position); }, (data, map) => map ? ({
|
|
8
8
|
wordPattern: data.wordPattern,
|
|
9
9
|
ranges: data.ranges.map(range => map.toSourceRange(range)).filter(shared.notEmpty),
|
|
10
|
-
}));
|
|
10
|
+
}) : data);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
exports.register = register;
|
|
@@ -15,7 +15,7 @@ function register(context) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
return [];
|
|
18
|
-
}, (plugin, document, positions) => { var _a; return (_a = plugin.getSelectionRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, positions); }, (item, map) => (0, transforms_1.transformSelectionRanges)(item, range => map.toSourceRange(range)), results => {
|
|
18
|
+
}, (plugin, document, positions) => { var _a; return (_a = plugin.getSelectionRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, positions); }, (item, map) => map ? (0, transforms_1.transformSelectionRanges)(item, range => map.toSourceRange(range)) : item, results => {
|
|
19
19
|
for (let i = 0; i < results[0].length; i++) {
|
|
20
20
|
const first = results[0][i];
|
|
21
21
|
let lastParent = first;
|
|
@@ -32,7 +32,7 @@ function register(context) {
|
|
|
32
32
|
cacheData.list.isIncomplete = false;
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
|
-
cacheData.list = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), (newItem, oldItem) => newItem.data = {
|
|
35
|
+
cacheData.list = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
36
36
|
uri,
|
|
37
37
|
originalItem: oldItem,
|
|
38
38
|
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
@@ -100,7 +100,7 @@ function register(context) {
|
|
|
100
100
|
if (!isAdditional) {
|
|
101
101
|
cache.mainCompletion = { documentUri: map.virtualFileDocument.uri };
|
|
102
102
|
}
|
|
103
|
-
const completionList = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), (newItem, oldItem) => newItem.data = {
|
|
103
|
+
const completionList = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), map.virtualFileDocument, (newItem, oldItem) => newItem.data = {
|
|
104
104
|
uri,
|
|
105
105
|
originalItem: oldItem,
|
|
106
106
|
pluginId: context.plugins.indexOf(plugin),
|
|
@@ -55,7 +55,7 @@ function register(context) {
|
|
|
55
55
|
if (!map)
|
|
56
56
|
return _inlayHint;
|
|
57
57
|
const position = map.toSourcePosition(_inlayHint.position);
|
|
58
|
-
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => (0, transforms_1.transformTextEdit)(textEdit, range => map.toSourceRange(range))).filter(shared.notEmpty);
|
|
58
|
+
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => (0, transforms_1.transformTextEdit)(textEdit, range => map.toSourceRange(range), map.virtualFileDocument)).filter(shared.notEmpty);
|
|
59
59
|
if (position) {
|
|
60
60
|
return Object.assign(Object.assign({}, _inlayHint), { position,
|
|
61
61
|
edits });
|
|
@@ -2,5 +2,5 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
|
2
2
|
import type { LanguageServicePluginInstance, LanguageServiceRuntimeContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, VirtualFile } from '@volar/language-service';
|
|
4
4
|
import { SourceMapWithDocuments } from '../documents';
|
|
5
|
-
export declare function documentFeatureWorker<T>(context: LanguageServiceRuntimeContext, uri: string, isValidSourceMap: (file: VirtualFile, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>) => boolean, worker: (plugin: LanguageServicePluginInstance, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: SourceMapWithDocuments<FileRangeCapabilities>) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
6
|
-
export declare function languageFeatureWorker<T, K>(context: LanguageServiceRuntimeContext, 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>) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
|
|
5
|
+
export declare function documentFeatureWorker<T>(context: LanguageServiceRuntimeContext, 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: LanguageServiceRuntimeContext, 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>;
|
|
@@ -50,7 +50,10 @@ function languageFeatureWorker(context, uri, arg, transformArg, worker, transfor
|
|
|
50
50
|
}
|
|
51
51
|
else if (document) {
|
|
52
52
|
for (const plugin of context.plugins) {
|
|
53
|
-
const
|
|
53
|
+
const embeddedResult = yield worker(plugin, document, arg, undefined, undefined);
|
|
54
|
+
if (!embeddedResult)
|
|
55
|
+
continue;
|
|
56
|
+
const result = transform(embeddedResult, undefined);
|
|
54
57
|
if (!result)
|
|
55
58
|
continue;
|
|
56
59
|
results.push(result);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.0.
|
|
17
|
-
"@volar/shared": "1.0.
|
|
18
|
-
"@volar/source-map": "1.0.
|
|
19
|
-
"@volar/transforms": "1.0.
|
|
20
|
-
"@volar/typescript-faster": "1.0.
|
|
16
|
+
"@volar/language-core": "1.0.21",
|
|
17
|
+
"@volar/shared": "1.0.21",
|
|
18
|
+
"@volar/source-map": "1.0.21",
|
|
19
|
+
"@volar/transforms": "1.0.21",
|
|
20
|
+
"@volar/typescript-faster": "1.0.21",
|
|
21
21
|
"vscode-html-languageservice": "^5.0.3",
|
|
22
22
|
"vscode-json-languageservice": "^5.1.3",
|
|
23
23
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
24
24
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
25
25
|
"vscode-uri": "^3.0.7"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "72332760759e06eed18e62026185cbad70250367"
|
|
28
28
|
}
|