@volar/language-server 1.4.0-alpha.0 → 1.4.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/out/browser/fileSystems.js +83 -107
- package/out/browser/index.js +11 -23
- package/out/browser/typescript/core.js +2 -1
- package/out/browser/typescript/corePublic.js +3 -2
- package/out/browser/typescript/path.js +1 -0
- package/out/browser/typescript/types.js +1 -0
- package/out/browser/typescript/utilities.js +1 -0
- package/out/common/cancellationPipe.js +2 -1
- package/out/common/configurationHost.js +13 -28
- package/out/common/documents.js +3 -3
- package/out/common/features/customFeatures.js +35 -47
- package/out/common/features/languageFeatures.js +135 -163
- package/out/common/project.d.ts +66 -62
- package/out/common/project.js +205 -228
- package/out/common/schemaRequestHandlers/file.js +1 -0
- package/out/common/schemaRequestHandlers/http.js +1 -0
- package/out/common/server.js +63 -68
- package/out/common/utils/inferredCompilerOptions.js +58 -61
- package/out/common/utils/isFileInDir.js +1 -0
- package/out/common/utils/registerFeatures.js +11 -12
- package/out/common/utils/serverConfig.js +3 -2
- package/out/common/utils/uriMap.js +2 -1
- package/out/common/workspace.d.ts +605 -568
- package/out/common/workspace.js +182 -194
- package/out/common/workspaces.d.ts +726 -682
- package/out/common/workspaces.js +82 -107
- package/out/index.js +1 -0
- package/out/node/fileSystem.js +13 -16
- package/out/node/index.js +16 -19
- package/out/protocol.d.ts +0 -6
- package/out/protocol.js +2 -5
- package/out/types.d.ts +4 -6
- package/out/types.js +1 -0
- package/package.json +4 -4
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
1
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.register = void 0;
|
|
12
4
|
const protocol_1 = require("../../protocol");
|
|
13
5
|
const language_core_1 = require("@volar/language-core");
|
|
14
6
|
function register(connection, projects, env) {
|
|
15
|
-
connection.onNotification(protocol_1.ReportStats.type, () =>
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
7
|
+
connection.onNotification(protocol_1.ReportStats.type, async () => {
|
|
17
8
|
for (const [rootUri, _workspace] of projects.workspaces) {
|
|
18
9
|
connection.console.log('workspace: ' + rootUri);
|
|
19
|
-
const workspace =
|
|
20
|
-
connection.console.log('documentRegistry stats: ' +
|
|
10
|
+
const workspace = await _workspace;
|
|
11
|
+
connection.console.log('documentRegistry stats: ' + workspace.documentRegistry?.reportStats());
|
|
21
12
|
connection.console.log('');
|
|
22
13
|
connection.console.log('tsconfig: inferred');
|
|
23
14
|
const _inferredProject = workspace.getInferredProjectDontCreate();
|
|
24
15
|
if (_inferredProject) {
|
|
25
16
|
connection.console.log('loaded: true');
|
|
26
|
-
const inferredProject =
|
|
17
|
+
const inferredProject = await _inferredProject;
|
|
27
18
|
connection.console.log('largest 10 files:');
|
|
28
19
|
for (const script of [...inferredProject.scripts.values()]
|
|
29
|
-
.sort((a, b) =>
|
|
20
|
+
.sort((a, b) => (b.snapshot?.getLength() ?? 0) - (a.snapshot?.getLength() ?? 0))
|
|
30
21
|
.slice(0, 10)) {
|
|
31
22
|
connection.console.log(' - ' + script.fileName);
|
|
32
|
-
connection.console.log(` size: ${
|
|
23
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
33
24
|
}
|
|
34
25
|
connection.console.log('files:');
|
|
35
26
|
for (const script of inferredProject.scripts.values()) {
|
|
36
27
|
connection.console.log(' - ' + script.fileName);
|
|
37
|
-
connection.console.log(` size: ${
|
|
38
|
-
connection.console.log(` ref counts: "${
|
|
28
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
29
|
+
connection.console.log(` ref counts: "${workspace.documentRegistry.getLanguageServiceRefCounts?.(script.fileName, inferredProject.languageServiceHost.getScriptKind?.(script.fileName))})"`);
|
|
39
30
|
}
|
|
40
31
|
}
|
|
41
32
|
else {
|
|
@@ -43,40 +34,39 @@ function register(connection, projects, env) {
|
|
|
43
34
|
}
|
|
44
35
|
connection.console.log('');
|
|
45
36
|
for (const _project of workspace.projects.values()) {
|
|
46
|
-
const project =
|
|
37
|
+
const project = await _project;
|
|
47
38
|
connection.console.log('tsconfig: ' + project.tsConfig);
|
|
48
39
|
connection.console.log('loaded: ' + !!project.getLanguageServiceDontCreate());
|
|
49
40
|
connection.console.log('largest 10 files:');
|
|
50
41
|
for (const script of [...project.scripts.values()]
|
|
51
|
-
.sort((a, b) =>
|
|
42
|
+
.sort((a, b) => (b.snapshot?.getLength() ?? 0) - (a.snapshot?.getLength() ?? 0))
|
|
52
43
|
.slice(0, 10)) {
|
|
53
44
|
connection.console.log(' - ' + script.fileName);
|
|
54
|
-
connection.console.log(` size: ${
|
|
45
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
55
46
|
}
|
|
56
47
|
connection.console.log('files:');
|
|
57
48
|
for (const script of project.scripts.values()) {
|
|
58
49
|
connection.console.log(' - ' + script.fileName);
|
|
59
|
-
connection.console.log(` size: ${
|
|
60
|
-
connection.console.log(` ref counts: "${
|
|
50
|
+
connection.console.log(` size: ${script.snapshot?.getLength()}`);
|
|
51
|
+
connection.console.log(` ref counts: "${workspace.documentRegistry.getLanguageServiceRefCounts?.(script.fileName, project.languageServiceHost.getScriptKind?.(script.fileName))})"`);
|
|
61
52
|
}
|
|
62
53
|
}
|
|
63
54
|
connection.console.log('');
|
|
64
55
|
}
|
|
65
|
-
})
|
|
66
|
-
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) =>
|
|
67
|
-
const project = (
|
|
68
|
-
if (project
|
|
56
|
+
});
|
|
57
|
+
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, async (params) => {
|
|
58
|
+
const project = (await projects.getProject(params.uri));
|
|
59
|
+
if (project?.tsconfig) {
|
|
69
60
|
return { uri: env.fileNameToUri(project.tsconfig) };
|
|
70
61
|
}
|
|
71
|
-
})
|
|
72
|
-
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) =>
|
|
73
|
-
|
|
74
|
-
const project = yield projects.getProject(document.uri);
|
|
62
|
+
});
|
|
63
|
+
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, async (document) => {
|
|
64
|
+
const project = await projects.getProject(document.uri);
|
|
75
65
|
const fileNames = [];
|
|
76
66
|
if (project) {
|
|
77
|
-
const rootVirtualFile =
|
|
67
|
+
const rootVirtualFile = project.project?.getLanguageService().context.core.virtualFiles.getSource(env.uriToFileName(document.uri))?.root;
|
|
78
68
|
if (rootVirtualFile) {
|
|
79
|
-
const kinds =
|
|
69
|
+
const kinds = document.fileKinds ?? [language_core_1.FileKind.TypeScriptHostFile];
|
|
80
70
|
(0, language_core_1.forEachEmbeddedFile)(rootVirtualFile, e => {
|
|
81
71
|
if (e.snapshot.getLength() && kinds.includes(e.kind)) {
|
|
82
72
|
fileNames.push(e.fileName);
|
|
@@ -85,17 +75,16 @@ function register(connection, projects, env) {
|
|
|
85
75
|
}
|
|
86
76
|
}
|
|
87
77
|
return fileNames;
|
|
88
|
-
})
|
|
89
|
-
connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) =>
|
|
90
|
-
|
|
91
|
-
const project = yield projects.getProject(params.sourceFileUri);
|
|
78
|
+
});
|
|
79
|
+
connection.onRequest(protocol_1.GetVirtualFileRequest.type, async (params) => {
|
|
80
|
+
const project = await projects.getProject(params.sourceFileUri);
|
|
92
81
|
if (project) {
|
|
93
|
-
const [virtualFile, source] =
|
|
82
|
+
const [virtualFile, source] = project.project?.getLanguageService().context.core.virtualFiles.getVirtualFile(params.virtualFileName) ?? [];
|
|
94
83
|
if (virtualFile && source) {
|
|
95
84
|
const mappings = {};
|
|
96
85
|
for (const mapping of virtualFile.mappings) {
|
|
97
|
-
const sourceUri = env.fileNameToUri(
|
|
98
|
-
|
|
86
|
+
const sourceUri = env.fileNameToUri(mapping.source ?? source.fileName);
|
|
87
|
+
mappings[sourceUri] ??= [];
|
|
99
88
|
mappings[sourceUri].push(mapping);
|
|
100
89
|
}
|
|
101
90
|
return {
|
|
@@ -104,16 +93,15 @@ function register(connection, projects, env) {
|
|
|
104
93
|
};
|
|
105
94
|
}
|
|
106
95
|
}
|
|
107
|
-
})
|
|
96
|
+
});
|
|
108
97
|
connection.onNotification(protocol_1.ReloadProjectNotification.type, () => {
|
|
109
98
|
projects.reloadProject();
|
|
110
99
|
});
|
|
111
|
-
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) =>
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const project = yield projects.getProject(params.uri);
|
|
100
|
+
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
|
|
101
|
+
const fs = await Promise.resolve().then(() => require('fs'));
|
|
102
|
+
const project = await projects.getProject(params.uri);
|
|
115
103
|
if (project) {
|
|
116
|
-
const ls = (
|
|
104
|
+
const ls = (await project.project)?.getLanguageServiceDontCreate();
|
|
117
105
|
if (ls) {
|
|
118
106
|
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
119
107
|
for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
|
|
@@ -126,7 +114,7 @@ function register(connection, projects, env) {
|
|
|
126
114
|
}
|
|
127
115
|
}
|
|
128
116
|
}
|
|
129
|
-
})
|
|
117
|
+
});
|
|
130
118
|
}
|
|
131
119
|
exports.register = register;
|
|
132
120
|
//# sourceMappingURL=customFeatures.js.map
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
1
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.sleep = exports.register = void 0;
|
|
12
4
|
const embedded = require("@volar/language-service");
|
|
@@ -19,73 +11,73 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
19
11
|
let lastCodeLensLs;
|
|
20
12
|
let lastCodeActionLs;
|
|
21
13
|
let lastCallHierarchyLs;
|
|
22
|
-
|
|
14
|
+
let lastDocumentLinkLs;
|
|
15
|
+
let lastInlayHintLs;
|
|
16
|
+
connection.onDocumentFormatting(async (params, token) => {
|
|
23
17
|
return worker(params.textDocument.uri, token, service => {
|
|
24
18
|
return service.format(params.textDocument.uri, params.options, undefined, undefined, token);
|
|
25
19
|
});
|
|
26
|
-
})
|
|
27
|
-
connection.onDocumentRangeFormatting((params, token) =>
|
|
20
|
+
});
|
|
21
|
+
connection.onDocumentRangeFormatting(async (params, token) => {
|
|
28
22
|
return worker(params.textDocument.uri, token, service => {
|
|
29
23
|
return service.format(params.textDocument.uri, params.options, params.range, undefined, token);
|
|
30
24
|
});
|
|
31
|
-
})
|
|
32
|
-
connection.onDocumentOnTypeFormatting((params, token) =>
|
|
25
|
+
});
|
|
26
|
+
connection.onDocumentOnTypeFormatting(async (params, token) => {
|
|
33
27
|
return worker(params.textDocument.uri, token, service => {
|
|
34
28
|
return service.format(params.textDocument.uri, params.options, undefined, params, token);
|
|
35
29
|
});
|
|
36
|
-
})
|
|
37
|
-
connection.onSelectionRanges((params, token) =>
|
|
30
|
+
});
|
|
31
|
+
connection.onSelectionRanges(async (params, token) => {
|
|
38
32
|
return worker(params.textDocument.uri, token, service => {
|
|
39
33
|
return service.getSelectionRanges(params.textDocument.uri, params.positions, token);
|
|
40
34
|
});
|
|
41
|
-
})
|
|
42
|
-
connection.onFoldingRanges((params, token) =>
|
|
35
|
+
});
|
|
36
|
+
connection.onFoldingRanges(async (params, token) => {
|
|
43
37
|
return worker(params.textDocument.uri, token, service => {
|
|
44
38
|
return service.getFoldingRanges(params.textDocument.uri, token);
|
|
45
39
|
});
|
|
46
|
-
})
|
|
47
|
-
connection.languages.onLinkedEditingRange((params, token) =>
|
|
40
|
+
});
|
|
41
|
+
connection.languages.onLinkedEditingRange(async (params, token) => {
|
|
48
42
|
return worker(params.textDocument.uri, token, service => {
|
|
49
43
|
return service.findLinkedEditingRanges(params.textDocument.uri, params.position, token);
|
|
50
44
|
});
|
|
51
|
-
})
|
|
52
|
-
connection.onDocumentSymbol((params, token) =>
|
|
45
|
+
});
|
|
46
|
+
connection.onDocumentSymbol(async (params, token) => {
|
|
53
47
|
return worker(params.textDocument.uri, token, service => {
|
|
54
48
|
return service.findDocumentSymbols(params.textDocument.uri, token);
|
|
55
49
|
});
|
|
56
|
-
})
|
|
57
|
-
connection.onDocumentColor((params, token) =>
|
|
50
|
+
});
|
|
51
|
+
connection.onDocumentColor(async (params, token) => {
|
|
58
52
|
return worker(params.textDocument.uri, token, service => {
|
|
59
53
|
return service.findDocumentColors(params.textDocument.uri, token);
|
|
60
54
|
});
|
|
61
|
-
})
|
|
62
|
-
connection.onColorPresentation((params, token) =>
|
|
55
|
+
});
|
|
56
|
+
connection.onColorPresentation(async (params, token) => {
|
|
63
57
|
return worker(params.textDocument.uri, token, service => {
|
|
64
58
|
return service.getColorPresentations(params.textDocument.uri, params.color, params.range, token);
|
|
65
59
|
});
|
|
66
|
-
})
|
|
67
|
-
connection.onCompletion((params, token) =>
|
|
68
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
69
|
-
var _a;
|
|
60
|
+
});
|
|
61
|
+
connection.onCompletion(async (params, token) => {
|
|
62
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
70
63
|
lastCompleteUri = params.textDocument.uri;
|
|
71
64
|
lastCompleteLs = service;
|
|
72
|
-
const document =
|
|
73
|
-
const list =
|
|
65
|
+
const document = documents.data.uriGet(params.textDocument.uri)?.getDocument();
|
|
66
|
+
const list = await service.doComplete(params.textDocument.uri, params.position, params.context, token);
|
|
74
67
|
for (const item of list.items) {
|
|
75
68
|
fixTextEdit(item);
|
|
76
69
|
}
|
|
77
70
|
if (!initOptions.fullCompletionList && document) {
|
|
78
71
|
list.items = list.items.filter(item => {
|
|
79
|
-
var _a, _b;
|
|
80
72
|
const range = item.textEdit ? (vscode.InsertReplaceEdit.is(item.textEdit)
|
|
81
73
|
? item.textEdit.replace
|
|
82
|
-
: item.textEdit.range) :
|
|
74
|
+
: item.textEdit.range) : list.itemDefaults?.editRange ? (vscode.Range.is(list.itemDefaults.editRange)
|
|
83
75
|
? list.itemDefaults.editRange
|
|
84
76
|
: list.itemDefaults.editRange.replace) : undefined;
|
|
85
77
|
if (range) {
|
|
86
78
|
const sourceText = document.getText(range).toLowerCase();
|
|
87
79
|
if (sourceText.trim()) {
|
|
88
|
-
let filterText = (
|
|
80
|
+
let filterText = (item.filterText ?? item.label).toLowerCase();
|
|
89
81
|
for (const char of sourceText) {
|
|
90
82
|
const index = filterText.indexOf(char);
|
|
91
83
|
if (index === -1) {
|
|
@@ -99,63 +91,48 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
99
91
|
});
|
|
100
92
|
}
|
|
101
93
|
return list;
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
connection.onCompletionResolve((item, token) =>
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
connection.onCompletionResolve(async (item, token) => {
|
|
105
97
|
if (lastCompleteUri && lastCompleteLs) {
|
|
106
|
-
item =
|
|
98
|
+
item = await lastCompleteLs.doCompletionResolve(item, token);
|
|
107
99
|
fixTextEdit(item);
|
|
108
100
|
}
|
|
109
101
|
return item;
|
|
110
|
-
})
|
|
111
|
-
connection.onHover((params, token) =>
|
|
102
|
+
});
|
|
103
|
+
connection.onHover(async (params, token) => {
|
|
112
104
|
return worker(params.textDocument.uri, token, service => {
|
|
113
105
|
return service.doHover(params.textDocument.uri, params.position, token);
|
|
114
106
|
});
|
|
115
|
-
})
|
|
116
|
-
connection.onSignatureHelp((params, token) =>
|
|
107
|
+
});
|
|
108
|
+
connection.onSignatureHelp(async (params, token) => {
|
|
117
109
|
return worker(params.textDocument.uri, token, service => {
|
|
118
110
|
return service.getSignatureHelp(params.textDocument.uri, params.position, params.context, token);
|
|
119
111
|
});
|
|
120
|
-
})
|
|
121
|
-
connection.onPrepareRename((params, token) =>
|
|
112
|
+
});
|
|
113
|
+
connection.onPrepareRename(async (params, token) => {
|
|
122
114
|
return worker(params.textDocument.uri, token, service => {
|
|
123
115
|
return service.prepareRename(params.textDocument.uri, params.position, token);
|
|
124
116
|
});
|
|
125
|
-
})
|
|
126
|
-
connection.onRenameRequest((params, token) =>
|
|
117
|
+
});
|
|
118
|
+
connection.onRenameRequest(async (params, token) => {
|
|
127
119
|
return worker(params.textDocument.uri, token, service => {
|
|
128
120
|
return service.doRename(params.textDocument.uri, params.position, params.newName, token);
|
|
129
121
|
});
|
|
130
|
-
})
|
|
131
|
-
connection.onCodeLens((params, token) =>
|
|
132
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
122
|
+
});
|
|
123
|
+
connection.onCodeLens(async (params, token) => {
|
|
124
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
133
125
|
lastCodeLensLs = service;
|
|
134
126
|
return service.doCodeLens(params.textDocument.uri, token);
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
connection.onCodeLensResolve((codeLens, token) =>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if (params.command === embedded.showReferencesCommand
|
|
143
|
-
&& params.arguments) {
|
|
144
|
-
const args = params.arguments;
|
|
145
|
-
yield connection.sendNotification(protocol_1.ShowReferencesNotification.type, {
|
|
146
|
-
textDocument: {
|
|
147
|
-
uri: args[0],
|
|
148
|
-
},
|
|
149
|
-
position: args[1],
|
|
150
|
-
references: args[2],
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}));
|
|
154
|
-
connection.onCodeAction((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
return worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
var _c, _d, _e;
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
connection.onCodeLensResolve(async (codeLens, token) => {
|
|
130
|
+
return await lastCodeLensLs?.doCodeLensResolve(codeLens, token) ?? codeLens;
|
|
131
|
+
});
|
|
132
|
+
connection.onCodeAction(async (params, token) => {
|
|
133
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
157
134
|
lastCodeActionLs = service;
|
|
158
|
-
let codeActions =
|
|
135
|
+
let codeActions = await service.doCodeActions(params.textDocument.uri, params.range, params.context, token) ?? [];
|
|
159
136
|
for (const codeAction of codeActions) {
|
|
160
137
|
if (codeAction.data && typeof codeAction.data === 'object') {
|
|
161
138
|
codeAction.data.uri = params.textDocument.uri;
|
|
@@ -164,104 +141,102 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
164
141
|
codeAction.data = { uri: params.textDocument.uri };
|
|
165
142
|
}
|
|
166
143
|
}
|
|
167
|
-
if (!
|
|
144
|
+
if (!initParams.capabilities.textDocument?.codeAction?.disabledSupport) {
|
|
168
145
|
codeActions = codeActions.filter(codeAction => !codeAction.disabled);
|
|
169
146
|
}
|
|
170
147
|
return codeActions;
|
|
171
|
-
})
|
|
172
|
-
})
|
|
173
|
-
connection.onCodeActionResolve((codeAction, token) =>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
connection.onReferences((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
connection.onCodeActionResolve(async (codeAction, token) => {
|
|
151
|
+
return await lastCodeActionLs.doCodeActionResolve(codeAction, token) ?? codeAction;
|
|
152
|
+
});
|
|
153
|
+
connection.onReferences(async (params, token) => {
|
|
178
154
|
return worker(params.textDocument.uri, token, service => {
|
|
179
155
|
return service.findReferences(params.textDocument.uri, params.position, token);
|
|
180
156
|
});
|
|
181
|
-
})
|
|
182
|
-
connection.onRequest(protocol_1.FindFileReferenceRequest.type, (params, token) =>
|
|
157
|
+
});
|
|
158
|
+
connection.onRequest(protocol_1.FindFileReferenceRequest.type, async (params, token) => {
|
|
183
159
|
return worker(params.textDocument.uri, token, service => {
|
|
184
160
|
return service.findFileReferences(params.textDocument.uri, token);
|
|
185
161
|
});
|
|
186
|
-
})
|
|
187
|
-
connection.onImplementation((params, token) =>
|
|
162
|
+
});
|
|
163
|
+
connection.onImplementation(async (params, token) => {
|
|
188
164
|
return worker(params.textDocument.uri, token, service => {
|
|
189
165
|
return service.findImplementations(params.textDocument.uri, params.position, token);
|
|
190
166
|
});
|
|
191
|
-
})
|
|
192
|
-
connection.onDefinition((params, token) =>
|
|
167
|
+
});
|
|
168
|
+
connection.onDefinition(async (params, token) => {
|
|
193
169
|
return worker(params.textDocument.uri, token, service => {
|
|
194
170
|
return service.findDefinition(params.textDocument.uri, params.position, token);
|
|
195
171
|
});
|
|
196
|
-
})
|
|
197
|
-
connection.onTypeDefinition((params, token) =>
|
|
172
|
+
});
|
|
173
|
+
connection.onTypeDefinition(async (params, token) => {
|
|
198
174
|
return worker(params.textDocument.uri, token, service => {
|
|
199
175
|
return service.findTypeDefinition(params.textDocument.uri, params.position, token);
|
|
200
176
|
});
|
|
201
|
-
})
|
|
202
|
-
connection.onDocumentHighlight((params, token) =>
|
|
177
|
+
});
|
|
178
|
+
connection.onDocumentHighlight(async (params, token) => {
|
|
203
179
|
return worker(params.textDocument.uri, token, service => {
|
|
204
180
|
return service.findDocumentHighlights(params.textDocument.uri, params.position, token);
|
|
205
181
|
});
|
|
206
|
-
})
|
|
207
|
-
connection.onDocumentLinks((params, token) =>
|
|
208
|
-
return
|
|
182
|
+
});
|
|
183
|
+
connection.onDocumentLinks(async (params, token) => {
|
|
184
|
+
return await worker(params.textDocument.uri, token, service => {
|
|
185
|
+
lastDocumentLinkLs = service;
|
|
209
186
|
return service.findDocumentLinks(params.textDocument.uri, token);
|
|
210
187
|
});
|
|
211
|
-
})
|
|
212
|
-
connection.
|
|
188
|
+
});
|
|
189
|
+
connection.onDocumentLinkResolve(async (link, token) => {
|
|
190
|
+
return await lastDocumentLinkLs.doDocumentLinkResolve(link, token);
|
|
191
|
+
});
|
|
192
|
+
connection.onWorkspaceSymbol(async (params, token) => {
|
|
213
193
|
let results = [];
|
|
214
194
|
for (const _workspace of projects.workspaces.values()) {
|
|
215
|
-
const workspace =
|
|
195
|
+
const workspace = await _workspace;
|
|
216
196
|
let projects = [...workspace.projects.values()];
|
|
217
197
|
projects = projects.length ? projects : [workspace.getInferredProject()];
|
|
218
198
|
for (const project of projects) {
|
|
219
199
|
if (token.isCancellationRequested)
|
|
220
200
|
return;
|
|
221
|
-
const service = (
|
|
222
|
-
results = results.concat(
|
|
201
|
+
const service = (await project).getLanguageService();
|
|
202
|
+
results = results.concat(await service.findWorkspaceSymbols(params.query, token));
|
|
223
203
|
}
|
|
224
204
|
}
|
|
225
205
|
return results;
|
|
226
|
-
})
|
|
227
|
-
connection.languages.callHierarchy.onPrepare((params, token) =>
|
|
228
|
-
|
|
229
|
-
return (_g = yield worker(params.textDocument.uri, token, (service) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
});
|
|
207
|
+
connection.languages.callHierarchy.onPrepare(async (params, token) => {
|
|
208
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
230
209
|
lastCallHierarchyLs = service;
|
|
231
210
|
return service.callHierarchy.doPrepare(params.textDocument.uri, params.position, token);
|
|
232
|
-
})
|
|
233
|
-
})
|
|
234
|
-
connection.languages.callHierarchy.onIncomingCalls((params, token) =>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}))) !== null && _l !== void 0 ? _l : { data: [] };
|
|
255
|
-
}));
|
|
256
|
-
connection.languages.diagnostics.on((params, token, _workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
const result = yield worker(params.textDocument.uri, token, service => {
|
|
211
|
+
}) ?? [];
|
|
212
|
+
});
|
|
213
|
+
connection.languages.callHierarchy.onIncomingCalls(async (params, token) => {
|
|
214
|
+
return await lastCallHierarchyLs?.callHierarchy.getIncomingCalls(params.item, token) ?? [];
|
|
215
|
+
});
|
|
216
|
+
connection.languages.callHierarchy.onOutgoingCalls(async (params, token) => {
|
|
217
|
+
return await lastCallHierarchyLs?.callHierarchy.getOutgoingCalls(params.item, token) ?? [];
|
|
218
|
+
});
|
|
219
|
+
connection.languages.semanticTokens.on(async (params, token, _, resultProgress) => {
|
|
220
|
+
await sleep(200);
|
|
221
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
222
|
+
return await service?.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
|
|
223
|
+
}) ?? { data: [] };
|
|
224
|
+
});
|
|
225
|
+
connection.languages.semanticTokens.onRange(async (params, token, _, resultProgress) => {
|
|
226
|
+
await sleep(200);
|
|
227
|
+
return await worker(params.textDocument.uri, token, async (service) => {
|
|
228
|
+
return await service?.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress?.report(tokens));
|
|
229
|
+
}) ?? { data: [] };
|
|
230
|
+
});
|
|
231
|
+
connection.languages.diagnostics.on(async (params, token, _workDoneProgressReporter, resultProgressReporter) => {
|
|
232
|
+
const result = await worker(params.textDocument.uri, token, service => {
|
|
258
233
|
const tsToken = cancelHost.createCancellationToken(token);
|
|
259
234
|
const mode = initOptions.serverMode === types_1.ServerMode.PartialSemantic ? 'semantic'
|
|
260
235
|
: initOptions.serverMode === types_1.ServerMode.Syntactic ? 'syntactic'
|
|
261
236
|
: 'all';
|
|
262
|
-
return service.doValidation(params.textDocument.uri,
|
|
237
|
+
return service.doValidation(params.textDocument.uri, mode, tsToken, errors => {
|
|
263
238
|
// resultProgressReporter is undefined in vscode
|
|
264
|
-
resultProgressReporter
|
|
239
|
+
resultProgressReporter?.report({
|
|
265
240
|
relatedDocuments: {
|
|
266
241
|
[params.textDocument.uri]: {
|
|
267
242
|
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
@@ -273,57 +248,58 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
273
248
|
});
|
|
274
249
|
return {
|
|
275
250
|
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
276
|
-
items: result
|
|
251
|
+
items: result ?? [],
|
|
277
252
|
};
|
|
278
|
-
})
|
|
279
|
-
connection.languages.inlayHint.on((params, token) =>
|
|
280
|
-
return worker(params.textDocument.uri, token, (service) =>
|
|
253
|
+
});
|
|
254
|
+
connection.languages.inlayHint.on(async (params, token) => {
|
|
255
|
+
return worker(params.textDocument.uri, token, async (service) => {
|
|
256
|
+
lastInlayHintLs = service;
|
|
281
257
|
return service.getInlayHints(params.textDocument.uri, params.range, token);
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
connection.languages.inlayHint.resolve(async (hint, token) => {
|
|
261
|
+
return await lastInlayHintLs.doInlayHintResolve(hint, token);
|
|
262
|
+
});
|
|
263
|
+
connection.workspace.onWillRenameFiles(async (params, token) => {
|
|
264
|
+
const config = await connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
|
|
287
265
|
if (!config) {
|
|
288
266
|
return null;
|
|
289
267
|
}
|
|
290
|
-
const _edits =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
})) !== null && _m !== void 0 ? _m : null;
|
|
296
|
-
})));
|
|
268
|
+
const _edits = await Promise.all(params.files.map(async (file) => {
|
|
269
|
+
return await worker(file.oldUri, token, service => {
|
|
270
|
+
return service.getEditsForFileRename(file.oldUri, file.newUri, token) ?? null;
|
|
271
|
+
}) ?? null;
|
|
272
|
+
}));
|
|
297
273
|
const edits = _edits.filter((edit) => !!edit);
|
|
298
274
|
if (edits.length) {
|
|
299
275
|
embedded.mergeWorkspaceEdits(edits[0], ...edits.slice(1));
|
|
300
276
|
return edits[0];
|
|
301
277
|
}
|
|
302
278
|
return null;
|
|
303
|
-
})
|
|
304
|
-
connection.onRequest(protocol_1.AutoInsertRequest.type, (params, token) =>
|
|
279
|
+
});
|
|
280
|
+
connection.onRequest(protocol_1.AutoInsertRequest.type, async (params, token) => {
|
|
305
281
|
return worker(params.textDocument.uri, token, service => {
|
|
306
282
|
return service.doAutoInsert(params.textDocument.uri, params.position, params.options, token);
|
|
307
283
|
});
|
|
308
|
-
})
|
|
284
|
+
});
|
|
309
285
|
function worker(uri, token, cb) {
|
|
310
286
|
return new Promise(resolve => {
|
|
311
|
-
runtime.timer.setImmediate(() =>
|
|
287
|
+
runtime.timer.setImmediate(async () => {
|
|
312
288
|
if (token.isCancellationRequested) {
|
|
313
289
|
resolve(undefined);
|
|
314
290
|
return;
|
|
315
291
|
}
|
|
316
|
-
const service =
|
|
292
|
+
const service = await getLanguageService(uri);
|
|
317
293
|
if (service) {
|
|
318
294
|
try { // handle TS cancel throw
|
|
319
|
-
const result =
|
|
295
|
+
const result = await cb(service);
|
|
320
296
|
if (token.isCancellationRequested) {
|
|
321
297
|
resolve(undefined);
|
|
322
298
|
return;
|
|
323
299
|
}
|
|
324
300
|
resolve(result);
|
|
325
301
|
}
|
|
326
|
-
catch
|
|
302
|
+
catch {
|
|
327
303
|
resolve(undefined);
|
|
328
304
|
return;
|
|
329
305
|
}
|
|
@@ -331,19 +307,15 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
|
|
|
331
307
|
else {
|
|
332
308
|
resolve(undefined);
|
|
333
309
|
}
|
|
334
|
-
})
|
|
310
|
+
});
|
|
335
311
|
});
|
|
336
312
|
}
|
|
337
|
-
function getLanguageService(uri) {
|
|
338
|
-
|
|
339
|
-
return
|
|
340
|
-
const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
|
|
341
|
-
return project === null || project === void 0 ? void 0 : project.getLanguageService();
|
|
342
|
-
});
|
|
313
|
+
async function getLanguageService(uri) {
|
|
314
|
+
const project = (await projects.getProject(uri))?.project;
|
|
315
|
+
return project?.getLanguageService();
|
|
343
316
|
}
|
|
344
317
|
function fixTextEdit(item) {
|
|
345
|
-
|
|
346
|
-
const insertReplaceSupport = (_d = (_c = (_b = (_a = initParams.capabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.insertReplaceSupport) !== null && _d !== void 0 ? _d : false;
|
|
318
|
+
const insertReplaceSupport = initParams.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
|
|
347
319
|
if (!insertReplaceSupport) {
|
|
348
320
|
if (item.textEdit && vscode.InsertReplaceEdit.is(item.textEdit)) {
|
|
349
321
|
item.textEdit = vscode.TextEdit.replace(item.textEdit.insert, item.textEdit.newText);
|