@volar/language-service 1.2.0-alpha.6 → 1.2.0-alpha.8
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/baseLanguageService.js +2 -1
- package/out/languageFeatures/completeResolve.js +2 -13
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +11 -11
- package/out/transformer/foldingRanges.js +6 -6
- package/out/types.d.ts +6 -0
- package/out/types.js +0 -1
- package/out/utils/featureWorkers.js +2 -0
- package/package.json +6 -6
|
@@ -44,7 +44,7 @@ function createLanguageService(host, config, env, documentRegistry) {
|
|
|
44
44
|
}
|
|
45
45
|
exports.createLanguageService = createLanguageService;
|
|
46
46
|
function createLanguageServiceContext(host, languageContext, config, env, getLanguageService, documentRegistry) {
|
|
47
|
-
var _a, _b;
|
|
47
|
+
var _a, _b, _c;
|
|
48
48
|
const ts = (_a = host.getTypeScriptModule) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
49
49
|
const tsLs = ts === null || ts === void 0 ? void 0 : ts.createLanguageService(languageContext.typescript.languageServiceHost, documentRegistry);
|
|
50
50
|
if (ts && tsLs) {
|
|
@@ -78,6 +78,7 @@ function createLanguageServiceContext(host, languageContext, config, env, getLan
|
|
|
78
78
|
return plugins;
|
|
79
79
|
},
|
|
80
80
|
rules: (_b = config.rules) !== null && _b !== void 0 ? _b : {},
|
|
81
|
+
rulesSettings: (_c = config.rulesSettings) !== null && _c !== void 0 ? _c : {},
|
|
81
82
|
typescript: ts && tsLs ? {
|
|
82
83
|
module: ts,
|
|
83
84
|
languageServiceHost: languageContext.typescript.languageServiceHost,
|
|
@@ -21,19 +21,8 @@ function register(context) {
|
|
|
21
21
|
item = Object.assign(item, data.original);
|
|
22
22
|
if (data.map) {
|
|
23
23
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (resolvedItem.additionalTextEdits) {
|
|
27
|
-
for (const edit of resolvedItem.additionalTextEdits) {
|
|
28
|
-
if (edit.range.start.line === 0
|
|
29
|
-
&& edit.range.start.character === 0
|
|
30
|
-
&& edit.range.end.line === 0
|
|
31
|
-
&& edit.range.end.character === 0) {
|
|
32
|
-
edit.newText = '\n' + edit.newText;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
item = transformer.asCompletionItem(resolvedItem, embeddedRange => {
|
|
24
|
+
item = yield plugin.complete.resolve(item);
|
|
25
|
+
item = transformer.asCompletionItem(item, embeddedRange => {
|
|
37
26
|
var _a;
|
|
38
27
|
let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
|
|
39
28
|
if (range)
|
|
@@ -3,4 +3,4 @@ import type { LanguageServiceRuntimeContext } from '../types';
|
|
|
3
3
|
import { DocumentsAndSourceMaps } from '../documents';
|
|
4
4
|
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
5
|
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
|
6
|
-
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit,
|
|
6
|
+
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, documents: DocumentsAndSourceMaps): vscode.WorkspaceEdit | undefined;
|
|
@@ -131,18 +131,18 @@ function mergeWorkspaceEdits(original, ...others) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
exports.mergeWorkspaceEdits = mergeWorkspaceEdits;
|
|
134
|
-
function embeddedEditToSourceEdit(tsResult,
|
|
134
|
+
function embeddedEditToSourceEdit(tsResult, documents) {
|
|
135
135
|
var _a, _b, _c;
|
|
136
136
|
const sourceResult = {};
|
|
137
137
|
let hasResult = false;
|
|
138
138
|
for (const tsUri in tsResult.changeAnnotations) {
|
|
139
139
|
(_a = sourceResult.changeAnnotations) !== null && _a !== void 0 ? _a : (sourceResult.changeAnnotations = {});
|
|
140
140
|
const tsAnno = tsResult.changeAnnotations[tsUri];
|
|
141
|
-
if (!
|
|
141
|
+
if (!documents.hasVirtualFileByUri(tsUri)) {
|
|
142
142
|
sourceResult.changeAnnotations[tsUri] = tsAnno;
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
145
|
-
for (const [_, map] of
|
|
145
|
+
for (const [_, map] of documents.getMapsByVirtualFileUri(tsUri)) {
|
|
146
146
|
// TODO: check capability?
|
|
147
147
|
const uri = map.sourceFileDocument.uri;
|
|
148
148
|
sourceResult.changeAnnotations[uri] = tsAnno;
|
|
@@ -151,12 +151,12 @@ function embeddedEditToSourceEdit(tsResult, vueDocuments) {
|
|
|
151
151
|
}
|
|
152
152
|
for (const tsUri in tsResult.changes) {
|
|
153
153
|
(_b = sourceResult.changes) !== null && _b !== void 0 ? _b : (sourceResult.changes = {});
|
|
154
|
-
if (!
|
|
154
|
+
if (!documents.hasVirtualFileByUri(tsUri)) {
|
|
155
155
|
sourceResult.changes[tsUri] = tsResult.changes[tsUri];
|
|
156
156
|
hasResult = true;
|
|
157
157
|
continue;
|
|
158
158
|
}
|
|
159
|
-
for (const [_, map] of
|
|
159
|
+
for (const [_, map] of documents.getMapsByVirtualFileUri(tsUri)) {
|
|
160
160
|
const tsEdits = tsResult.changes[tsUri];
|
|
161
161
|
for (const tsEdit of tsEdits) {
|
|
162
162
|
let _data;
|
|
@@ -183,8 +183,8 @@ function embeddedEditToSourceEdit(tsResult, vueDocuments) {
|
|
|
183
183
|
(_c = sourceResult.documentChanges) !== null && _c !== void 0 ? _c : (sourceResult.documentChanges = []);
|
|
184
184
|
let sourceEdit;
|
|
185
185
|
if (vscode.TextDocumentEdit.is(tsDocEdit)) {
|
|
186
|
-
if (
|
|
187
|
-
for (const [_, map] of
|
|
186
|
+
if (documents.hasVirtualFileByUri(tsDocEdit.textDocument.uri)) {
|
|
187
|
+
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.textDocument.uri)) {
|
|
188
188
|
sourceEdit = vscode.TextDocumentEdit.create({
|
|
189
189
|
uri: map.sourceFileDocument.uri,
|
|
190
190
|
// version: map.sourceDocument.version,
|
|
@@ -222,22 +222,22 @@ function embeddedEditToSourceEdit(tsResult, vueDocuments) {
|
|
|
222
222
|
sourceEdit = tsDocEdit; // TODO: remove .ts?
|
|
223
223
|
}
|
|
224
224
|
else if (vscode.RenameFile.is(tsDocEdit)) {
|
|
225
|
-
if (!
|
|
225
|
+
if (!documents.hasVirtualFileByUri(tsDocEdit.oldUri)) {
|
|
226
226
|
sourceEdit = tsDocEdit;
|
|
227
227
|
}
|
|
228
228
|
else {
|
|
229
|
-
for (const [_, map] of
|
|
229
|
+
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.oldUri)) {
|
|
230
230
|
// TODO: check capability?
|
|
231
231
|
sourceEdit = vscode.RenameFile.create(map.sourceFileDocument.uri, tsDocEdit.newUri /* TODO: remove .ts? */, tsDocEdit.options, tsDocEdit.annotationId);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
else if (vscode.DeleteFile.is(tsDocEdit)) {
|
|
236
|
-
if (!
|
|
236
|
+
if (!documents.hasVirtualFileByUri(tsDocEdit.uri)) {
|
|
237
237
|
sourceEdit = tsDocEdit;
|
|
238
238
|
}
|
|
239
239
|
else {
|
|
240
|
-
for (const [_, map] of
|
|
240
|
+
for (const [_, map] of documents.getMapsByVirtualFileUri(tsDocEdit.uri)) {
|
|
241
241
|
// TODO: check capability?
|
|
242
242
|
sourceEdit = vscode.DeleteFile.create(map.sourceFileDocument.uri, tsDocEdit.options, tsDocEdit.annotationId);
|
|
243
243
|
}
|
|
@@ -4,17 +4,17 @@ function transform(ranges, getOtherRange) {
|
|
|
4
4
|
var _a, _b;
|
|
5
5
|
const result = [];
|
|
6
6
|
for (const range of ranges) {
|
|
7
|
-
const
|
|
7
|
+
const otherRange = getOtherRange({
|
|
8
8
|
start: { line: range.startLine, character: (_a = range.startCharacter) !== null && _a !== void 0 ? _a : 0 },
|
|
9
9
|
end: { line: range.endLine, character: (_b = range.endCharacter) !== null && _b !== void 0 ? _b : 0 },
|
|
10
10
|
});
|
|
11
|
-
if (
|
|
12
|
-
range.startLine =
|
|
13
|
-
range.endLine =
|
|
11
|
+
if (otherRange) {
|
|
12
|
+
range.startLine = otherRange.start.line;
|
|
13
|
+
range.endLine = otherRange.end.line;
|
|
14
14
|
if (range.startCharacter !== undefined)
|
|
15
|
-
range.startCharacter =
|
|
15
|
+
range.startCharacter = otherRange.start.character;
|
|
16
16
|
if (range.endCharacter !== undefined)
|
|
17
|
-
range.endCharacter =
|
|
17
|
+
range.endCharacter = otherRange.end.character;
|
|
18
18
|
result.push(range);
|
|
19
19
|
}
|
|
20
20
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface LanguageServiceRuntimeContext<Host extends LanguageServiceHost
|
|
|
39
39
|
[id: string]: Rule | undefined;
|
|
40
40
|
};
|
|
41
41
|
/** @private */
|
|
42
|
+
rulesSettings: RulesSettings;
|
|
43
|
+
/** @private */
|
|
42
44
|
getTextDocument(uri: string): TextDocument | undefined;
|
|
43
45
|
/** @private */
|
|
44
46
|
ruleFixes?: {
|
|
@@ -163,10 +165,13 @@ export interface RuleContext {
|
|
|
163
165
|
rootUri: URI;
|
|
164
166
|
getConfiguration?: ConfigurationHost['getConfiguration'];
|
|
165
167
|
onDidChangeConfiguration?: ConfigurationHost['onDidChangeConfiguration'];
|
|
168
|
+
settings: RulesSettings;
|
|
166
169
|
ruleId: string;
|
|
167
170
|
document: TextDocument;
|
|
168
171
|
report(error: vscode.Diagnostic, ...fixes: RuleFix[]): void;
|
|
169
172
|
}
|
|
173
|
+
export interface RulesSettings {
|
|
174
|
+
}
|
|
170
175
|
export interface RuleFix {
|
|
171
176
|
kinds?: ('' | 'quickfix' | 'refactor' | 'refactor.extract' | 'refactor.inline' | 'refactor.rewrite' | 'source' | 'source.organizeImports' | 'source.fixAll')[];
|
|
172
177
|
title?: string;
|
|
@@ -183,4 +188,5 @@ export interface Config {
|
|
|
183
188
|
rules?: {
|
|
184
189
|
[id: string]: Rule | undefined;
|
|
185
190
|
};
|
|
191
|
+
rulesSettings?: RulesSettings;
|
|
186
192
|
}
|
package/out/types.js
CHANGED
|
@@ -96,6 +96,7 @@ function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineRe
|
|
|
96
96
|
locale: context.env.locale,
|
|
97
97
|
getConfiguration: (_f = context.env.configurationHost) === null || _f === void 0 ? void 0 : _f.getConfiguration,
|
|
98
98
|
onDidChangeConfiguration: (_g = context.env.configurationHost) === null || _g === void 0 ? void 0 : _g.onDidChangeConfiguration,
|
|
99
|
+
settings: context.rulesSettings,
|
|
99
100
|
// document context
|
|
100
101
|
ruleId: '',
|
|
101
102
|
document: map.virtualFileDocument,
|
|
@@ -138,6 +139,7 @@ function ruleWorker(context, uri, isValidSourceMap, worker, transform, combineRe
|
|
|
138
139
|
locale: context.env.locale,
|
|
139
140
|
getConfiguration: (_b = context.env.configurationHost) === null || _b === void 0 ? void 0 : _b.getConfiguration,
|
|
140
141
|
onDidChangeConfiguration: (_c = context.env.configurationHost) === null || _c === void 0 ? void 0 : _c.onDidChangeConfiguration,
|
|
142
|
+
settings: context.rulesSettings,
|
|
141
143
|
// document context
|
|
142
144
|
ruleId: '',
|
|
143
145
|
document,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.8",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.2.0-alpha.
|
|
17
|
-
"@volar/shared": "1.2.0-alpha.
|
|
18
|
-
"@volar/source-map": "1.2.0-alpha.
|
|
19
|
-
"@volar/typescript-faster": "1.2.0-alpha.
|
|
16
|
+
"@volar/language-core": "1.2.0-alpha.8",
|
|
17
|
+
"@volar/shared": "1.2.0-alpha.8",
|
|
18
|
+
"@volar/source-map": "1.2.0-alpha.8",
|
|
19
|
+
"@volar/typescript-faster": "1.2.0-alpha.8",
|
|
20
20
|
"vscode-html-languageservice": "^5.0.3",
|
|
21
21
|
"vscode-json-languageservice": "^5.1.3",
|
|
22
22
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
23
23
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
24
24
|
"vscode-uri": "^3.0.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "9437b4560f35d2a153a9e2ae0dd0f64285bbb3b3"
|
|
27
27
|
}
|