@volar/language-server 1.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/out/browser.d.ts +3 -0
- package/out/browser.js +47 -0
- package/out/features/customFeatures.d.ts +4 -0
- package/out/features/customFeatures.js +83 -0
- package/out/features/documentFeatures.d.ts +4 -0
- package/out/features/documentFeatures.js +73 -0
- package/out/features/languageFeatures.d.ts +4 -0
- package/out/features/languageFeatures.js +274 -0
- package/out/index.d.ts +3 -0
- package/out/index.js +19 -0
- package/out/node.d.ts +3 -0
- package/out/node.js +88 -0
- package/out/registers/registerDocumentFeatures.d.ts +3 -0
- package/out/registers/registerDocumentFeatures.js +30 -0
- package/out/registers/registerlanguageFeatures.d.ts +3 -0
- package/out/registers/registerlanguageFeatures.js +144 -0
- package/out/requests.d.ts +81 -0
- package/out/requests.js +65 -0
- package/out/schemaRequestHandlers/file.d.ts +2 -0
- package/out/schemaRequestHandlers/file.js +12 -0
- package/out/schemaRequestHandlers/http.d.ts +1 -0
- package/out/schemaRequestHandlers/http.js +12 -0
- package/out/server.d.ts +3 -0
- package/out/server.js +99 -0
- package/out/types.d.ts +112 -0
- package/out/types.js +2 -0
- package/out/utils/config.d.ts +2 -0
- package/out/utils/config.js +17 -0
- package/out/utils/configurationHost.d.ts +5 -0
- package/out/utils/configurationHost.js +38 -0
- package/out/utils/documentServiceHost.d.ts +30 -0
- package/out/utils/documentServiceHost.js +51 -0
- package/out/utils/inferredCompilerOptions.d.ts +3 -0
- package/out/utils/inferredCompilerOptions.js +71 -0
- package/out/utils/iterableWeakSet.d.ts +7 -0
- package/out/utils/iterableWeakSet.js +40 -0
- package/out/utils/nodeFileSystemHost.d.ts +3 -0
- package/out/utils/nodeFileSystemHost.js +95 -0
- package/out/utils/project.d.ts +99 -0
- package/out/utils/project.js +273 -0
- package/out/utils/snapshots.d.ts +45 -0
- package/out/utils/snapshots.js +201 -0
- package/out/utils/ts/core.d.ts +83 -0
- package/out/utils/ts/core.js +319 -0
- package/out/utils/ts/corePublic.d.ts +91 -0
- package/out/utils/ts/corePublic.js +50 -0
- package/out/utils/ts/path.d.ts +112 -0
- package/out/utils/ts/path.js +416 -0
- package/out/utils/ts/types.d.ts +129 -0
- package/out/utils/ts/types.js +2 -0
- package/out/utils/ts/utilities.d.ts +7 -0
- package/out/utils/ts/utilities.js +249 -0
- package/out/utils/webFileSystemHost.d.ts +2 -0
- package/out/utils/webFileSystemHost.js +265 -0
- package/out/utils/workspaceProjects.d.ts +120 -0
- package/out/utils/workspaceProjects.js +226 -0
- package/out/utils/workspaces.d.ts +309 -0
- package/out/utils/workspaces.js +154 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Johnson Chu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/out/browser.d.ts
ADDED
package/out/browser.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createLanguageServer = void 0;
|
|
17
|
+
const request_light_1 = require("request-light");
|
|
18
|
+
const ts = require("typescript/lib/tsserverlibrary"); // bundle typescript lib in web
|
|
19
|
+
const vscode = require("vscode-languageserver/browser");
|
|
20
|
+
const server_1 = require("./server");
|
|
21
|
+
const http_1 = require("./schemaRequestHandlers/http");
|
|
22
|
+
const webFileSystemHost_1 = require("./utils/webFileSystemHost");
|
|
23
|
+
function createLanguageServer(plugins) {
|
|
24
|
+
const messageReader = new vscode.BrowserMessageReader(self);
|
|
25
|
+
const messageWriter = new vscode.BrowserMessageWriter(self);
|
|
26
|
+
const connection = vscode.createConnection(messageReader, messageWriter);
|
|
27
|
+
(0, server_1.createCommonLanguageServer)(connection, {
|
|
28
|
+
loadTypescript(options) {
|
|
29
|
+
return ts; // not support load by user config in web
|
|
30
|
+
},
|
|
31
|
+
loadTypescriptLocalized(options) {
|
|
32
|
+
// TODO
|
|
33
|
+
},
|
|
34
|
+
schemaRequestHandlers: {
|
|
35
|
+
http: http_1.default,
|
|
36
|
+
https: http_1.default,
|
|
37
|
+
},
|
|
38
|
+
onDidChangeConfiguration(settings) {
|
|
39
|
+
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
40
|
+
},
|
|
41
|
+
fileSystemProvide: undefined,
|
|
42
|
+
createFileSystemHost: webFileSystemHost_1.createWebFileSystemHost,
|
|
43
|
+
}, plugins);
|
|
44
|
+
}
|
|
45
|
+
exports.createLanguageServer = createLanguageServer;
|
|
46
|
+
__exportStar(require("./index"), exports);
|
|
47
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import type { Workspaces } from '../utils/workspaces';
|
|
3
|
+
import { LanguageServerPlugin } from '../types';
|
|
4
|
+
export declare function register(connection: vscode.Connection, projects: Workspaces, plugins: ReturnType<LanguageServerPlugin>[]): void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
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
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.register = void 0;
|
|
12
|
+
const shared = require("@volar/shared");
|
|
13
|
+
const path = require("upath");
|
|
14
|
+
const vscode = require("vscode-languageserver");
|
|
15
|
+
const requests_1 = require("../requests");
|
|
16
|
+
function register(connection, projects, plugins) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
connection.onRequest(requests_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
var _c;
|
|
20
|
+
return (_c = (yield projects.getProject(params.uri))) === null || _c === void 0 ? void 0 : _c.tsconfig;
|
|
21
|
+
}));
|
|
22
|
+
connection.onNotification(requests_1.ReloadProjectNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
projects.reloadProject();
|
|
24
|
+
}));
|
|
25
|
+
connection.onNotification(requests_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _d;
|
|
27
|
+
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
28
|
+
const project = yield projects.getProject(params.uri);
|
|
29
|
+
if (project) {
|
|
30
|
+
const ls = (_d = (yield project.project)) === null || _d === void 0 ? void 0 : _d.getLanguageServiceDontCreate();
|
|
31
|
+
if (ls) {
|
|
32
|
+
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
33
|
+
for (const virtualFile of ls.context.core.typescriptLanguageServiceHost.getScriptFileNames()) {
|
|
34
|
+
if (virtualFile.startsWith(ls.context.host.getCurrentDirectory()) && !sourceFiles.has(virtualFile)) {
|
|
35
|
+
const snapshot = ls.context.core.typescriptLanguageServiceHost.getScriptSnapshot(virtualFile);
|
|
36
|
+
if (snapshot) {
|
|
37
|
+
fs.writeFile(virtualFile, snapshot.getText(0, snapshot.getLength()), () => { });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
connection.onNotification(requests_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
var _e;
|
|
46
|
+
let errors = 0;
|
|
47
|
+
let warnings = 0;
|
|
48
|
+
const progress = yield connection.window.createWorkDoneProgress();
|
|
49
|
+
progress.begin('Verify', 0, '', true);
|
|
50
|
+
const project = yield projects.getProject(params.uri);
|
|
51
|
+
if (project) {
|
|
52
|
+
const ls = (_e = (yield project.project)) === null || _e === void 0 ? void 0 : _e.getLanguageServiceDontCreate();
|
|
53
|
+
if (ls) {
|
|
54
|
+
const allVueDocuments = ls.context.documents.getAll();
|
|
55
|
+
let i = 0;
|
|
56
|
+
for (const vueFile of allVueDocuments) {
|
|
57
|
+
progress.report(i++ / allVueDocuments.length * 100, path.relative(ls.context.host.getCurrentDirectory(), shared.getPathOfUri(vueFile.uri)));
|
|
58
|
+
if (progress.token.isCancellationRequested) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
let _result = yield ls.doValidation(vueFile.uri);
|
|
62
|
+
connection.sendDiagnostics({ uri: vueFile.uri, diagnostics: _result });
|
|
63
|
+
errors += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Error).length;
|
|
64
|
+
warnings += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Warning).length;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
progress.done();
|
|
69
|
+
connection.window.showInformationMessage(`Verification complete. Found ${errors} errors and ${warnings} warnings.`);
|
|
70
|
+
}));
|
|
71
|
+
for (const plugin of plugins) {
|
|
72
|
+
(_b = (_a = plugin.languageService) === null || _a === void 0 ? void 0 : _a.onInitialize) === null || _b === void 0 ? void 0 : _b.call(_a, connection, getLanguageService);
|
|
73
|
+
}
|
|
74
|
+
function getLanguageService(uri) {
|
|
75
|
+
var _a;
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
|
|
78
|
+
return project === null || project === void 0 ? void 0 : project.getLanguageService();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.register = register;
|
|
83
|
+
//# sourceMappingURL=customFeatures.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { createSnapshots } from '../utils/snapshots';
|
|
3
|
+
import { createDocumentServiceHost } from '../utils/documentServiceHost';
|
|
4
|
+
export declare function register(connection: vscode.Connection, documents: ReturnType<typeof createSnapshots>, documentServiceHost: ReturnType<typeof createDocumentServiceHost>): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
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
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.register = void 0;
|
|
12
|
+
const requests_1 = require("../requests");
|
|
13
|
+
function register(connection, documents, documentServiceHost) {
|
|
14
|
+
connection.onDocumentFormatting(params => {
|
|
15
|
+
return worker(params.textDocument.uri, document => {
|
|
16
|
+
return documentServiceHost.get(document.uri).format(document, params.options);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
connection.onDocumentRangeFormatting(params => {
|
|
20
|
+
return worker(params.textDocument.uri, document => {
|
|
21
|
+
return documentServiceHost.get(document.uri).format(document, params.options, params.range);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
connection.onDocumentOnTypeFormatting(params => {
|
|
25
|
+
return worker(params.textDocument.uri, document => {
|
|
26
|
+
return documentServiceHost.get(document.uri).format(document, params.options, undefined, params);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
connection.onSelectionRanges(params => {
|
|
30
|
+
return worker(params.textDocument.uri, document => {
|
|
31
|
+
return documentServiceHost.get(document.uri).getSelectionRanges(document, params.positions);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
connection.onFoldingRanges(params => {
|
|
35
|
+
return worker(params.textDocument.uri, document => {
|
|
36
|
+
return documentServiceHost.get(document.uri).getFoldingRanges(document);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
connection.languages.onLinkedEditingRange(params => {
|
|
40
|
+
return worker(params.textDocument.uri, document => {
|
|
41
|
+
return documentServiceHost.get(document.uri).findLinkedEditingRanges(document, params.position);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
connection.onDocumentSymbol(params => {
|
|
45
|
+
return worker(params.textDocument.uri, document => {
|
|
46
|
+
return documentServiceHost.get(document.uri).findDocumentSymbols(document);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
connection.onDocumentColor(params => {
|
|
50
|
+
return worker(params.textDocument.uri, document => {
|
|
51
|
+
return documentServiceHost.get(document.uri).findDocumentColors(document);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
connection.onColorPresentation(params => {
|
|
55
|
+
return worker(params.textDocument.uri, document => {
|
|
56
|
+
return documentServiceHost.get(document.uri).getColorPresentations(document, params.color, params.range);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
connection.onRequest(requests_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return worker(params.textDocument.uri, document => {
|
|
61
|
+
return documentServiceHost.get(document.uri).doAutoInsert(document, params.position, params.options);
|
|
62
|
+
});
|
|
63
|
+
}));
|
|
64
|
+
function worker(uri, cb) {
|
|
65
|
+
var _a;
|
|
66
|
+
const document = (_a = documents.data.uriGet(uri)) === null || _a === void 0 ? void 0 : _a.getDocument();
|
|
67
|
+
if (document) {
|
|
68
|
+
return cb(document);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.register = register;
|
|
73
|
+
//# sourceMappingURL=documentFeatures.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver';
|
|
2
|
+
import { ServerInitializationOptions } from '../types';
|
|
3
|
+
import type { Workspaces } from '../utils/workspaces';
|
|
4
|
+
export declare function register(connection: vscode.Connection, projects: Workspaces, features: NonNullable<ServerInitializationOptions['languageFeatures']>, initParams: vscode.InitializeParams): void;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
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
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.register = void 0;
|
|
12
|
+
const embedded = require("@volar/language-service");
|
|
13
|
+
const vscode = require("vscode-languageserver");
|
|
14
|
+
const requests_1 = require("../requests");
|
|
15
|
+
function register(connection, projects, features, initParams) {
|
|
16
|
+
let lastCompleteUri;
|
|
17
|
+
let lastCompleteLs;
|
|
18
|
+
let lastCodeLensLs;
|
|
19
|
+
let lastCodeActionLs;
|
|
20
|
+
let lastCallHierarchyLs;
|
|
21
|
+
connection.onCompletion((params) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
lastCompleteUri = params.textDocument.uri;
|
|
24
|
+
lastCompleteLs = vueLs;
|
|
25
|
+
const list = yield vueLs.doComplete(params.textDocument.uri, params.position, params.context);
|
|
26
|
+
if (list) {
|
|
27
|
+
for (const item of list.items) {
|
|
28
|
+
fixTextEdit(item);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return list;
|
|
32
|
+
}));
|
|
33
|
+
}));
|
|
34
|
+
connection.onCompletionResolve((item) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (lastCompleteUri && lastCompleteLs) {
|
|
36
|
+
const activeSel = typeof features.completion === 'object' && features.completion.getDocumentSelectionRequest
|
|
37
|
+
? yield connection.sendRequest(requests_1.GetEditorSelectionRequest.type)
|
|
38
|
+
: undefined;
|
|
39
|
+
const newPosition = (activeSel === null || activeSel === void 0 ? void 0 : activeSel.textDocument.uri.toLowerCase()) === lastCompleteUri.toLowerCase() ? activeSel.position : undefined;
|
|
40
|
+
item = yield lastCompleteLs.doCompletionResolve(item, newPosition);
|
|
41
|
+
fixTextEdit(item);
|
|
42
|
+
}
|
|
43
|
+
return item;
|
|
44
|
+
}));
|
|
45
|
+
connection.onHover((params) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
47
|
+
return vueLs.doHover(params.textDocument.uri, params.position);
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
connection.onSignatureHelp((params) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
52
|
+
return vueLs.getSignatureHelp(params.textDocument.uri, params.position, params.context);
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
55
|
+
connection.onPrepareRename((params) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
57
|
+
return vueLs.prepareRename(params.textDocument.uri, params.position);
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
connection.onRenameRequest((params) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
62
|
+
return vueLs.doRename(params.textDocument.uri, params.position, params.newName);
|
|
63
|
+
});
|
|
64
|
+
}));
|
|
65
|
+
connection.onCodeLens((params) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
lastCodeLensLs = vueLs;
|
|
68
|
+
return vueLs.doCodeLens(params.textDocument.uri);
|
|
69
|
+
}));
|
|
70
|
+
}));
|
|
71
|
+
connection.onCodeLensResolve((codeLens) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
var _a;
|
|
73
|
+
return (_a = yield (lastCodeLensLs === null || lastCodeLensLs === void 0 ? void 0 : lastCodeLensLs.doCodeLensResolve(codeLens))) !== null && _a !== void 0 ? _a : codeLens;
|
|
74
|
+
}));
|
|
75
|
+
connection.onExecuteCommand((params, token, workDoneProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (params.command === embedded.executePluginCommand) {
|
|
77
|
+
const args = params.arguments;
|
|
78
|
+
if (!args) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
return worker(args[0], vueLs => {
|
|
82
|
+
return vueLs.doExecuteCommand(params.command, args, {
|
|
83
|
+
token,
|
|
84
|
+
workDoneProgress,
|
|
85
|
+
applyEdit: (paramOrEdit) => connection.workspace.applyEdit(paramOrEdit),
|
|
86
|
+
showReferences: (params) => connection.sendNotification(requests_1.ShowReferencesNotification.type, params),
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
connection.onCodeAction((params) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
return worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
var _b, _c, _d;
|
|
94
|
+
lastCodeActionLs = vueLs;
|
|
95
|
+
let codeActions = (_b = yield vueLs.doCodeActions(params.textDocument.uri, params.range, params.context)) !== null && _b !== void 0 ? _b : [];
|
|
96
|
+
for (const codeAction of codeActions) {
|
|
97
|
+
if (codeAction.data && typeof codeAction.data === 'object') {
|
|
98
|
+
codeAction.data.uri = params.textDocument.uri;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
codeAction.data = { uri: params.textDocument.uri };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (!((_d = (_c = initParams.capabilities.textDocument) === null || _c === void 0 ? void 0 : _c.codeAction) === null || _d === void 0 ? void 0 : _d.disabledSupport)) {
|
|
105
|
+
codeActions = codeActions.filter(codeAction => !codeAction.disabled);
|
|
106
|
+
}
|
|
107
|
+
return codeActions;
|
|
108
|
+
}));
|
|
109
|
+
}));
|
|
110
|
+
connection.onCodeActionResolve((codeAction) => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
var _e;
|
|
112
|
+
return (_e = yield lastCodeActionLs.doCodeActionResolve(codeAction)) !== null && _e !== void 0 ? _e : codeAction;
|
|
113
|
+
}));
|
|
114
|
+
connection.onReferences((params) => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
116
|
+
return vueLs.findReferences(params.textDocument.uri, params.position);
|
|
117
|
+
});
|
|
118
|
+
}));
|
|
119
|
+
connection.onRequest(requests_1.FindFileReferenceRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
121
|
+
return vueLs.findFileReferences(params.textDocument.uri);
|
|
122
|
+
});
|
|
123
|
+
}));
|
|
124
|
+
connection.onImplementation((params) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
126
|
+
return vueLs.findImplementations(params.textDocument.uri, params.position);
|
|
127
|
+
});
|
|
128
|
+
}));
|
|
129
|
+
connection.onDefinition((params) => __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
131
|
+
return vueLs.findDefinition(params.textDocument.uri, params.position);
|
|
132
|
+
});
|
|
133
|
+
}));
|
|
134
|
+
connection.onTypeDefinition((params) => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
136
|
+
return vueLs.findTypeDefinition(params.textDocument.uri, params.position);
|
|
137
|
+
});
|
|
138
|
+
}));
|
|
139
|
+
connection.onDocumentHighlight((params) => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
141
|
+
return vueLs.findDocumentHighlights(params.textDocument.uri, params.position);
|
|
142
|
+
});
|
|
143
|
+
}));
|
|
144
|
+
connection.onDocumentLinks((params) => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
146
|
+
return vueLs.findDocumentLinks(params.textDocument.uri);
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
connection.onWorkspaceSymbol((params, token) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
let results = [];
|
|
151
|
+
for (const _workspace of projects.workspaces.values()) {
|
|
152
|
+
const workspace = yield _workspace;
|
|
153
|
+
let projects = [...workspace.projects.values()];
|
|
154
|
+
projects = projects.length ? projects : [workspace.getInferredProject()];
|
|
155
|
+
for (const project of projects) {
|
|
156
|
+
if (token.isCancellationRequested)
|
|
157
|
+
return;
|
|
158
|
+
const vueLs = (yield project).getLanguageService();
|
|
159
|
+
results = results.concat(yield vueLs.findWorkspaceSymbols(params.query));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return results;
|
|
163
|
+
}));
|
|
164
|
+
connection.languages.callHierarchy.onPrepare((params) => __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
var _f;
|
|
166
|
+
return (_f = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
lastCallHierarchyLs = vueLs;
|
|
168
|
+
return vueLs.callHierarchy.doPrepare(params.textDocument.uri, params.position);
|
|
169
|
+
}))) !== null && _f !== void 0 ? _f : [];
|
|
170
|
+
}));
|
|
171
|
+
connection.languages.callHierarchy.onIncomingCalls((params) => __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
var _g;
|
|
173
|
+
return (_g = yield (lastCallHierarchyLs === null || lastCallHierarchyLs === void 0 ? void 0 : lastCallHierarchyLs.callHierarchy.getIncomingCalls(params.item))) !== null && _g !== void 0 ? _g : [];
|
|
174
|
+
}));
|
|
175
|
+
connection.languages.callHierarchy.onOutgoingCalls((params) => __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
var _h;
|
|
177
|
+
return (_h = yield (lastCallHierarchyLs === null || lastCallHierarchyLs === void 0 ? void 0 : lastCallHierarchyLs.callHierarchy.getOutgoingCalls(params.item))) !== null && _h !== void 0 ? _h : [];
|
|
178
|
+
}));
|
|
179
|
+
connection.languages.semanticTokens.on((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
var _j;
|
|
181
|
+
return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
var _k;
|
|
183
|
+
const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
|
|
184
|
+
return buildTokens(result);
|
|
185
|
+
}))) !== null && _j !== void 0 ? _j : buildTokens([]);
|
|
186
|
+
}));
|
|
187
|
+
connection.languages.semanticTokens.onRange((params, token, _, resultProgress) => __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
var _l;
|
|
189
|
+
return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
+
var _m;
|
|
191
|
+
const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
|
|
192
|
+
return buildTokens(result);
|
|
193
|
+
}))) !== null && _l !== void 0 ? _l : buildTokens([]);
|
|
194
|
+
}));
|
|
195
|
+
connection.languages.diagnostics.on((params, cancellationToken, workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const result = yield worker(params.textDocument.uri, vueLs => {
|
|
197
|
+
return vueLs.doValidation(params.textDocument.uri, errors => {
|
|
198
|
+
// resultProgressReporter is undefined in vscode
|
|
199
|
+
resultProgressReporter === null || resultProgressReporter === void 0 ? void 0 : resultProgressReporter.report({
|
|
200
|
+
relatedDocuments: {
|
|
201
|
+
[params.textDocument.uri]: {
|
|
202
|
+
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
203
|
+
items: errors,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}, cancellationToken);
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
kind: vscode.DocumentDiagnosticReportKind.Full,
|
|
211
|
+
items: result !== null && result !== void 0 ? result : [],
|
|
212
|
+
};
|
|
213
|
+
}));
|
|
214
|
+
connection.languages.inlayHint.on((params) => __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
216
|
+
return vueLs.getInlayHints(params.textDocument.uri, params.range);
|
|
217
|
+
});
|
|
218
|
+
}));
|
|
219
|
+
// TODO: connection.languages.inlayHint.resolve
|
|
220
|
+
connection.workspace.onWillRenameFiles((params) => __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
var _o;
|
|
222
|
+
const config = yield connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
|
|
223
|
+
if (!config) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
if (params.files.length !== 1) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
const file = params.files[0];
|
|
230
|
+
return (_o = yield worker(file.oldUri, vueLs => {
|
|
231
|
+
var _a;
|
|
232
|
+
return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
233
|
+
})) !== null && _o !== void 0 ? _o : null;
|
|
234
|
+
}));
|
|
235
|
+
connection.onRequest(requests_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
236
|
+
return worker(params.textDocument.uri, vueLs => {
|
|
237
|
+
return vueLs.doAutoInsert(params.textDocument.uri, params.position, params.options);
|
|
238
|
+
});
|
|
239
|
+
}));
|
|
240
|
+
function worker(uri, cb) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
const vueLs = yield getLanguageService(uri);
|
|
243
|
+
if (vueLs) {
|
|
244
|
+
return cb(vueLs);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function buildTokens(tokens) {
|
|
249
|
+
const builder = new vscode.SemanticTokensBuilder();
|
|
250
|
+
const sortedTokens = tokens.sort((a, b) => a[0] - b[0] === 0 ? a[1] - b[1] : a[0] - b[0]);
|
|
251
|
+
for (const token of sortedTokens) {
|
|
252
|
+
builder.push(...token);
|
|
253
|
+
}
|
|
254
|
+
return builder.build();
|
|
255
|
+
}
|
|
256
|
+
function getLanguageService(uri) {
|
|
257
|
+
var _a;
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
const project = (_a = (yield projects.getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
|
|
260
|
+
return project === null || project === void 0 ? void 0 : project.getLanguageService();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function fixTextEdit(item) {
|
|
264
|
+
var _a, _b, _c, _d;
|
|
265
|
+
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;
|
|
266
|
+
if (!insertReplaceSupport) {
|
|
267
|
+
if (item.textEdit && vscode.InsertReplaceEdit.is(item.textEdit)) {
|
|
268
|
+
item.textEdit = vscode.TextEdit.replace(item.textEdit.insert, item.textEdit.newText);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
exports.register = register;
|
|
274
|
+
//# sourceMappingURL=languageFeatures.js.map
|
package/out/index.d.ts
ADDED
package/out/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
__exportStar(require("@volar/language-service"), exports);
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/out/node.d.ts
ADDED
package/out/node.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createLanguageServer = void 0;
|
|
17
|
+
const shared = require("@volar/shared");
|
|
18
|
+
const fs = require("fs");
|
|
19
|
+
const request_light_1 = require("request-light");
|
|
20
|
+
const path = require("upath");
|
|
21
|
+
const html = require("vscode-html-languageservice");
|
|
22
|
+
const vscode = require("vscode-languageserver/node");
|
|
23
|
+
const server_1 = require("./server");
|
|
24
|
+
const file_1 = require("./schemaRequestHandlers/file");
|
|
25
|
+
const http_1 = require("./schemaRequestHandlers/http");
|
|
26
|
+
const nodeFileSystemHost_1 = require("./utils/nodeFileSystemHost");
|
|
27
|
+
function createLanguageServer(plugins) {
|
|
28
|
+
const connection = vscode.createConnection(vscode.ProposedFeatures.all);
|
|
29
|
+
(0, server_1.createCommonLanguageServer)(connection, {
|
|
30
|
+
loadTypescript(options) {
|
|
31
|
+
return require(path.toUnix(options.typescript.serverPath));
|
|
32
|
+
},
|
|
33
|
+
loadTypescriptLocalized(options) {
|
|
34
|
+
if (options.typescript.localizedPath) {
|
|
35
|
+
try {
|
|
36
|
+
return require(path.toUnix(options.typescript.localizedPath));
|
|
37
|
+
}
|
|
38
|
+
catch (_a) { }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
schemaRequestHandlers: {
|
|
42
|
+
file: file_1.default,
|
|
43
|
+
http: http_1.default,
|
|
44
|
+
https: http_1.default,
|
|
45
|
+
},
|
|
46
|
+
onDidChangeConfiguration(settings) {
|
|
47
|
+
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
48
|
+
},
|
|
49
|
+
createFileSystemHost: nodeFileSystemHost_1.createNodeFileSystemHost,
|
|
50
|
+
fileSystemProvide: {
|
|
51
|
+
stat: (uri) => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
fs.stat(shared.getPathOfUri(uri), (err, stats) => {
|
|
54
|
+
if (stats) {
|
|
55
|
+
resolve({
|
|
56
|
+
type: stats.isFile() ? html.FileType.File
|
|
57
|
+
: stats.isDirectory() ? html.FileType.Directory
|
|
58
|
+
: stats.isSymbolicLink() ? html.FileType.SymbolicLink
|
|
59
|
+
: html.FileType.Unknown,
|
|
60
|
+
ctime: stats.ctimeMs,
|
|
61
|
+
mtime: stats.mtimeMs,
|
|
62
|
+
size: stats.size,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
reject(err);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
readDirectory: (uri) => {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
fs.readdir(shared.getPathOfUri(uri), (err, files) => {
|
|
74
|
+
if (files) {
|
|
75
|
+
resolve(files.map(file => [file, html.FileType.File]));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
reject(err);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}, plugins);
|
|
85
|
+
}
|
|
86
|
+
exports.createLanguageServer = createLanguageServer;
|
|
87
|
+
__exportStar(require("./index"), exports);
|
|
88
|
+
//# sourceMappingURL=node.js.map
|