@volar/language-server 1.0.16 → 1.0.18
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/{utils/webFileSystemHost.d.ts → browser/fileSystems.d.ts} +0 -0
- package/out/{utils/webFileSystemHost.js → browser/fileSystems.js} +4 -4
- package/out/{browser.d.ts → browser/index.d.ts} +2 -2
- package/out/{browser.js → browser/index.js} +32 -28
- package/out/{utils/ts → browser/typescript}/core.d.ts +0 -0
- package/out/{utils/ts → browser/typescript}/core.js +0 -0
- package/out/{utils/ts → browser/typescript}/corePublic.d.ts +0 -0
- package/out/{utils/ts → browser/typescript}/corePublic.js +0 -0
- package/out/{utils/ts → browser/typescript}/path.d.ts +0 -0
- package/out/{utils/ts → browser/typescript}/path.js +0 -0
- package/out/{utils/ts → browser/typescript}/types.d.ts +0 -0
- package/out/{utils/ts → browser/typescript}/types.js +0 -0
- package/out/{utils/ts → browser/typescript}/utilities.d.ts +0 -0
- package/out/{utils/ts → browser/typescript}/utilities.js +0 -0
- package/out/{utils → common}/cancellationPipe.d.ts +0 -0
- package/out/{utils → common}/cancellationPipe.js +0 -0
- package/out/{utils → common}/configurationHost.d.ts +1 -1
- package/out/{utils → common}/configurationHost.js +7 -5
- package/out/{utils/snapshots.d.ts → common/documents.d.ts} +1 -1
- package/out/{utils/snapshots.js → common/documents.js} +5 -5
- package/out/{features → common/features}/customFeatures.d.ts +1 -1
- package/out/{features → common/features}/customFeatures.js +20 -42
- package/out/common/features/documentFeatures.d.ts +4 -0
- package/out/{features → common/features}/documentFeatures.js +1 -1
- package/out/common/features/languageFeatures.d.ts +4 -0
- package/out/{features → common/features}/languageFeatures.js +4 -5
- package/out/{utils → common}/project.d.ts +14 -9
- package/out/{utils → common}/project.js +24 -16
- package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/file.d.ts +0 -0
- package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/file.js +0 -0
- package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/http.d.ts +0 -0
- package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/http.js +0 -0
- package/out/common/server.d.ts +8 -0
- package/out/{server.js → common/server.js} +94 -34
- package/out/{utils/documentServiceHost.d.ts → common/syntaxServicesHost.d.ts} +2 -2
- package/out/{utils/documentServiceHost.js → common/syntaxServicesHost.js} +10 -10
- package/out/{utils → common/utils}/inferredCompilerOptions.d.ts +0 -0
- package/out/{utils → common/utils}/inferredCompilerOptions.js +0 -0
- package/out/{registerFeatures.d.ts → common/utils/registerFeatures.d.ts} +2 -3
- package/out/{registerFeatures.js → common/utils/registerFeatures.js} +5 -48
- package/out/{utils/config.d.ts → common/utils/serverConfig.d.ts} +0 -0
- package/out/{utils/config.js → common/utils/serverConfig.js} +1 -1
- package/out/{utils → common/utils}/uriMap.d.ts +0 -0
- package/out/{utils → common/utils}/uriMap.js +0 -0
- package/out/common/workspace.d.ts +1186 -0
- package/out/{utils/workspaceProjects.js → common/workspace.js} +29 -13
- package/out/common/workspaces.d.ts +1465 -0
- package/out/{utils → common}/workspaces.js +15 -10
- package/out/{utils/nodeFileSystemHost.d.ts → node/fileSystem.d.ts} +0 -0
- package/out/{utils/nodeFileSystemHost.js → node/fileSystem.js} +17 -19
- package/out/{node.d.ts → node/index.d.ts} +2 -2
- package/out/node/index.js +107 -0
- package/out/protocol.d.ts +4 -6
- package/out/protocol.js +1 -5
- package/out/types.d.ts +5 -3
- package/package.json +5 -5
- package/out/features/documentFeatures.d.ts +0 -4
- package/out/features/languageFeatures.d.ts +0 -4
- package/out/node.js +0 -103
- package/out/server.d.ts +0 -3
- package/out/utils/iterableWeakSet.d.ts +0 -7
- package/out/utils/iterableWeakSet.js +0 -40
- package/out/utils/workspaceProjects.d.ts +0 -162
- package/out/utils/workspaces.d.ts +0 -429
|
File without changes
|
|
@@ -14,8 +14,8 @@ const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
|
14
14
|
const vscode = require("vscode-languageserver");
|
|
15
15
|
const vscode_uri_1 = require("vscode-uri");
|
|
16
16
|
const protocol_1 = require("../protocol");
|
|
17
|
-
const utilities_1 = require("./
|
|
18
|
-
const uriMap_1 = require("
|
|
17
|
+
const utilities_1 = require("./typescript/utilities");
|
|
18
|
+
const uriMap_1 = require("../common/utils/uriMap");
|
|
19
19
|
const shared = require("@volar/shared");
|
|
20
20
|
let currentCwd = '/';
|
|
21
21
|
function createWebFileSystemHost() {
|
|
@@ -58,7 +58,7 @@ function createWebFileSystemHost() {
|
|
|
58
58
|
}
|
|
59
59
|
onReadys.length = 0;
|
|
60
60
|
},
|
|
61
|
-
|
|
61
|
+
reload() {
|
|
62
62
|
root.dirs.clear();
|
|
63
63
|
root.fileTexts.clear();
|
|
64
64
|
root.fileTypes.clear();
|
|
@@ -315,4 +315,4 @@ function createWebFileSystemHost() {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
exports.createWebFileSystemHost = createWebFileSystemHost;
|
|
318
|
-
//# sourceMappingURL=
|
|
318
|
+
//# sourceMappingURL=fileSystems.js.map
|
|
@@ -26,39 +26,43 @@ exports.createLanguageServer = void 0;
|
|
|
26
26
|
const request_light_1 = require("request-light");
|
|
27
27
|
const ts = require("typescript/lib/tsserverlibrary"); // bundle typescript lib in web
|
|
28
28
|
const vscode = require("vscode-languageserver/browser");
|
|
29
|
-
const server_1 = require("
|
|
30
|
-
const http_1 = require("
|
|
31
|
-
const
|
|
29
|
+
const server_1 = require("../common/server");
|
|
30
|
+
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
31
|
+
const fileSystems_1 = require("./fileSystems");
|
|
32
32
|
const shared = require("@volar/shared");
|
|
33
|
+
__exportStar(require("../index"), exports);
|
|
33
34
|
function createLanguageServer(plugins) {
|
|
34
35
|
const messageReader = new vscode.BrowserMessageReader(self);
|
|
35
36
|
const messageWriter = new vscode.BrowserMessageWriter(self);
|
|
36
37
|
const connection = vscode.createConnection(messageReader, messageWriter);
|
|
37
|
-
(0, server_1.createCommonLanguageServer)(
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
(0, server_1.createCommonLanguageServer)({
|
|
39
|
+
plugins,
|
|
40
|
+
connection,
|
|
41
|
+
runtimeEnv: {
|
|
42
|
+
loadTypescript() {
|
|
43
|
+
return ts; // not support load by user config in web
|
|
44
|
+
},
|
|
45
|
+
loadTypescriptLocalized(tsdk, locale) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
try {
|
|
48
|
+
const uri = shared.getUriByPath(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
49
|
+
const json = yield (0, http_1.default)(uri);
|
|
50
|
+
return JSON.parse(json);
|
|
51
|
+
}
|
|
52
|
+
catch (_a) { }
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
schemaRequestHandlers: {
|
|
56
|
+
http: http_1.default,
|
|
57
|
+
https: http_1.default,
|
|
58
|
+
},
|
|
59
|
+
onDidChangeConfiguration(settings) {
|
|
60
|
+
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
61
|
+
},
|
|
62
|
+
fileSystemProvide: undefined,
|
|
63
|
+
createFileSystemHost: fileSystems_1.createWebFileSystemHost,
|
|
40
64
|
},
|
|
41
|
-
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
try {
|
|
44
|
-
const uri = shared.getUriByPath(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
45
|
-
const json = yield (0, http_1.default)(uri);
|
|
46
|
-
return JSON.parse(json);
|
|
47
|
-
}
|
|
48
|
-
catch (_a) { }
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
schemaRequestHandlers: {
|
|
52
|
-
http: http_1.default,
|
|
53
|
-
https: http_1.default,
|
|
54
|
-
},
|
|
55
|
-
onDidChangeConfiguration(settings) {
|
|
56
|
-
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
57
|
-
},
|
|
58
|
-
fileSystemProvide: undefined,
|
|
59
|
-
createFileSystemHost: webFileSystemHost_1.createWebFileSystemHost,
|
|
60
|
-
}, plugins);
|
|
65
|
+
});
|
|
61
66
|
}
|
|
62
67
|
exports.createLanguageServer = createLanguageServer;
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=browser.js.map
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver';
|
|
2
1
|
import { ConfigurationHost } from '@volar/language-service';
|
|
2
|
+
import * as vscode from 'vscode-languageserver';
|
|
3
3
|
export declare function createConfigurationHost(params: vscode.InitializeParams, connection: vscode.Connection): ConfigurationHost & {
|
|
4
4
|
ready(): void;
|
|
5
5
|
};
|
|
@@ -12,9 +12,9 @@ exports.createConfigurationHost = void 0;
|
|
|
12
12
|
const vscode = require("vscode-languageserver");
|
|
13
13
|
function createConfigurationHost(params, connection) {
|
|
14
14
|
const callbacks = [];
|
|
15
|
-
|
|
15
|
+
const cache = new Map();
|
|
16
16
|
connection.onDidChangeConfiguration(() => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
cache
|
|
17
|
+
cache.clear();
|
|
18
18
|
for (const cb of callbacks) {
|
|
19
19
|
cb();
|
|
20
20
|
}
|
|
@@ -27,11 +27,13 @@ function createConfigurationHost(params, connection) {
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
getConfiguration(section, scopeUri) {
|
|
30
|
-
var _a
|
|
30
|
+
var _a;
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
if (!scopeUri && ((_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration)) {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (!cache.has(section)) {
|
|
34
|
+
cache.set(section, yield getConfigurationWorker(section, scopeUri));
|
|
35
|
+
}
|
|
36
|
+
return cache.get(section);
|
|
35
37
|
}
|
|
36
38
|
return yield getConfigurationWorker(section, scopeUri);
|
|
37
39
|
});
|
|
@@ -24,7 +24,7 @@ declare class IncrementalScriptSnapshot {
|
|
|
24
24
|
applyVersionChanges(version: number, removeBeforeVersions: boolean): void;
|
|
25
25
|
}
|
|
26
26
|
export declare function combineContinuousChangeRanges(...changeRanges: ts.TextChangeRange[]): ts.TextChangeRange;
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function createDocuments(connection: vscode.Connection): {
|
|
28
28
|
data: {
|
|
29
29
|
clear: () => void;
|
|
30
30
|
values: () => IterableIterator<IncrementalScriptSnapshot>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
|
|
3
3
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
4
4
|
const vscode = require("vscode-languageserver");
|
|
5
|
-
const uriMap_1 = require("./uriMap");
|
|
5
|
+
const uriMap_1 = require("./utils/uriMap");
|
|
6
6
|
class IncrementalScriptSnapshot {
|
|
7
7
|
constructor(uri, languageId, version, text) {
|
|
8
8
|
this.uri = uri;
|
|
@@ -145,7 +145,7 @@ function _combineContinuousChangeRanges(a, b) {
|
|
|
145
145
|
const newLength = aDiff + bDiff + length;
|
|
146
146
|
return { span: { start, length }, newLength };
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function createDocuments(connection) {
|
|
149
149
|
const snapshots = (0, uriMap_1.createUriMap)();
|
|
150
150
|
const onDidChangeContents = new Set();
|
|
151
151
|
const onDidCloses = new Set();
|
|
@@ -195,5 +195,5 @@ function createSnapshots(connection) {
|
|
|
195
195
|
},
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
exports.
|
|
199
|
-
//# sourceMappingURL=
|
|
198
|
+
exports.createDocuments = createDocuments;
|
|
199
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
|
-
const
|
|
14
|
-
const vscode = require("vscode-languageserver");
|
|
15
|
-
const protocol_1 = require("../protocol");
|
|
13
|
+
const protocol_1 = require("../../protocol");
|
|
16
14
|
const language_core_1 = require("@volar/language-core");
|
|
17
15
|
function register(connection, projects) {
|
|
18
16
|
connection.onNotification(protocol_1.ReportStats.type, () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -77,10 +75,10 @@ function register(connection, projects) {
|
|
|
77
75
|
const project = yield projects.getProject(document.uri);
|
|
78
76
|
const fileNames = [];
|
|
79
77
|
if (project) {
|
|
80
|
-
const sourceFile = (_p = (_o = project.project) === null || _o === void 0 ? void 0 : _o.getLanguageService().context.core.
|
|
78
|
+
const sourceFile = (_p = (_o = project.project) === null || _o === void 0 ? void 0 : _o.getLanguageService().context.core.virtualFiles.get(shared.getPathOfUri(document.uri))) === null || _p === void 0 ? void 0 : _p[1];
|
|
81
79
|
if (sourceFile) {
|
|
82
|
-
(0, language_core_1.
|
|
83
|
-
if (e.
|
|
80
|
+
(0, language_core_1.forEachEmbeddedFile)(sourceFile, e => {
|
|
81
|
+
if (e.snapshot.getLength() && e.kind === 1) {
|
|
84
82
|
fileNames.push(e.fileName);
|
|
85
83
|
}
|
|
86
84
|
});
|
|
@@ -89,14 +87,21 @@ function register(connection, projects) {
|
|
|
89
87
|
return fileNames;
|
|
90
88
|
}));
|
|
91
89
|
connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
var _q, _r;
|
|
90
|
+
var _q, _r, _s;
|
|
93
91
|
const project = yield projects.getProject(params.sourceFileUri);
|
|
94
92
|
if (project) {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
93
|
+
const sourceAndVirtual = (_q = project.project) === null || _q === void 0 ? void 0 : _q.getLanguageService().context.core.virtualFiles.getSourceByVirtualFileName(params.virtualFileName);
|
|
94
|
+
if (sourceAndVirtual) {
|
|
95
|
+
const virtualFile = sourceAndVirtual[2];
|
|
96
|
+
const mappings = {};
|
|
97
|
+
for (const mapping of virtualFile.mappings) {
|
|
98
|
+
const sourceUri = shared.getUriByPath((_r = mapping.source) !== null && _r !== void 0 ? _r : sourceAndVirtual[0]);
|
|
99
|
+
(_s = mappings[sourceUri]) !== null && _s !== void 0 ? _s : (mappings[sourceUri] = []);
|
|
100
|
+
mappings[sourceUri].push(mapping);
|
|
101
|
+
}
|
|
97
102
|
return {
|
|
98
|
-
content:
|
|
99
|
-
mappings
|
|
103
|
+
content: virtualFile.snapshot.getText(0, virtualFile.snapshot.getLength()),
|
|
104
|
+
mappings,
|
|
100
105
|
};
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -105,16 +110,16 @@ function register(connection, projects) {
|
|
|
105
110
|
projects.reloadProject();
|
|
106
111
|
});
|
|
107
112
|
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
var
|
|
113
|
+
var _t;
|
|
109
114
|
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
110
115
|
const project = yield projects.getProject(params.uri);
|
|
111
116
|
if (project) {
|
|
112
|
-
const ls = (
|
|
117
|
+
const ls = (_t = (yield project.project)) === null || _t === void 0 ? void 0 : _t.getLanguageServiceDontCreate();
|
|
113
118
|
if (ls) {
|
|
114
119
|
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
115
|
-
for (const virtualFile of ls.context.core.
|
|
120
|
+
for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
|
|
116
121
|
if (virtualFile.startsWith(ls.context.host.getCurrentDirectory()) && !sourceFiles.has(virtualFile)) {
|
|
117
|
-
const snapshot = ls.context.core.
|
|
122
|
+
const snapshot = ls.context.core.typescript.languageServiceHost.getScriptSnapshot(virtualFile);
|
|
118
123
|
if (snapshot) {
|
|
119
124
|
fs.writeFile(virtualFile, snapshot.getText(0, snapshot.getLength()), () => { });
|
|
120
125
|
}
|
|
@@ -123,33 +128,6 @@ function register(connection, projects) {
|
|
|
123
128
|
}
|
|
124
129
|
}
|
|
125
130
|
}));
|
|
126
|
-
connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
var _t;
|
|
128
|
-
let errors = 0;
|
|
129
|
-
let warnings = 0;
|
|
130
|
-
const progress = yield connection.window.createWorkDoneProgress();
|
|
131
|
-
progress.begin('Verify', 0, '', true);
|
|
132
|
-
const project = yield projects.getProject(params.uri);
|
|
133
|
-
if (project) {
|
|
134
|
-
const ls = (_t = (yield project.project)) === null || _t === void 0 ? void 0 : _t.getLanguageServiceDontCreate();
|
|
135
|
-
if (ls) {
|
|
136
|
-
const allVueDocuments = ls.context.documents.getAll();
|
|
137
|
-
let i = 0;
|
|
138
|
-
for (const vueFile of allVueDocuments) {
|
|
139
|
-
progress.report(i++ / allVueDocuments.length * 100, path.relative(ls.context.host.getCurrentDirectory(), shared.getPathOfUri(vueFile.uri)));
|
|
140
|
-
if (progress.token.isCancellationRequested) {
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
let _result = yield ls.doValidation(vueFile.uri, progress.token);
|
|
144
|
-
connection.sendDiagnostics({ uri: vueFile.uri, diagnostics: _result });
|
|
145
|
-
errors += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Error).length;
|
|
146
|
-
warnings += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Warning).length;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
progress.done();
|
|
151
|
-
connection.window.showInformationMessage(`Verification complete. Found ${errors} errors and ${warnings} warnings.`);
|
|
152
|
-
}));
|
|
153
131
|
}
|
|
154
132
|
exports.register = register;
|
|
155
133
|
//# sourceMappingURL=customFeatures.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { createDocuments } from '../documents';
|
|
3
|
+
import { createSyntaxServicesHost } from '../syntaxServicesHost';
|
|
4
|
+
export declare function register(connection: vscode.Connection, documents: ReturnType<typeof createDocuments>, documentServiceHost: ReturnType<typeof createSyntaxServicesHost>): void;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = void 0;
|
|
12
|
-
const protocol_1 = require("
|
|
12
|
+
const protocol_1 = require("../../protocol");
|
|
13
13
|
function register(connection, documents, documentServiceHost) {
|
|
14
14
|
connection.onDocumentFormatting(params => {
|
|
15
15
|
return worker(params.textDocument.uri, document => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { CancellationTokenHost } from '../cancellationPipe';
|
|
3
|
+
import type { Workspaces } from '../workspaces';
|
|
4
|
+
export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellationTokenHost, semanticTokensLegend: vscode.SemanticTokensLegend): void;
|
|
@@ -11,10 +11,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.register = void 0;
|
|
12
12
|
const embedded = require("@volar/language-service");
|
|
13
13
|
const vscode = require("vscode-languageserver");
|
|
14
|
-
const protocol_1 = require("
|
|
14
|
+
const protocol_1 = require("../../protocol");
|
|
15
15
|
const shared = require("@volar/shared");
|
|
16
|
-
|
|
17
|
-
function register(connection, projects, initParams, cancelHost) {
|
|
16
|
+
function register(connection, projects, initParams, cancelHost, semanticTokensLegend) {
|
|
18
17
|
let lastCompleteUri;
|
|
19
18
|
let lastCompleteLs;
|
|
20
19
|
let lastCodeLensLs;
|
|
@@ -181,7 +180,7 @@ function register(connection, projects, initParams, cancelHost) {
|
|
|
181
180
|
return buildTokens([]);
|
|
182
181
|
return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
183
182
|
var _k;
|
|
184
|
-
const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined,
|
|
183
|
+
const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
|
|
185
184
|
return buildTokens(result);
|
|
186
185
|
}))) !== null && _j !== void 0 ? _j : buildTokens([]);
|
|
187
186
|
}));
|
|
@@ -192,7 +191,7 @@ function register(connection, projects, initParams, cancelHost) {
|
|
|
192
191
|
return buildTokens([]);
|
|
193
192
|
return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
194
193
|
var _m;
|
|
195
|
-
const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range,
|
|
194
|
+
const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
|
|
196
195
|
return buildTokens(result);
|
|
197
196
|
}))) !== null && _l !== void 0 ? _l : buildTokens([]);
|
|
198
197
|
}));
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import * as embedded from '@volar/language-core';
|
|
1
2
|
import * as embeddedLS from '@volar/language-service';
|
|
3
|
+
import * as path from 'typesafe-path';
|
|
2
4
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
5
|
import { URI } from 'vscode-uri';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { WorkspaceParams } from './workspace';
|
|
7
|
+
import { LanguageServicePlugin } from '@volar/language-service';
|
|
8
|
+
export interface ProjectParams {
|
|
9
|
+
workspace: WorkspaceParams;
|
|
10
|
+
rootUri: URI;
|
|
11
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
12
|
+
documentRegistry: ts.DocumentRegistry;
|
|
13
|
+
workspacePlugins: LanguageServicePlugin[];
|
|
10
14
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
15
|
+
export type Project = ReturnType<typeof createProject>;
|
|
16
|
+
export declare function createProject(params: ProjectParams): Promise<{
|
|
17
|
+
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
13
18
|
scripts: {
|
|
14
19
|
clear: () => void;
|
|
15
20
|
values: () => IterableIterator<{
|
|
@@ -52,7 +57,7 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
52
57
|
snapshotVersion: number | undefined;
|
|
53
58
|
}) => void;
|
|
54
59
|
};
|
|
55
|
-
languageServiceHost:
|
|
60
|
+
languageServiceHost: embedded.LanguageServiceHost;
|
|
56
61
|
getLanguageService: () => {
|
|
57
62
|
doValidation: (uri: string, token?: embeddedLS.CancellationToken | undefined, response?: ((result: embeddedLS.Diagnostic[]) => void) | undefined) => Promise<embeddedLS.Diagnostic[]>;
|
|
58
63
|
findReferences: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Location[] | undefined>;
|
|
@@ -9,16 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createProject = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
|
-
const embeddedLS = require("@volar/language-service");
|
|
14
12
|
const embedded = require("@volar/language-core");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
13
|
+
const embeddedLS = require("@volar/language-service");
|
|
14
|
+
const shared = require("@volar/shared");
|
|
17
15
|
const path = require("typesafe-path");
|
|
18
|
-
const
|
|
19
|
-
|
|
16
|
+
const vscode = require("vscode-languageserver");
|
|
17
|
+
const uriMap_1 = require("./utils/uriMap");
|
|
18
|
+
function createProject(params) {
|
|
20
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const
|
|
20
|
+
const { tsConfig, documentRegistry, rootUri } = params;
|
|
21
|
+
const { ts, fileSystemHost, documents, cancelTokenHost, tsLocalized, initOptions, configurationHost } = params.workspace.workspaces;
|
|
22
|
+
const { plugins } = params.workspace.workspaces;
|
|
23
|
+
const { runtimeEnv } = params.workspace.workspaces.server;
|
|
24
|
+
const sys = fileSystemHost.getWorkspaceFileSystem(rootUri);
|
|
22
25
|
let typeRootVersion = 0;
|
|
23
26
|
let projectVersion = 0;
|
|
24
27
|
let projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
@@ -26,7 +29,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
26
29
|
let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
|
|
27
30
|
const scripts = (0, uriMap_1.createUriMap)();
|
|
28
31
|
const languageServiceHost = createLanguageServiceHost();
|
|
29
|
-
const disposeWatchEvent =
|
|
32
|
+
const disposeWatchEvent = fileSystemHost.onDidChangeWatchedFiles(params => {
|
|
30
33
|
onWorkspaceFilesChanged(params.changes);
|
|
31
34
|
});
|
|
32
35
|
const disposeDocChange = documents.onDidChangeContent(() => {
|
|
@@ -44,6 +47,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
44
47
|
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
45
48
|
parsedCommandLine.fileNames.push(fileName);
|
|
46
49
|
projectVersion++;
|
|
50
|
+
projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
dispose,
|
|
@@ -51,19 +55,19 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
51
55
|
function getLanguageService() {
|
|
52
56
|
if (!vueLs) {
|
|
53
57
|
const languageModules = plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getLanguageModules) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost)) !== null && _c !== void 0 ? _c : []; }).flat();
|
|
54
|
-
const languageContext = embedded.
|
|
58
|
+
const languageContext = embedded.createLanguageContext(languageServiceHost, languageModules);
|
|
55
59
|
const languageServiceContext = embeddedLS.createLanguageServiceContext({
|
|
56
60
|
host: languageServiceHost,
|
|
57
61
|
context: languageContext,
|
|
58
62
|
getPlugins() {
|
|
59
63
|
return [
|
|
60
|
-
...
|
|
64
|
+
...params.workspacePlugins,
|
|
61
65
|
...plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost, vueLs)) !== null && _c !== void 0 ? _c : []; }).flat(),
|
|
62
66
|
];
|
|
63
67
|
},
|
|
64
68
|
env: {
|
|
65
69
|
rootUri,
|
|
66
|
-
configurationHost:
|
|
70
|
+
configurationHost: configurationHost,
|
|
67
71
|
fileSystemProvider: runtimeEnv.fileSystemProvide,
|
|
68
72
|
documentContext: getHTMLDocumentContext(ts, languageServiceHost),
|
|
69
73
|
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -83,6 +87,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
83
87
|
}
|
|
84
88
|
function onWorkspaceFilesChanged(changes) {
|
|
85
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const _projectVersion = projectVersion;
|
|
86
91
|
for (const change of changes) {
|
|
87
92
|
const script = scripts.uriGet(change.uri);
|
|
88
93
|
if (script && (change.type === vscode.FileChangeType.Changed || change.type === vscode.FileChangeType.Created)) {
|
|
@@ -107,6 +112,9 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
107
112
|
projectVersion++;
|
|
108
113
|
typeRootVersion++;
|
|
109
114
|
}
|
|
115
|
+
if (_projectVersion !== projectVersion) {
|
|
116
|
+
projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
117
|
+
}
|
|
110
118
|
});
|
|
111
119
|
}
|
|
112
120
|
function createLanguageServiceHost() {
|
|
@@ -138,7 +146,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
138
146
|
}
|
|
139
147
|
catch (_a) {
|
|
140
148
|
// web
|
|
141
|
-
return
|
|
149
|
+
return initOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
|
|
142
150
|
}
|
|
143
151
|
},
|
|
144
152
|
getProjectVersion: () => projectVersion.toString(),
|
|
@@ -149,7 +157,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
149
157
|
getScriptSnapshot,
|
|
150
158
|
getTypeScriptModule: () => ts,
|
|
151
159
|
};
|
|
152
|
-
if (
|
|
160
|
+
if (initOptions.noProjectReferences) {
|
|
153
161
|
host.getProjectReferences = undefined;
|
|
154
162
|
host.getCompilationSettings = () => (Object.assign(Object.assign({}, parsedCommandLine.options), { rootDir: undefined, composite: false }));
|
|
155
163
|
}
|
|
@@ -181,10 +189,10 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
181
189
|
return script.snapshot;
|
|
182
190
|
}
|
|
183
191
|
if (sys.fileExists(fileName)) {
|
|
184
|
-
if (
|
|
192
|
+
if (initOptions.maxFileSize) {
|
|
185
193
|
const fileSize = (_a = sys.getFileSize) === null || _a === void 0 ? void 0 : _a.call(sys, fileName);
|
|
186
|
-
if (fileSize !== undefined && fileSize >
|
|
187
|
-
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${
|
|
194
|
+
if (fileSize !== undefined && fileSize > initOptions.maxFileSize) {
|
|
195
|
+
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${initOptions.maxFileSize}bytes)`);
|
|
188
196
|
return ts.ScriptSnapshot.fromString('');
|
|
189
197
|
}
|
|
190
198
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
3
|
+
export interface ServerParams {
|
|
4
|
+
connection: vscode.Connection;
|
|
5
|
+
runtimeEnv: RuntimeEnvironment;
|
|
6
|
+
plugins: LanguageServerPlugin[];
|
|
7
|
+
}
|
|
8
|
+
export declare function createCommonLanguageServer(params: ServerParams): void;
|