@volar/language-server 1.0.9 → 1.0.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/features/customFeatures.js +24 -24
- package/out/registerFeatures.d.ts +2 -2
- package/out/registerFeatures.js +30 -30
- package/out/server.js +18 -11
- package/out/types.d.ts +6 -0
- package/out/utils/configurationHost.js +14 -2
- package/out/utils/nodeFileSystemHost.js +2 -2
- package/out/utils/project.js +2 -1
- package/out/utils/snapshots.js +2 -1
- package/out/utils/uriMap.d.ts +22 -0
- package/out/utils/uriMap.js +77 -0
- package/out/utils/webFileSystemHost.js +2 -2
- package/out/utils/workspaceProjects.js +6 -2
- package/package.json +7 -7
|
@@ -18,52 +18,52 @@ function register(connection, projects) {
|
|
|
18
18
|
connection.onNotification(protocol_1.ReportStats.type, () => __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
20
20
|
for (const [rootUri, _workspace] of projects.workspaces) {
|
|
21
|
-
console.log('workspace: ' + rootUri);
|
|
21
|
+
connection.console.log('workspace: ' + rootUri);
|
|
22
22
|
const workspace = yield _workspace;
|
|
23
|
-
console.log('documentRegistry stats: ' + workspace.documentRegistry.reportStats());
|
|
24
|
-
console.log('');
|
|
25
|
-
console.log('tsconfig: inferred');
|
|
23
|
+
connection.console.log('documentRegistry stats: ' + workspace.documentRegistry.reportStats());
|
|
24
|
+
connection.console.log('');
|
|
25
|
+
connection.console.log('tsconfig: inferred');
|
|
26
26
|
const _inferredProject = workspace.getInferredProjectDontCreate();
|
|
27
27
|
if (_inferredProject) {
|
|
28
|
-
console.log('loaded: true');
|
|
28
|
+
connection.console.log('loaded: true');
|
|
29
29
|
const inferredProject = yield _inferredProject;
|
|
30
|
-
console.log('largest 10 files:');
|
|
30
|
+
connection.console.log('largest 10 files:');
|
|
31
31
|
for (const script of [...inferredProject.scripts.values()]
|
|
32
32
|
.sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.snapshot) === null || _c === void 0 ? void 0 : _c.getLength()) !== null && _d !== void 0 ? _d : 0); })
|
|
33
33
|
.slice(0, 10)) {
|
|
34
|
-
console.log(' - ' + script.fileName);
|
|
35
|
-
console.log(` size: ${(_a = script.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()}`);
|
|
34
|
+
connection.console.log(' - ' + script.fileName);
|
|
35
|
+
connection.console.log(` size: ${(_a = script.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()}`);
|
|
36
36
|
}
|
|
37
|
-
console.log('files:');
|
|
37
|
+
connection.console.log('files:');
|
|
38
38
|
for (const script of inferredProject.scripts.values()) {
|
|
39
|
-
console.log(' - ' + script.fileName);
|
|
40
|
-
console.log(` size: ${(_b = script.snapshot) === null || _b === void 0 ? void 0 : _b.getLength()}`);
|
|
41
|
-
console.log(` ref counts: "${(_d = (_c = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _d === void 0 ? void 0 : _d.call(_c, script.fileName, (_f = (_e = inferredProject.languageServiceHost).getScriptKind) === null || _f === void 0 ? void 0 : _f.call(_e, script.fileName))})"`);
|
|
39
|
+
connection.console.log(' - ' + script.fileName);
|
|
40
|
+
connection.console.log(` size: ${(_b = script.snapshot) === null || _b === void 0 ? void 0 : _b.getLength()}`);
|
|
41
|
+
connection.console.log(` ref counts: "${(_d = (_c = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _d === void 0 ? void 0 : _d.call(_c, script.fileName, (_f = (_e = inferredProject.languageServiceHost).getScriptKind) === null || _f === void 0 ? void 0 : _f.call(_e, script.fileName))})"`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
console.log('loaded: false');
|
|
45
|
+
connection.console.log('loaded: false');
|
|
46
46
|
}
|
|
47
|
-
console.log('');
|
|
47
|
+
connection.console.log('');
|
|
48
48
|
for (const _project of workspace.projects.values()) {
|
|
49
49
|
const project = yield _project;
|
|
50
|
-
console.log('tsconfig: ' + project.tsConfig);
|
|
51
|
-
console.log('loaded: ' + !!project.getLanguageServiceDontCreate());
|
|
52
|
-
console.log('largest 10 files:');
|
|
50
|
+
connection.console.log('tsconfig: ' + project.tsConfig);
|
|
51
|
+
connection.console.log('loaded: ' + !!project.getLanguageServiceDontCreate());
|
|
52
|
+
connection.console.log('largest 10 files:');
|
|
53
53
|
for (const script of [...project.scripts.values()]
|
|
54
54
|
.sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.snapshot) === null || _c === void 0 ? void 0 : _c.getLength()) !== null && _d !== void 0 ? _d : 0); })
|
|
55
55
|
.slice(0, 10)) {
|
|
56
|
-
console.log(' - ' + script.fileName);
|
|
57
|
-
console.log(` size: ${(_g = script.snapshot) === null || _g === void 0 ? void 0 : _g.getLength()}`);
|
|
56
|
+
connection.console.log(' - ' + script.fileName);
|
|
57
|
+
connection.console.log(` size: ${(_g = script.snapshot) === null || _g === void 0 ? void 0 : _g.getLength()}`);
|
|
58
58
|
}
|
|
59
|
-
console.log('files:');
|
|
59
|
+
connection.console.log('files:');
|
|
60
60
|
for (const script of project.scripts.values()) {
|
|
61
|
-
console.log(' - ' + script.fileName);
|
|
62
|
-
console.log(` size: ${(_h = script.snapshot) === null || _h === void 0 ? void 0 : _h.getLength()}`);
|
|
63
|
-
console.log(` ref counts: "${(_k = (_j = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _k === void 0 ? void 0 : _k.call(_j, script.fileName, (_m = (_l = project.languageServiceHost).getScriptKind) === null || _m === void 0 ? void 0 : _m.call(_l, script.fileName))})"`);
|
|
61
|
+
connection.console.log(' - ' + script.fileName);
|
|
62
|
+
connection.console.log(` size: ${(_h = script.snapshot) === null || _h === void 0 ? void 0 : _h.getLength()}`);
|
|
63
|
+
connection.console.log(` ref counts: "${(_k = (_j = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _k === void 0 ? void 0 : _k.call(_j, script.fileName, (_m = (_l = project.languageServiceHost).getScriptKind) === null || _m === void 0 ? void 0 : _m.call(_l, script.fileName))})"`);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
console.log('');
|
|
66
|
+
connection.console.log('');
|
|
67
67
|
}
|
|
68
68
|
}));
|
|
69
69
|
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2,5 +2,5 @@ import { LanguageServerPlugin, LanguageServerInitializationOptions } from './typ
|
|
|
2
2
|
import * as vscode from 'vscode-languageserver';
|
|
3
3
|
import { ClientCapabilities } from 'vscode-languageserver';
|
|
4
4
|
export declare const semanticTokensLegend: vscode.SemanticTokensLegend;
|
|
5
|
-
export declare function setupSyntacticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities): void;
|
|
6
|
-
export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities,
|
|
5
|
+
export declare function setupSyntacticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, initOptions: LanguageServerInitializationOptions): void;
|
|
6
|
+
export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, initOptions: LanguageServerInitializationOptions, plugins: ReturnType<LanguageServerPlugin>[]): void;
|
package/out/registerFeatures.js
CHANGED
|
@@ -43,30 +43,30 @@ exports.semanticTokensLegend = {
|
|
|
43
43
|
'defaultLibrary',
|
|
44
44
|
],
|
|
45
45
|
};
|
|
46
|
-
function setupSyntacticCapabilities(params, server) {
|
|
46
|
+
function setupSyntacticCapabilities(params, server, initOptions) {
|
|
47
47
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
48
|
-
if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.selectionRange) {
|
|
48
|
+
if (!initOptions.respectClientCapabilities || ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.selectionRange)) {
|
|
49
49
|
server.selectionRangeProvider = true;
|
|
50
50
|
}
|
|
51
|
-
if ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.foldingRange) {
|
|
51
|
+
if (!initOptions.respectClientCapabilities || ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.foldingRange)) {
|
|
52
52
|
server.foldingRangeProvider = true;
|
|
53
53
|
}
|
|
54
|
-
if ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.linkedEditingRange) {
|
|
54
|
+
if (!initOptions.respectClientCapabilities || ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.linkedEditingRange)) {
|
|
55
55
|
server.linkedEditingRangeProvider = true;
|
|
56
56
|
}
|
|
57
|
-
if ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.colorProvider) {
|
|
57
|
+
if (!initOptions.respectClientCapabilities || ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.colorProvider)) {
|
|
58
58
|
server.colorProvider = true;
|
|
59
59
|
}
|
|
60
|
-
if ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.documentSymbol) {
|
|
60
|
+
if (!initOptions.respectClientCapabilities || ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.documentSymbol)) {
|
|
61
61
|
server.documentSymbolProvider = true;
|
|
62
62
|
}
|
|
63
|
-
if ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.formatting) {
|
|
63
|
+
if (!initOptions.respectClientCapabilities || ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.formatting)) {
|
|
64
64
|
server.documentFormattingProvider = true;
|
|
65
65
|
}
|
|
66
|
-
if ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rangeFormatting) {
|
|
66
|
+
if (!initOptions.respectClientCapabilities || ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rangeFormatting)) {
|
|
67
67
|
server.documentRangeFormattingProvider = true;
|
|
68
68
|
}
|
|
69
|
-
if ((_h = params.textDocument) === null || _h === void 0 ? void 0 : _h.onTypeFormatting) {
|
|
69
|
+
if (!initOptions.respectClientCapabilities || ((_h = params.textDocument) === null || _h === void 0 ? void 0 : _h.onTypeFormatting)) {
|
|
70
70
|
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
71
71
|
server.documentOnTypeFormattingProvider = {
|
|
72
72
|
firstTriggerCharacter: ';',
|
|
@@ -75,32 +75,32 @@ function setupSyntacticCapabilities(params, server) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
exports.setupSyntacticCapabilities = setupSyntacticCapabilities;
|
|
78
|
-
function setupSemanticCapabilities(params, server,
|
|
78
|
+
function setupSemanticCapabilities(params, server, initOptions, plugins) {
|
|
79
79
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
80
|
-
if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.references) {
|
|
80
|
+
if (!initOptions.respectClientCapabilities || ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.references)) {
|
|
81
81
|
server.referencesProvider = true;
|
|
82
82
|
}
|
|
83
|
-
if ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.implementation) {
|
|
83
|
+
if (!initOptions.respectClientCapabilities || ((_b = params.textDocument) === null || _b === void 0 ? void 0 : _b.implementation)) {
|
|
84
84
|
server.implementationProvider = true;
|
|
85
85
|
}
|
|
86
|
-
if ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.definition) {
|
|
86
|
+
if (!initOptions.respectClientCapabilities || ((_c = params.textDocument) === null || _c === void 0 ? void 0 : _c.definition)) {
|
|
87
87
|
server.definitionProvider = true;
|
|
88
88
|
}
|
|
89
|
-
if ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.typeDefinition) {
|
|
89
|
+
if (!initOptions.respectClientCapabilities || ((_d = params.textDocument) === null || _d === void 0 ? void 0 : _d.typeDefinition)) {
|
|
90
90
|
server.typeDefinitionProvider = true;
|
|
91
91
|
}
|
|
92
|
-
if ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.callHierarchy) {
|
|
92
|
+
if (!initOptions.respectClientCapabilities || ((_e = params.textDocument) === null || _e === void 0 ? void 0 : _e.callHierarchy)) {
|
|
93
93
|
server.callHierarchyProvider = true;
|
|
94
94
|
}
|
|
95
|
-
if ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.hover) {
|
|
95
|
+
if (!initOptions.respectClientCapabilities || ((_f = params.textDocument) === null || _f === void 0 ? void 0 : _f.hover)) {
|
|
96
96
|
server.hoverProvider = true;
|
|
97
97
|
}
|
|
98
|
-
if ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rename) {
|
|
98
|
+
if (!initOptions.respectClientCapabilities || ((_g = params.textDocument) === null || _g === void 0 ? void 0 : _g.rename)) {
|
|
99
99
|
server.renameProvider = {
|
|
100
100
|
prepareProvider: true,
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
if ((_h = params.workspace) === null || _h === void 0 ? void 0 : _h.fileOperations) {
|
|
103
|
+
if (!initOptions.respectClientCapabilities || ((_h = params.workspace) === null || _h === void 0 ? void 0 : _h.fileOperations)) {
|
|
104
104
|
server.workspace = {
|
|
105
105
|
fileOperations: {
|
|
106
106
|
willRename: {
|
|
@@ -120,13 +120,13 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
if ((_j = params.textDocument) === null || _j === void 0 ? void 0 : _j.signatureHelp) {
|
|
123
|
+
if (!initOptions.respectClientCapabilities || ((_j = params.textDocument) === null || _j === void 0 ? void 0 : _j.signatureHelp)) {
|
|
124
124
|
server.signatureHelpProvider = {
|
|
125
125
|
triggerCharacters: ['(', ',', '<'],
|
|
126
126
|
retriggerCharacters: [')'],
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
-
if ((_k = params.textDocument) === null || _k === void 0 ? void 0 : _k.completion) {
|
|
129
|
+
if (!initOptions.respectClientCapabilities || ((_k = params.textDocument) === null || _k === void 0 ? void 0 : _k.completion)) {
|
|
130
130
|
server.completionProvider = {
|
|
131
131
|
// triggerCharacters: '!@#$%^&*()_+-=`~{}|[]\:";\'<>?,./ '.split(''), // all symbols on keyboard
|
|
132
132
|
// hardcode to fix https://github.com/sublimelsp/LSP-volar/issues/114
|
|
@@ -142,22 +142,22 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
142
142
|
])],
|
|
143
143
|
resolveProvider: true,
|
|
144
144
|
};
|
|
145
|
-
if (
|
|
146
|
-
server.completionProvider.triggerCharacters = (_l = server.completionProvider.triggerCharacters) === null || _l === void 0 ? void 0 : _l.filter(c => !
|
|
145
|
+
if (initOptions.ignoreTriggerCharacters) {
|
|
146
|
+
server.completionProvider.triggerCharacters = (_l = server.completionProvider.triggerCharacters) === null || _l === void 0 ? void 0 : _l.filter(c => !initOptions.ignoreTriggerCharacters.includes(c));
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
if ((_m = params.textDocument) === null || _m === void 0 ? void 0 : _m.documentHighlight) {
|
|
149
|
+
if (!initOptions.respectClientCapabilities || ((_m = params.textDocument) === null || _m === void 0 ? void 0 : _m.documentHighlight)) {
|
|
150
150
|
server.documentHighlightProvider = true;
|
|
151
151
|
}
|
|
152
|
-
if ((_o = params.textDocument) === null || _o === void 0 ? void 0 : _o.documentLink) {
|
|
152
|
+
if (!initOptions.respectClientCapabilities || ((_o = params.textDocument) === null || _o === void 0 ? void 0 : _o.documentLink)) {
|
|
153
153
|
server.documentLinkProvider = {
|
|
154
154
|
resolveProvider: false, // TODO
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
if ((_p = params.workspace) === null || _p === void 0 ? void 0 : _p.symbol) {
|
|
157
|
+
if (!initOptions.respectClientCapabilities || ((_p = params.workspace) === null || _p === void 0 ? void 0 : _p.symbol)) {
|
|
158
158
|
server.workspaceSymbolProvider = true;
|
|
159
159
|
}
|
|
160
|
-
if ((_q = params.textDocument) === null || _q === void 0 ? void 0 : _q.codeLens) {
|
|
160
|
+
if (!initOptions.respectClientCapabilities || ((_q = params.textDocument) === null || _q === void 0 ? void 0 : _q.codeLens)) {
|
|
161
161
|
server.codeLensProvider = {
|
|
162
162
|
resolveProvider: true,
|
|
163
163
|
};
|
|
@@ -168,14 +168,14 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
168
168
|
]
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
if ((_t = params.textDocument) === null || _t === void 0 ? void 0 : _t.semanticTokens) {
|
|
171
|
+
if (!initOptions.respectClientCapabilities || ((_t = params.textDocument) === null || _t === void 0 ? void 0 : _t.semanticTokens)) {
|
|
172
172
|
server.semanticTokensProvider = {
|
|
173
173
|
range: true,
|
|
174
174
|
full: false,
|
|
175
175
|
legend: exports.semanticTokensLegend,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
if ((_u = params.textDocument) === null || _u === void 0 ? void 0 : _u.codeAction) {
|
|
178
|
+
if (!initOptions.respectClientCapabilities || ((_u = params.textDocument) === null || _u === void 0 ? void 0 : _u.codeAction)) {
|
|
179
179
|
server.codeActionProvider = {
|
|
180
180
|
codeActionKinds: [
|
|
181
181
|
vscode.CodeActionKind.Empty,
|
|
@@ -191,10 +191,10 @@ function setupSemanticCapabilities(params, server, options, plugins) {
|
|
|
191
191
|
resolveProvider: true,
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
if ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.inlayHint) {
|
|
194
|
+
if (!initOptions.respectClientCapabilities || ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.inlayHint)) {
|
|
195
195
|
server.inlayHintProvider = true;
|
|
196
196
|
}
|
|
197
|
-
if (((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.diagnostic) && ((_x =
|
|
197
|
+
if (!initOptions.respectClientCapabilities || ((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.diagnostic) && ((_x = initOptions.diagnosticModel) !== null && _x !== void 0 ? _x : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
198
198
|
server.diagnosticProvider = {
|
|
199
199
|
documentSelector: [
|
|
200
200
|
...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: `**/*.${ext.extension}` }))).flat(),
|
package/out/server.js
CHANGED
|
@@ -49,7 +49,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
49
49
|
};
|
|
50
50
|
configHost = ((_c = params.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(params, connection) : undefined;
|
|
51
51
|
const serverMode = (_d = options.serverMode) !== null && _d !== void 0 ? _d : types_1.ServerMode.Semantic;
|
|
52
|
-
(0, registerFeatures_1.setupSyntacticCapabilities)(params.capabilities, result.capabilities);
|
|
52
|
+
(0, registerFeatures_1.setupSyntacticCapabilities)(params.capabilities, result.capabilities, options);
|
|
53
53
|
yield _createDocumentServiceHost();
|
|
54
54
|
if (serverMode === types_1.ServerMode.Semantic) {
|
|
55
55
|
(0, registerFeatures_1.setupSemanticCapabilities)(params.capabilities, result.capabilities, options, plugins);
|
|
@@ -82,19 +82,26 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
if (
|
|
85
|
+
if (options.serverMode !== types_1.ServerMode.Syntactic
|
|
86
|
+
&& !options.disableFileWatcher
|
|
87
|
+
&& ((_h = (_g = params.capabilities.workspace) === null || _g === void 0 ? void 0 : _g.didChangeWatchedFiles) === null || _h === void 0 ? void 0 : _h.dynamicRegistration)) {
|
|
86
88
|
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
|
|
87
89
|
watchers: [
|
|
88
90
|
...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ globPattern: `**/*.${ext.extension}` }))).flat(),
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
{
|
|
92
|
+
globPattern: `**/*.{${[
|
|
93
|
+
'js',
|
|
94
|
+
'cjs',
|
|
95
|
+
'mjs',
|
|
96
|
+
'ts',
|
|
97
|
+
'cts',
|
|
98
|
+
'mts',
|
|
99
|
+
'jsx',
|
|
100
|
+
'tsx',
|
|
101
|
+
'json',
|
|
102
|
+
...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ext.extension)).flat(),
|
|
103
|
+
].join(',')}}`
|
|
104
|
+
},
|
|
98
105
|
]
|
|
99
106
|
});
|
|
100
107
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -60,4 +60,10 @@ export interface LanguageServerInitializationOptions {
|
|
|
60
60
|
*/
|
|
61
61
|
cancellationPipeName?: string;
|
|
62
62
|
noProjectReferences?: boolean;
|
|
63
|
+
reverseConfigFilePriority?: boolean;
|
|
64
|
+
disableFileWatcher?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Enable this option to make language server setup server capabilities based on client capabilities to support multiple servers.
|
|
67
|
+
*/
|
|
68
|
+
respectClientCapabilities?: boolean;
|
|
63
69
|
}
|
|
@@ -12,7 +12,9 @@ exports.createConfigurationHost = void 0;
|
|
|
12
12
|
const vscode = require("vscode-languageserver");
|
|
13
13
|
function createConfigurationHost(params, connection) {
|
|
14
14
|
const callbacks = [];
|
|
15
|
+
let cache = {};
|
|
15
16
|
connection.onDidChangeConfiguration(() => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
cache = {};
|
|
16
18
|
for (const cb of callbacks) {
|
|
17
19
|
cb();
|
|
18
20
|
}
|
|
@@ -25,15 +27,25 @@ function createConfigurationHost(params, connection) {
|
|
|
25
27
|
}
|
|
26
28
|
},
|
|
27
29
|
getConfiguration(section, scopeUri) {
|
|
28
|
-
var _a;
|
|
30
|
+
var _a, _b;
|
|
29
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
|
|
32
|
+
if (!scopeUri && ((_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration)) {
|
|
33
|
+
(_b = cache[section]) !== null && _b !== void 0 ? _b : (cache[section] = yield getConfigurationWorker(section, scopeUri));
|
|
34
|
+
return cache[section];
|
|
35
|
+
}
|
|
36
|
+
return yield getConfigurationWorker(section, scopeUri);
|
|
31
37
|
});
|
|
32
38
|
},
|
|
33
39
|
onDidChangeConfiguration(cb) {
|
|
34
40
|
callbacks.push(cb);
|
|
35
41
|
},
|
|
36
42
|
};
|
|
43
|
+
function getConfigurationWorker(section, scopeUri) {
|
|
44
|
+
var _a;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return (_a = (yield connection.workspace.getConfiguration({ scopeUri, section }))) !== null && _a !== void 0 ? _a : undefined /* replace null to undefined */;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
37
49
|
}
|
|
38
50
|
exports.createConfigurationHost = createConfigurationHost;
|
|
39
51
|
//# sourceMappingURL=configurationHost.js.map
|
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createNodeFileSystemHost = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const vscode = require("vscode-languageserver");
|
|
14
13
|
const iterableWeakSet_1 = require("./iterableWeakSet");
|
|
14
|
+
const uriMap_1 = require("./uriMap");
|
|
15
15
|
let currentCwd = '';
|
|
16
16
|
function createNodeFileSystemHost(ts, capabilities) {
|
|
17
|
-
const instances =
|
|
17
|
+
const instances = (0, uriMap_1.createUriMap)();
|
|
18
18
|
const onDidChangeWatchedFilesCb = new Set();
|
|
19
19
|
const caches = new iterableWeakSet_1.IterableWeakSet();
|
|
20
20
|
return {
|
package/out/utils/project.js
CHANGED
|
@@ -16,6 +16,7 @@ const vscode = require("vscode-languageserver");
|
|
|
16
16
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
17
|
const config_1 = require("./config");
|
|
18
18
|
const path = require("typesafe-path");
|
|
19
|
+
const uriMap_1 = require("./uriMap");
|
|
19
20
|
function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost, serverOptions) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
@@ -24,7 +25,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
24
25
|
let projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
25
26
|
let vueLs;
|
|
26
27
|
let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
|
|
27
|
-
const scripts =
|
|
28
|
+
const scripts = (0, uriMap_1.createUriMap)();
|
|
28
29
|
const languageServiceHost = createLanguageServiceHost();
|
|
29
30
|
const disposeWatchEvent = fsHost.onDidChangeWatchedFiles(params => {
|
|
30
31
|
onWorkspaceFilesChanged(params.changes);
|
package/out/utils/snapshots.js
CHANGED
|
@@ -3,6 +3,7 @@ exports.createSnapshots = exports.combineContinuousChangeRanges = void 0;
|
|
|
3
3
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
4
4
|
const vscode = require("vscode-languageserver");
|
|
5
5
|
const shared = require("@volar/shared");
|
|
6
|
+
const uriMap_1 = require("./uriMap");
|
|
6
7
|
class IncrementalScriptSnapshot {
|
|
7
8
|
constructor(uri, languageId, version, text) {
|
|
8
9
|
this.uri = uri;
|
|
@@ -143,7 +144,7 @@ function _combineContinuousChangeRanges(a, b) {
|
|
|
143
144
|
return { span: { start, length }, newLength };
|
|
144
145
|
}
|
|
145
146
|
function createSnapshots(connection) {
|
|
146
|
-
const snapshots =
|
|
147
|
+
const snapshots = (0, uriMap_1.createUriMap)();
|
|
147
148
|
const onDidChangeContents = new Set();
|
|
148
149
|
const onDidCloses = new Set();
|
|
149
150
|
connection.onDidOpenTextDocument(params => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { URI } from 'vscode-uri';
|
|
2
|
+
export * as _ from 'vscode-uri';
|
|
3
|
+
interface Options<T> {
|
|
4
|
+
delete(key: string): boolean;
|
|
5
|
+
get(key: string): T | undefined;
|
|
6
|
+
has(key: string): boolean;
|
|
7
|
+
set(key: string, value: T): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
values(): IterableIterator<T>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createUriMap<T>(map?: Options<T>): {
|
|
12
|
+
clear: () => void;
|
|
13
|
+
values: () => IterableIterator<T>;
|
|
14
|
+
uriDelete: (_uri: string) => boolean;
|
|
15
|
+
uriGet: (_uri: string) => T | undefined;
|
|
16
|
+
uriHas: (_uri: string) => boolean;
|
|
17
|
+
uriSet: (_uri: string, item: T) => void;
|
|
18
|
+
pathDelete: (rootUri: URI, path: string) => boolean;
|
|
19
|
+
pathGet: (rootUri: URI, path: string) => T | undefined;
|
|
20
|
+
pathHas: (rootUri: URI, path: string) => T | undefined;
|
|
21
|
+
pathSet: (rootUri: URI, path: string, item: T) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.createUriMap = exports._ = void 0;
|
|
3
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
4
|
+
const shared = require("@volar/shared");
|
|
5
|
+
exports._ = require("vscode-uri");
|
|
6
|
+
function createUriMap(map = new Map()) {
|
|
7
|
+
const uriToUriKeys = new Map();
|
|
8
|
+
const pathToUriKeys = new WeakMap();
|
|
9
|
+
return {
|
|
10
|
+
clear,
|
|
11
|
+
values,
|
|
12
|
+
uriDelete,
|
|
13
|
+
uriGet,
|
|
14
|
+
uriHas,
|
|
15
|
+
uriSet,
|
|
16
|
+
pathDelete,
|
|
17
|
+
pathGet,
|
|
18
|
+
pathHas,
|
|
19
|
+
pathSet,
|
|
20
|
+
};
|
|
21
|
+
function getUriByUri(uri) {
|
|
22
|
+
if (!uriToUriKeys.has(uri))
|
|
23
|
+
uriToUriKeys.set(uri, normalizeUri(uri).toLowerCase());
|
|
24
|
+
return uriToUriKeys.get(uri);
|
|
25
|
+
}
|
|
26
|
+
function getUriByPath(rootUri, path) {
|
|
27
|
+
let map = pathToUriKeys.get(rootUri);
|
|
28
|
+
if (!map) {
|
|
29
|
+
map = new Map();
|
|
30
|
+
pathToUriKeys.set(rootUri, map);
|
|
31
|
+
}
|
|
32
|
+
if (!map.has(path)) {
|
|
33
|
+
map.set(path, shared.getUriByPath(rootUri, path).toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
return map.get(path);
|
|
36
|
+
}
|
|
37
|
+
function clear() {
|
|
38
|
+
return map.clear();
|
|
39
|
+
}
|
|
40
|
+
function values() {
|
|
41
|
+
return map.values();
|
|
42
|
+
}
|
|
43
|
+
function uriDelete(_uri) {
|
|
44
|
+
return map.delete(getUriByUri(_uri));
|
|
45
|
+
}
|
|
46
|
+
function uriGet(_uri) {
|
|
47
|
+
return map.get(getUriByUri(_uri));
|
|
48
|
+
}
|
|
49
|
+
function uriHas(_uri) {
|
|
50
|
+
return map.has(getUriByUri(_uri));
|
|
51
|
+
}
|
|
52
|
+
function uriSet(_uri, item) {
|
|
53
|
+
return map.set(getUriByUri(_uri), item);
|
|
54
|
+
}
|
|
55
|
+
function pathDelete(rootUri, path) {
|
|
56
|
+
return uriDelete(getUriByPath(rootUri, path));
|
|
57
|
+
}
|
|
58
|
+
function pathGet(rootUri, path) {
|
|
59
|
+
return uriGet(getUriByPath(rootUri, path));
|
|
60
|
+
}
|
|
61
|
+
function pathHas(rootUri, path) {
|
|
62
|
+
return uriGet(getUriByPath(rootUri, path));
|
|
63
|
+
}
|
|
64
|
+
function pathSet(rootUri, path, item) {
|
|
65
|
+
return uriSet(getUriByPath(rootUri, path), item);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.createUriMap = createUriMap;
|
|
69
|
+
function normalizeUri(uri) {
|
|
70
|
+
try {
|
|
71
|
+
return vscode_uri_1.URI.parse(uri).toString();
|
|
72
|
+
}
|
|
73
|
+
catch (_a) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=uriMap.js.map
|
|
@@ -9,16 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createWebFileSystemHost = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const path = require("typesafe-path");
|
|
14
13
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
15
14
|
const vscode = require("vscode-languageserver");
|
|
16
15
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
16
|
const protocol_1 = require("../protocol");
|
|
18
17
|
const utilities_1 = require("./ts/utilities");
|
|
18
|
+
const uriMap_1 = require("./uriMap");
|
|
19
19
|
let currentCwd = '/';
|
|
20
20
|
function createWebFileSystemHost() {
|
|
21
|
-
const instances =
|
|
21
|
+
const instances = (0, uriMap_1.createUriMap)();
|
|
22
22
|
const onDidChangeWatchedFilesCb = new Set();
|
|
23
23
|
const root = {
|
|
24
24
|
dirs: new Map(),
|
|
@@ -15,13 +15,14 @@ const vscode = require("vscode-languageserver");
|
|
|
15
15
|
const project_1 = require("./project");
|
|
16
16
|
const inferredCompilerOptions_1 = require("./inferredCompilerOptions");
|
|
17
17
|
const vscode_uri_1 = require("vscode-uri");
|
|
18
|
+
const uriMap_1 = require("./uriMap");
|
|
18
19
|
exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
19
20
|
function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configHost, cancelTokenHost, serverOptions) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
let inferredProject;
|
|
22
23
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
23
24
|
const documentRegistry = ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.normalizeFileName(rootUri.fsPath));
|
|
24
|
-
const projects =
|
|
25
|
+
const projects = (0, uriMap_1.createUriMap)();
|
|
25
26
|
const rootTsConfigs = new Set(sys.readDirectory(rootUri.fsPath, exports.rootTsConfigNames, undefined, ['**/*']));
|
|
26
27
|
const disposeWatch = fsHost.onDidChangeWatchedFiles((params, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
const disposes = [];
|
|
@@ -137,7 +138,10 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
137
138
|
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(uri.fsPath, a, b))) {
|
|
138
139
|
const project = yield projects.pathGet(rootUri, rootTsConfig);
|
|
139
140
|
if (project) {
|
|
140
|
-
|
|
141
|
+
let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
|
|
142
|
+
if (serverOptions.reverseConfigFilePriority) {
|
|
143
|
+
chains = chains.reverse();
|
|
144
|
+
}
|
|
141
145
|
for (const chain of chains) {
|
|
142
146
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
143
147
|
const tsconfig = chain[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.0.
|
|
21
|
-
"@volar/language-service": "1.0.
|
|
22
|
-
"@volar/shared": "1.0.
|
|
23
|
-
"request-light": "^0.
|
|
20
|
+
"@volar/language-core": "1.0.10",
|
|
21
|
+
"@volar/language-service": "1.0.10",
|
|
22
|
+
"@volar/shared": "1.0.10",
|
|
23
|
+
"request-light": "^0.6.0",
|
|
24
24
|
"typesafe-path": "^0.2.2",
|
|
25
|
-
"vscode-html-languageservice": "^5.0.
|
|
25
|
+
"vscode-html-languageservice": "^5.0.3",
|
|
26
26
|
"vscode-languageserver": "^8.0.2",
|
|
27
27
|
"vscode-languageserver-protocol": "^3.17.2",
|
|
28
28
|
"vscode-languageserver-textdocument": "^1.0.7",
|
|
29
29
|
"vscode-uri": "^3.0.6"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "89b82f92fdc30674b03941c5f17c60df8c46211c"
|
|
32
32
|
}
|