@volar/language-service 1.0.0-alpha.4 → 1.0.0-beta.0
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 +1 -1
- package/out/baseLanguageService.d.ts +1 -1
- package/out/documents.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.js +8 -9
- package/out/languageFeatures/codeActions.js +8 -9
- package/out/languageFeatures/codeLens.js +5 -7
- package/out/languageFeatures/complete.js +28 -32
- package/out/languageFeatures/definition.js +18 -4
- package/out/languageFeatures/executeCommand.d.ts +1 -1
- package/out/plugin.d.ts +3 -3
- package/package.json +8 -8
|
@@ -4,7 +4,7 @@ import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
|
4
4
|
import { EmbeddedLanguageServicePlugin } from './plugin';
|
|
5
5
|
import { EmbeddedLanguageModule } from '@volar/language-core';
|
|
6
6
|
import type * as _0 from 'vscode-languageserver-protocol';
|
|
7
|
-
export
|
|
7
|
+
export type DocumentService = ReturnType<typeof createDocumentService>;
|
|
8
8
|
export declare function createDocumentServiceContext(options: {
|
|
9
9
|
ts: typeof import('typescript/lib/tsserverlibrary');
|
|
10
10
|
getLanguageModules(): EmbeddedLanguageModule[];
|
|
@@ -3,7 +3,7 @@ import * as executeCommand from './languageFeatures/executeCommand';
|
|
|
3
3
|
import { EmbeddedLanguageServicePlugin } from './plugin';
|
|
4
4
|
import { LanguageServiceRuntimeContext as LanguageServiceContext, PluginContext } from './types';
|
|
5
5
|
import type * as _0 from 'vscode-languageserver-protocol';
|
|
6
|
-
export
|
|
6
|
+
export type LanguageService = ReturnType<typeof createLanguageService>;
|
|
7
7
|
export declare function createLanguageServiceContext(options: {
|
|
8
8
|
host: LanguageServiceHost;
|
|
9
9
|
context: ReturnType<typeof createEmbeddedLanguageServiceHost>;
|
package/out/documents.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { SourceMapBase } from '@volar/source-map';
|
|
|
4
4
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
5
5
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
6
6
|
import { URI } from 'vscode-uri';
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type SourceFileDocuments = ReturnType<typeof parseSourceFileDocuments>;
|
|
8
|
+
export type SourceFileDocument = ReturnType<typeof parseSourceFileDocument>;
|
|
9
9
|
export declare class SourceMap<Data = undefined> {
|
|
10
10
|
sourceDocument: TextDocument;
|
|
11
11
|
mappedDocument: TextDocument;
|
|
@@ -24,15 +24,14 @@ function register(context) {
|
|
|
24
24
|
var _a;
|
|
25
25
|
const items = yield ((_a = plugin.callHierarchy) === null || _a === void 0 ? void 0 : _a.prepare(document, position));
|
|
26
26
|
return items === null || items === void 0 ? void 0 : items.map(item => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return Object.assign(Object.assign({}, item), { data: data });
|
|
27
|
+
return Object.assign(Object.assign({}, item), { data: {
|
|
28
|
+
uri,
|
|
29
|
+
originalItem: item,
|
|
30
|
+
pluginId: context.plugins.indexOf(plugin),
|
|
31
|
+
sourceMap: sourceMap ? {
|
|
32
|
+
embeddedDocumentUri: sourceMap.mappedDocument.uri,
|
|
33
|
+
} : undefined,
|
|
34
|
+
} });
|
|
36
35
|
});
|
|
37
36
|
}), (data, sourceMap) => !sourceMap ? data : data
|
|
38
37
|
.map(item => { var _a; return (_a = transformCallHierarchyItem(item, [])) === null || _a === void 0 ? void 0 : _a[0]; })
|
|
@@ -55,15 +55,14 @@ function register(context) {
|
|
|
55
55
|
var _a, _b;
|
|
56
56
|
const codeActions = yield ((_b = (_a = plugin.codeAction) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, arg.range, arg.codeActionContext));
|
|
57
57
|
return codeActions === null || codeActions === void 0 ? void 0 : codeActions.map(_codeAction => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return Object.assign(Object.assign({}, _codeAction), { data: data });
|
|
58
|
+
return Object.assign(Object.assign({}, _codeAction), { data: {
|
|
59
|
+
uri,
|
|
60
|
+
originalItem: _codeAction,
|
|
61
|
+
pluginId: context.plugins.indexOf(plugin),
|
|
62
|
+
sourceMap: sourceMap ? {
|
|
63
|
+
embeddedDocumentUri: sourceMap.mappedDocument.uri,
|
|
64
|
+
} : undefined,
|
|
65
|
+
} });
|
|
67
66
|
});
|
|
68
67
|
}), (_codeActions, sourceMap) => _codeActions.map(_codeAction => {
|
|
69
68
|
if (!sourceMap)
|
|
@@ -20,14 +20,12 @@ function register(context) {
|
|
|
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) {
|
|
22
22
|
return codeLens.map(item => {
|
|
23
|
-
const data = {
|
|
24
|
-
uri,
|
|
25
|
-
originalItem: item,
|
|
26
|
-
pluginId: context.plugins.indexOf(plugin),
|
|
27
|
-
};
|
|
28
23
|
const commandArgs = item.command ? [uri, context.plugins.indexOf(plugin), item.command] : undefined;
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
return Object.assign(Object.assign({}, item), { command: item.command && commandArgs ? Object.assign(Object.assign({}, item.command), { command: executeCommand_1.executePluginCommand, arguments: commandArgs }) : undefined, data: {
|
|
25
|
+
uri,
|
|
26
|
+
originalItem: item,
|
|
27
|
+
pluginId: context.plugins.indexOf(plugin),
|
|
28
|
+
} });
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
}), (data, sourceMap) => data.map(codeLens => {
|
|
@@ -35,15 +35,14 @@ function register(context) {
|
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
cacheData.list = Object.assign(Object.assign({}, embeddedCompletionList), { items: embeddedCompletionList.items.map(item => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => { var _a; return (_a = sourceMap.getSourceRange(embeddedRange.start, embeddedRange.end)) === null || _a === void 0 ? void 0 : _a[0]; })), { data: data });
|
|
38
|
+
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => { var _a; return (_a = sourceMap.getSourceRange(embeddedRange.start, embeddedRange.end)) === null || _a === void 0 ? void 0 : _a[0]; })), { data: {
|
|
39
|
+
uri,
|
|
40
|
+
originalItem: item,
|
|
41
|
+
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
42
|
+
sourceMap: {
|
|
43
|
+
embeddedDocumentUri: sourceMap.mappedDocument.uri,
|
|
44
|
+
},
|
|
45
|
+
} });
|
|
47
46
|
}) });
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -56,13 +55,12 @@ function register(context) {
|
|
|
56
55
|
continue;
|
|
57
56
|
}
|
|
58
57
|
cacheData.list = Object.assign(Object.assign({}, completionList), { items: completionList.items.map(item => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return Object.assign(Object.assign({}, item), { data: data });
|
|
58
|
+
return Object.assign(Object.assign({}, item), { data: {
|
|
59
|
+
uri,
|
|
60
|
+
originalItem: item,
|
|
61
|
+
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
62
|
+
sourceMap: undefined,
|
|
63
|
+
} });
|
|
66
64
|
}) });
|
|
67
65
|
}
|
|
68
66
|
}
|
|
@@ -101,15 +99,14 @@ function register(context) {
|
|
|
101
99
|
cache.mainCompletion = { documentUri: sourceMap.mappedDocument.uri };
|
|
102
100
|
}
|
|
103
101
|
const completionList = Object.assign(Object.assign({}, embeddedCompletionList), { items: embeddedCompletionList.items.map(item => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => { var _a; return (_a = sourceMap.getSourceRange(embeddedRange.start, embeddedRange.end)) === null || _a === void 0 ? void 0 : _a[0]; })), { data: data });
|
|
102
|
+
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => { var _a; return (_a = sourceMap.getSourceRange(embeddedRange.start, embeddedRange.end)) === null || _a === void 0 ? void 0 : _a[0]; })), { data: {
|
|
103
|
+
uri,
|
|
104
|
+
originalItem: item,
|
|
105
|
+
pluginId: context.plugins.indexOf(plugin),
|
|
106
|
+
sourceMap: {
|
|
107
|
+
embeddedDocumentUri: sourceMap.mappedDocument.uri,
|
|
108
|
+
}
|
|
109
|
+
} });
|
|
113
110
|
}) });
|
|
114
111
|
cache.data.push({
|
|
115
112
|
sourceMap: {
|
|
@@ -148,13 +145,12 @@ function register(context) {
|
|
|
148
145
|
sourceMap: undefined,
|
|
149
146
|
plugin,
|
|
150
147
|
list: Object.assign(Object.assign({}, completionList), { items: completionList.items.map(item => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return Object.assign(Object.assign({}, item), { data: data });
|
|
148
|
+
return Object.assign(Object.assign({}, item), { data: {
|
|
149
|
+
uri,
|
|
150
|
+
originalItem: item,
|
|
151
|
+
pluginId: context.plugins.indexOf(plugin),
|
|
152
|
+
sourceMap: undefined,
|
|
153
|
+
} });
|
|
158
154
|
}) }),
|
|
159
155
|
});
|
|
160
156
|
}
|
|
@@ -60,17 +60,17 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
}), (data, sourceMap) => data.map(link => {
|
|
63
|
-
var _a, _b
|
|
63
|
+
var _a, _b;
|
|
64
64
|
if (link.originSelectionRange && sourceMap) {
|
|
65
|
-
const originSelectionRange = (
|
|
65
|
+
const originSelectionRange = getSourceRangePreferSurroundedPosition(sourceMap, link.originSelectionRange, position);
|
|
66
66
|
if (!originSelectionRange)
|
|
67
67
|
return;
|
|
68
68
|
link.originSelectionRange = originSelectionRange;
|
|
69
69
|
}
|
|
70
70
|
const targetSourceMap = context.documents.sourceMapFromEmbeddedDocumentUri(link.targetUri);
|
|
71
71
|
if (targetSourceMap) {
|
|
72
|
-
const targetRange = (
|
|
73
|
-
const targetSelectionRange = (
|
|
72
|
+
const targetRange = (_a = targetSourceMap.getSourceRange(link.targetRange.start, link.targetRange.end)) === null || _a === void 0 ? void 0 : _a[0];
|
|
73
|
+
const targetSelectionRange = (_b = targetSourceMap.getSourceRange(link.targetSelectionRange.start, link.targetSelectionRange.end)) === null || _b === void 0 ? void 0 : _b[0];
|
|
74
74
|
if (!targetSelectionRange)
|
|
75
75
|
return;
|
|
76
76
|
link.targetUri = targetSourceMap.sourceDocument.uri;
|
|
@@ -82,4 +82,18 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
exports.register = register;
|
|
85
|
+
function getSourceRangePreferSurroundedPosition(sourceMap, mappedRange, position) {
|
|
86
|
+
let result;
|
|
87
|
+
for (const [sourceRange] of sourceMap.getSourceRanges(mappedRange.start, mappedRange.end)) {
|
|
88
|
+
if (!result) {
|
|
89
|
+
result = sourceRange;
|
|
90
|
+
}
|
|
91
|
+
if ((sourceRange.start.line < position.line || (sourceRange.start.line === position.line && sourceRange.start.character <= position.character))
|
|
92
|
+
&& (sourceRange.end.line > position.line || (sourceRange.end.line === position.line && sourceRange.end.character >= position.character))) {
|
|
93
|
+
result = sourceRange;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
85
99
|
//# sourceMappingURL=definition.js.map
|
|
@@ -2,7 +2,7 @@ import type { LanguageServiceRuntimeContext } from '../types';
|
|
|
2
2
|
import { ExecuteCommandContext } from '@volar/language-service';
|
|
3
3
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
export declare const executePluginCommand = "volar.executtePluginCommand";
|
|
5
|
-
export
|
|
5
|
+
export type ExecutePluginCommandArgs = [
|
|
6
6
|
string,
|
|
7
7
|
// uri
|
|
8
8
|
number | undefined,
|
package/out/plugin.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import { PluginContext } from './types';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
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
7
|
export interface ExecuteCommandContext {
|
|
8
8
|
token: vscode.CancellationToken;
|
|
9
9
|
workDoneProgress: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"typescript": "
|
|
16
|
+
"typescript": "beta"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@volar/language-core": "1.0.0-
|
|
20
|
-
"@volar/shared": "1.0.0-
|
|
21
|
-
"@volar/source-map": "1.0.0-
|
|
22
|
-
"@volar/transforms": "1.0.0-
|
|
23
|
-
"@volar/typescript-faster": "1.0.0-
|
|
19
|
+
"@volar/language-core": "1.0.0-beta.0",
|
|
20
|
+
"@volar/shared": "1.0.0-beta.0",
|
|
21
|
+
"@volar/source-map": "1.0.0-beta.0",
|
|
22
|
+
"@volar/transforms": "1.0.0-beta.0",
|
|
23
|
+
"@volar/typescript-faster": "1.0.0-beta.0",
|
|
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": "e93a2cf6e614f6c8fa9b8a61e314c123cbe9a95a"
|
|
33
33
|
}
|