@volar/language-service 1.0.11 → 1.0.13
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.js +1 -1
- package/out/baseLanguageService.js +2 -2
- package/out/documentFeatures/autoInsert.js +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +1 -1
- package/out/documents.d.ts +2 -3
- package/out/documents.js +6 -6
- package/out/languageFeatures/codeActions.js +1 -1
- package/out/languageFeatures/codeLens.js +1 -1
- package/out/languageFeatures/definition.js +1 -1
- package/out/languageFeatures/documentHighlights.js +1 -1
- package/out/languageFeatures/documentLinks.js +1 -1
- package/out/languageFeatures/fileReferences.js +1 -1
- package/out/languageFeatures/inlayHints.js +2 -2
- package/out/languageFeatures/references.js +2 -2
- package/out/languageFeatures/rename.js +2 -2
- package/out/languageFeatures/signatureHelp.js +1 -1
- package/out/languageFeatures/validation.js +1 -1
- package/package.json +7 -7
|
@@ -54,7 +54,7 @@ function createDocumentServiceContext(options) {
|
|
|
54
54
|
let sourceFile = languageModule.createSourceFile('/untitled.' + shared.languageIdToSyntax(document.languageId), ts.ScriptSnapshot.fromString(document.getText()));
|
|
55
55
|
if (sourceFile) {
|
|
56
56
|
sourceFile = (0, reactivity_1.shallowReactive)(sourceFile);
|
|
57
|
-
const sourceFileDoc = (0, documents_1.parseSourceFileDocument)(
|
|
57
|
+
const sourceFileDoc = (0, documents_1.parseSourceFileDocument)(sourceFile);
|
|
58
58
|
cache = [sourceFileDoc, languageModule];
|
|
59
59
|
vueDocuments.set(document, cache);
|
|
60
60
|
fileMods.set(sourceFile, languageModule);
|
|
@@ -40,7 +40,7 @@ function createLanguageServiceContext(options) {
|
|
|
40
40
|
languageService: tsLs,
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
const textDocumentMapper = (0, documents_1.parseSourceFileDocuments)(options.
|
|
43
|
+
const textDocumentMapper = (0, documents_1.parseSourceFileDocuments)(options.context.mapper);
|
|
44
44
|
const documents = new WeakMap();
|
|
45
45
|
const documentVersions = new Map();
|
|
46
46
|
const context = {
|
|
@@ -86,7 +86,7 @@ function createLanguageService(context) {
|
|
|
86
86
|
findFileReferences: fileReferences.register(context),
|
|
87
87
|
findDefinition: definition.register(context, 'findDefinition', data => !!data.definition, data => !!data.definition),
|
|
88
88
|
findTypeDefinition: definition.register(context, 'findTypeDefinition', data => !!data.definition, data => !!data.definition),
|
|
89
|
-
findImplementations: definition.register(context, 'findImplementations', data => !!data.references,
|
|
89
|
+
findImplementations: definition.register(context, 'findImplementations', data => !!data.references, () => false),
|
|
90
90
|
prepareRename: renamePrepare.register(context),
|
|
91
91
|
doRename: rename.register(context),
|
|
92
92
|
getEditsForFileRename: fileRename.register(context),
|
|
@@ -3,7 +3,7 @@ exports.register = void 0;
|
|
|
3
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
4
|
function register(context) {
|
|
5
5
|
return (document, position, options) => {
|
|
6
|
-
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, position,
|
|
6
|
+
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, position, () => true, (position, sourceMap) => sourceMap.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => { var _a; return (_a = plugin.doAutoInsert) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, options); }, (data, sourceMap) => {
|
|
7
7
|
if (typeof data === 'string')
|
|
8
8
|
return data;
|
|
9
9
|
const range = sourceMap.toSourceRange(data.range);
|
|
@@ -4,7 +4,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
4
4
|
const shared = require("@volar/shared");
|
|
5
5
|
function register(context) {
|
|
6
6
|
return (document, position) => {
|
|
7
|
-
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, position,
|
|
7
|
+
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, position, () => true, (position, sourceMap) => sourceMap.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, sourceMap) => ({
|
|
8
8
|
wordPattern: data.wordPattern,
|
|
9
9
|
ranges: data.ranges.map(range => sourceMap.toSourceRange(range)).filter(shared.notEmpty),
|
|
10
10
|
}));
|
package/out/documents.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { DocumentRegistry, EmbeddedFile, PositionCapabilities, SourceFile, Telep
|
|
|
2
2
|
import { Mapping, SourceMapBase } from '@volar/source-map';
|
|
3
3
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
|
-
import { URI } from 'vscode-uri';
|
|
6
5
|
export type SourceFileDocuments = ReturnType<typeof parseSourceFileDocuments>;
|
|
7
6
|
export type SourceFileDocument = ReturnType<typeof parseSourceFileDocument>;
|
|
8
7
|
export declare class SourceMap<Data = undefined> extends SourceMapBase<Data> {
|
|
@@ -37,7 +36,7 @@ export declare class TeleportSourceMap extends SourceMap<TeleportMappingData> {
|
|
|
37
36
|
constructor(embeddedFile: EmbeddedFile, document: TextDocument, mappings: Mapping<TeleportMappingData>[]);
|
|
38
37
|
findTeleports(start: vscode.Position): Generator<readonly [import("vscode-languageserver-textdocument").Position, import("@volar/language-core").TeleportCapabilities], void, unknown>;
|
|
39
38
|
}
|
|
40
|
-
export declare function parseSourceFileDocuments(
|
|
39
|
+
export declare function parseSourceFileDocuments(mapper: DocumentRegistry): {
|
|
41
40
|
getAll: () => {
|
|
42
41
|
uri: string;
|
|
43
42
|
file: SourceFile;
|
|
@@ -68,7 +67,7 @@ export declare function parseSourceFileDocuments(rootUri: URI, mapper: DocumentR
|
|
|
68
67
|
sourceMapFromEmbeddedDocumentUri: (uri: string) => EmbeddedDocumentSourceMap | undefined;
|
|
69
68
|
teleportfromEmbeddedDocumentUri: (uri: string) => TeleportSourceMap | undefined;
|
|
70
69
|
};
|
|
71
|
-
export declare function parseSourceFileDocument(
|
|
70
|
+
export declare function parseSourceFileDocument(sourceFile: SourceFile): {
|
|
72
71
|
uri: string;
|
|
73
72
|
file: SourceFile;
|
|
74
73
|
getSourceMap: (embedded: EmbeddedFile) => EmbeddedDocumentSourceMap;
|
package/out/documents.js
CHANGED
|
@@ -135,7 +135,7 @@ class TeleportSourceMap extends SourceMap {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
exports.TeleportSourceMap = TeleportSourceMap;
|
|
138
|
-
function parseSourceFileDocuments(
|
|
138
|
+
function parseSourceFileDocuments(mapper) {
|
|
139
139
|
const _sourceFiles = new WeakMap();
|
|
140
140
|
// reactivity
|
|
141
141
|
const embeddedDocumentsMap = (0, reactivity_1.computed)(() => {
|
|
@@ -187,7 +187,7 @@ function parseSourceFileDocuments(rootUri, mapper) {
|
|
|
187
187
|
function get(sourceFile) {
|
|
188
188
|
let vueDocument = _sourceFiles.get(sourceFile);
|
|
189
189
|
if (!vueDocument) {
|
|
190
|
-
vueDocument = parseSourceFileDocument(
|
|
190
|
+
vueDocument = parseSourceFileDocument(sourceFile);
|
|
191
191
|
_sourceFiles.set(sourceFile, vueDocument);
|
|
192
192
|
}
|
|
193
193
|
return vueDocument;
|
|
@@ -197,13 +197,13 @@ function parseSourceFileDocuments(rootUri, mapper) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
exports.parseSourceFileDocuments = parseSourceFileDocuments;
|
|
200
|
-
function parseSourceFileDocument(
|
|
200
|
+
function parseSourceFileDocument(sourceFile) {
|
|
201
201
|
let documentVersion = 0;
|
|
202
202
|
const embeddedDocumentVersions = new Map();
|
|
203
203
|
const embeddedDocuments = new WeakMap();
|
|
204
204
|
const sourceMaps = new WeakMap();
|
|
205
205
|
// computed
|
|
206
|
-
const document = (0, reactivity_1.computed)(() => vscode_languageserver_textdocument_1.TextDocument.create(shared.getUriByPath(
|
|
206
|
+
const document = (0, reactivity_1.computed)(() => vscode_languageserver_textdocument_1.TextDocument.create(shared.getUriByPath(sourceFile.fileName), sourceFile.fileName.endsWith('.md') ? 'markdown' : 'vue', documentVersion++, sourceFile.text));
|
|
207
207
|
const allSourceMaps = (0, reactivity_1.computed)(() => {
|
|
208
208
|
const result = [];
|
|
209
209
|
(0, language_core_1.forEachEmbeddeds)(sourceFile.embeddeds, embedded => {
|
|
@@ -223,7 +223,7 @@ function parseSourceFileDocument(rootUri, sourceFile) {
|
|
|
223
223
|
return result;
|
|
224
224
|
});
|
|
225
225
|
return {
|
|
226
|
-
uri: shared.getUriByPath(
|
|
226
|
+
uri: shared.getUriByPath(sourceFile.fileName),
|
|
227
227
|
file: sourceFile,
|
|
228
228
|
getSourceMap,
|
|
229
229
|
getEmbeddedDocument,
|
|
@@ -246,7 +246,7 @@ function parseSourceFileDocument(rootUri, sourceFile) {
|
|
|
246
246
|
var _a;
|
|
247
247
|
let document = embeddedDocuments.get(embeddedFile);
|
|
248
248
|
if (!document || document.getText() !== embeddedFile.text) {
|
|
249
|
-
const uri = shared.getUriByPath(
|
|
249
|
+
const uri = shared.getUriByPath(embeddedFile.fileName);
|
|
250
250
|
const newVersion = ((_a = embeddedDocumentVersions.get(uri.toLowerCase())) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
251
251
|
embeddedDocumentVersions.set(uri.toLowerCase(), newVersion);
|
|
252
252
|
document = vscode_languageserver_textdocument_1.TextDocument.create(uri, shared.syntaxToLanguageId(embeddedFile.fileName.split('.').pop()), newVersion, embeddedFile.text);
|
|
@@ -25,7 +25,7 @@ function register(context) {
|
|
|
25
25
|
start: document.offsetAt(range.start),
|
|
26
26
|
end: document.offsetAt(range.end),
|
|
27
27
|
};
|
|
28
|
-
let codeActions = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (
|
|
28
|
+
let codeActions = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, { range, codeActionContext }, (_arg, sourceMap) => {
|
|
29
29
|
var _a, _b;
|
|
30
30
|
if (!sourceMap.embeddedFile.capabilities.codeAction)
|
|
31
31
|
return [];
|
|
@@ -15,7 +15,7 @@ const executeCommand_1 = require("./executeCommand");
|
|
|
15
15
|
function register(context) {
|
|
16
16
|
return (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
var _a;
|
|
18
|
-
return (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg
|
|
18
|
+
return (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
var _b, _c;
|
|
20
20
|
const codeLens = yield ((_c = (_b = plugin.codeLens) === null || _b === void 0 ? void 0 : _b.on) === null || _c === void 0 ? void 0 : _c.call(_b, document));
|
|
21
21
|
if (codeLens) {
|
|
@@ -14,7 +14,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
15
|
function register(context, api, isValidMappingData, isValidTeleportSideData) {
|
|
16
16
|
return (uri, position) => {
|
|
17
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, isValidMappingData), (plugin, document, position
|
|
17
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, isValidMappingData), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const recursiveChecker = dedupe.createLocationSet();
|
|
19
19
|
const result = [];
|
|
20
20
|
yield withTeleports(document, position, undefined);
|
|
@@ -16,7 +16,7 @@ function register(context) {
|
|
|
16
16
|
return (uri, position) => {
|
|
17
17
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position,
|
|
18
18
|
// note https://github.com/johnsoncodehk/volar/issues/2009
|
|
19
|
-
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position
|
|
19
|
+
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const recursiveChecker = dedupe.createLocationSet();
|
|
21
21
|
const result = [];
|
|
22
22
|
yield withTeleports(document, position);
|
|
@@ -14,7 +14,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
17
|
-
const pluginLinks = (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg
|
|
17
|
+
const pluginLinks = (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => { var _a; return (_a = plugin.findDocumentLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, sourceMap) => data.map(link => {
|
|
18
18
|
if (!sourceMap)
|
|
19
19
|
return link;
|
|
20
20
|
const range = sourceMap.toSourceRange(link.range);
|
|
@@ -19,7 +19,7 @@ function register(context) {
|
|
|
19
19
|
}, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b;
|
|
21
21
|
return (_b = yield ((_a = plugin.findFileReferences) === null || _a === void 0 ? void 0 : _a.call(plugin, document))) !== null && _b !== void 0 ? _b : [];
|
|
22
|
-
}), (data
|
|
22
|
+
}), (data) => data.map(reference => {
|
|
23
23
|
const map = context.documents.sourceMapFromEmbeddedDocumentUri(reference.uri);
|
|
24
24
|
if (!map) {
|
|
25
25
|
return reference;
|
|
@@ -23,7 +23,7 @@ function register(context) {
|
|
|
23
23
|
start: document.offsetAt(range.start),
|
|
24
24
|
end: document.offsetAt(range.end),
|
|
25
25
|
};
|
|
26
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, range, (
|
|
26
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, range, (_arg, sourceMap) => {
|
|
27
27
|
/**
|
|
28
28
|
* copy from ./codeActions.ts
|
|
29
29
|
*/
|
|
@@ -47,7 +47,7 @@ function register(context) {
|
|
|
47
47
|
return [vscode.Range.create(sourceMap.mappedDocument.positionAt(minStart), sourceMap.mappedDocument.positionAt(maxEnd))];
|
|
48
48
|
}
|
|
49
49
|
return [];
|
|
50
|
-
}, (plugin, document, arg
|
|
50
|
+
}, (plugin, document, arg) => {
|
|
51
51
|
var _a, _b;
|
|
52
52
|
return (_b = (_a = plugin.inlayHints) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, arg);
|
|
53
53
|
}, (inlayHints, sourceMap) => inlayHints.map(_inlayHint => {
|
|
@@ -13,7 +13,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
13
13
|
const dedupe = require("../utils/dedupe");
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (uri, position) => {
|
|
16
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, data => !!data.references), (plugin, document, position
|
|
16
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, data => !!data.references), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const recursiveChecker = dedupe.createLocationSet();
|
|
18
18
|
const result = [];
|
|
19
19
|
yield withTeleports(document, position);
|
|
@@ -47,7 +47,7 @@ function register(context) {
|
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
}), (data
|
|
50
|
+
}), (data) => {
|
|
51
51
|
const results = [];
|
|
52
52
|
for (const reference of data) {
|
|
53
53
|
const map = context.documents.sourceMapFromEmbeddedDocumentUri(reference.uri);
|
|
@@ -27,7 +27,7 @@ function register(context) {
|
|
|
27
27
|
yield { position: mapped, newName };
|
|
28
28
|
}
|
|
29
29
|
;
|
|
30
|
-
}, (plugin, document, arg
|
|
30
|
+
}, (plugin, document, arg) => __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const recursiveChecker = dedupe.createLocationSet();
|
|
32
32
|
let result;
|
|
33
33
|
yield withTeleports(document, arg.position, arg.newName);
|
|
@@ -86,7 +86,7 @@ function register(context) {
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
}), (data
|
|
89
|
+
}), (data) => {
|
|
90
90
|
return embeddedEditToSourceEdit(data, context.documents);
|
|
91
91
|
}, (workspaceEdits) => {
|
|
92
92
|
const mainEdit = workspaceEdits[0];
|
|
@@ -3,7 +3,7 @@ exports.register = void 0;
|
|
|
3
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
4
|
function register(context) {
|
|
5
5
|
return (uri, position, signatureHelpContext) => {
|
|
6
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => { var _a; return (_a = plugin.getSignatureHelp) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, signatureHelpContext); }, (data
|
|
6
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, sourceMap) => sourceMap.toGeneratedPositions(position, data => !!data.completion), (plugin, document, position) => { var _a; return (_a = plugin.getSignatureHelp) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position, signatureHelpContext); }, (data) => data);
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
exports.register = register;
|
|
@@ -150,7 +150,7 @@ function register(context) {
|
|
|
150
150
|
if (sourceMap.embeddedFile.capabilities.diagnostic) {
|
|
151
151
|
yield arg;
|
|
152
152
|
}
|
|
153
|
-
}, (plugin, document
|
|
153
|
+
}, (plugin, document) => __awaiter(this, void 0, void 0, function* () {
|
|
154
154
|
var _a, _b, _c, _d, _e;
|
|
155
155
|
if (token) {
|
|
156
156
|
if (Date.now() - lastCheckCancelAt >= 5) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,11 +13,11 @@
|
|
|
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.13",
|
|
17
|
+
"@volar/shared": "1.0.13",
|
|
18
|
+
"@volar/source-map": "1.0.13",
|
|
19
|
+
"@volar/transforms": "1.0.13",
|
|
20
|
+
"@volar/typescript-faster": "1.0.13",
|
|
21
21
|
"@vue/reactivity": "^3.2.45",
|
|
22
22
|
"vscode-html-languageservice": "^5.0.3",
|
|
23
23
|
"vscode-json-languageservice": "^5.1.3",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
26
26
|
"vscode-uri": "^3.0.6"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "cba2eba187b2d82e1d45dd86b3edeab0ca7caad6"
|
|
29
29
|
}
|