@volar/language-server 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/browser/index.d.ts +3 -1
- package/out/browser/index.js +8 -4
- package/out/common/features/customFeatures.js +16 -16
- package/out/common/features/languageFeatures.js +45 -0
- package/out/common/project.d.ts +32 -12
- package/out/common/project.js +96 -77
- package/out/common/server.d.ts +2 -2
- package/out/common/server.js +25 -49
- package/out/common/utils/inferredCompilerOptions.d.ts +1 -1
- package/out/common/utils/inferredCompilerOptions.js +5 -5
- package/out/common/utils/registerFeatures.d.ts +1 -2
- package/out/common/utils/registerFeatures.js +68 -51
- package/out/common/utils/serverConfig.d.ts +4 -1
- package/out/common/utils/serverConfig.js +5 -7
- package/out/common/workspace.d.ts +231 -51
- package/out/common/workspace.js +31 -34
- package/out/common/workspaces.d.ts +285 -64
- package/out/common/workspaces.js +66 -62
- package/out/node/index.d.ts +3 -1
- package/out/node/index.js +8 -5
- package/out/types.d.ts +7 -13
- package/package.json +5 -5
- package/out/common/features/documentFeatures.d.ts +0 -4
- package/out/common/features/documentFeatures.js +0 -73
- package/out/common/syntaxServicesHost.d.ts +0 -29
- package/out/common/syntaxServicesHost.js +0 -51
package/out/common/workspaces.js
CHANGED
|
@@ -13,39 +13,37 @@ const shared = require("@volar/shared");
|
|
|
13
13
|
const vscode = require("vscode-languageserver");
|
|
14
14
|
const types_1 = require("../types");
|
|
15
15
|
const workspace_1 = require("./workspace");
|
|
16
|
-
function createWorkspaces(
|
|
17
|
-
var _a;
|
|
18
|
-
const
|
|
19
|
-
const { connection, runtimeEnv } = params.server;
|
|
16
|
+
function createWorkspaces(context) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const workspaces = new Map();
|
|
20
19
|
let semanticTokensReq = 0;
|
|
21
20
|
let documentUpdatedReq = 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
updateDiagnostics(params.textDocument.uri);
|
|
21
|
+
context.documents.onDidChangeContent(({ textDocument }) => {
|
|
22
|
+
updateDiagnostics(textDocument.uri);
|
|
25
23
|
});
|
|
26
|
-
documents.onDidClose(
|
|
27
|
-
connection.sendDiagnostics({ uri:
|
|
24
|
+
context.documents.onDidClose(({ textDocument }) => {
|
|
25
|
+
context.server.connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
|
|
28
26
|
});
|
|
29
|
-
fileSystemHost.onDidChangeWatchedFiles(
|
|
30
|
-
const tsConfigChanges =
|
|
27
|
+
(_a = context.fileSystemHost) === null || _a === void 0 ? void 0 : _a.onDidChangeWatchedFiles(({ changes }) => {
|
|
28
|
+
const tsConfigChanges = changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
|
|
31
29
|
if (tsConfigChanges.length) {
|
|
32
30
|
reloadDiagnostics();
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
35
|
-
|
|
33
|
+
updateDiagnosticsAndSemanticTokens();
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
|
-
(
|
|
39
|
-
|
|
36
|
+
(_c = (_b = context.server.runtimeEnv).onDidChangeConfiguration) === null || _c === void 0 ? void 0 : _c.call(_b, () => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
updateDiagnosticsAndSemanticTokens();
|
|
40
38
|
}));
|
|
41
39
|
return {
|
|
42
40
|
workspaces,
|
|
43
|
-
getProject,
|
|
41
|
+
getProject: getProjectAndTsConfig,
|
|
44
42
|
reloadProject,
|
|
45
43
|
add: (rootUri) => {
|
|
46
44
|
if (!workspaces.has(rootUri.toString())) {
|
|
47
45
|
workspaces.set(rootUri.toString(), (0, workspace_1.createWorkspace)({
|
|
48
|
-
workspaces:
|
|
46
|
+
workspaces: context,
|
|
49
47
|
rootUri,
|
|
50
48
|
}));
|
|
51
49
|
}
|
|
@@ -60,8 +58,9 @@ function createWorkspaces(params) {
|
|
|
60
58
|
},
|
|
61
59
|
};
|
|
62
60
|
function reloadProject() {
|
|
61
|
+
var _a;
|
|
63
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
fileSystemHost.reload();
|
|
63
|
+
(_a = context.fileSystemHost) === null || _a === void 0 ? void 0 : _a.reload();
|
|
65
64
|
for (const [_, workspace] of workspaces) {
|
|
66
65
|
(yield workspace).reload();
|
|
67
66
|
}
|
|
@@ -69,89 +68,94 @@ function createWorkspaces(params) {
|
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
function reloadDiagnostics() {
|
|
72
|
-
for (const doc of documents.data.values()) {
|
|
73
|
-
connection.sendDiagnostics({ uri: doc.uri, diagnostics: [] });
|
|
71
|
+
for (const doc of context.documents.data.values()) {
|
|
72
|
+
context.server.connection.sendDiagnostics({ uri: doc.uri, diagnostics: [] });
|
|
74
73
|
}
|
|
75
|
-
|
|
74
|
+
updateDiagnosticsAndSemanticTokens();
|
|
76
75
|
}
|
|
77
|
-
function
|
|
78
|
-
var _a, _b;
|
|
76
|
+
function updateDiagnosticsAndSemanticTokens() {
|
|
77
|
+
var _a, _b, _c, _d;
|
|
79
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
79
|
const req = ++semanticTokensReq;
|
|
81
80
|
yield updateDiagnostics();
|
|
81
|
+
const delay = (_b = yield ((_a = context.configurationHost) === null || _a === void 0 ? void 0 : _a.getConfiguration('volar.diagnostics.delay'))) !== null && _b !== void 0 ? _b : 200;
|
|
82
|
+
yield shared.sleep(delay);
|
|
82
83
|
if (req === semanticTokensReq) {
|
|
83
|
-
if ((
|
|
84
|
-
connection.languages.semanticTokens.refresh();
|
|
84
|
+
if ((_c = context.initParams.capabilities.textDocument) === null || _c === void 0 ? void 0 : _c.semanticTokens) {
|
|
85
|
+
context.server.connection.languages.semanticTokens.refresh();
|
|
85
86
|
}
|
|
86
|
-
if ((
|
|
87
|
-
connection.languages.inlayHint.refresh();
|
|
87
|
+
if ((_d = context.initParams.capabilities.textDocument) === null || _d === void 0 ? void 0 : _d.inlayHint) {
|
|
88
|
+
context.server.connection.languages.inlayHint.refresh();
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
function updateDiagnostics(docUri) {
|
|
93
|
-
var _a, _b;
|
|
94
|
+
var _a, _b, _c;
|
|
94
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
if (((_a = initOptions.diagnosticModel) !== null && _a !== void 0 ? _a : types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
|
|
96
|
+
if (((_a = context.initOptions.diagnosticModel) !== null && _a !== void 0 ? _a : types_1.DiagnosticModel.Push) !== types_1.DiagnosticModel.Push)
|
|
96
97
|
return;
|
|
97
98
|
const req = ++documentUpdatedReq;
|
|
98
|
-
const delay = (
|
|
99
|
-
const cancel = cancelTokenHost.createCancellationToken({
|
|
99
|
+
const delay = (_c = yield ((_b = context.configurationHost) === null || _b === void 0 ? void 0 : _b.getConfiguration('volar.diagnostics.delay'))) !== null && _c !== void 0 ? _c : 200;
|
|
100
|
+
const cancel = context.cancelTokenHost.createCancellationToken({
|
|
100
101
|
get isCancellationRequested() {
|
|
101
102
|
return req !== documentUpdatedReq;
|
|
102
103
|
},
|
|
103
104
|
onCancellationRequested: vscode.Event.None,
|
|
104
105
|
});
|
|
105
|
-
const changeDoc = docUri ? documents.data.uriGet(docUri) : undefined;
|
|
106
|
-
const otherDocs = [...documents.data.values()].filter(doc => doc !== changeDoc);
|
|
106
|
+
const changeDoc = docUri ? context.documents.data.uriGet(docUri) : undefined;
|
|
107
|
+
const otherDocs = [...context.documents.data.values()].filter(doc => doc !== changeDoc);
|
|
107
108
|
if (changeDoc) {
|
|
108
109
|
yield shared.sleep(delay);
|
|
110
|
+
if (cancel.isCancellationRequested) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
109
113
|
yield sendDocumentDiagnostics(changeDoc.uri, changeDoc.version, cancel);
|
|
110
114
|
}
|
|
111
115
|
for (const doc of otherDocs) {
|
|
112
116
|
yield shared.sleep(delay);
|
|
113
|
-
yield sendDocumentDiagnostics(doc.uri, doc.version, cancel);
|
|
114
117
|
if (cancel.isCancellationRequested) {
|
|
115
118
|
break;
|
|
116
119
|
}
|
|
120
|
+
yield sendDocumentDiagnostics(doc.uri, doc.version, cancel);
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function sendDocumentDiagnostics(uri, version, cancel) {
|
|
125
|
+
var _a;
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const project = (_a = (yield getProjectAndTsConfig(uri))) === null || _a === void 0 ? void 0 : _a.project;
|
|
128
|
+
if (!project)
|
|
129
|
+
return;
|
|
130
|
+
const languageService = project.getLanguageService();
|
|
131
|
+
const errors = yield languageService.doValidation(uri, cancel, result => {
|
|
132
|
+
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: result.map(addVersion), version });
|
|
133
|
+
});
|
|
134
|
+
context.server.connection.sendDiagnostics({ uri: uri, diagnostics: errors.map(addVersion), version });
|
|
135
|
+
function addVersion(error) {
|
|
136
|
+
if (error.data === undefined) {
|
|
137
|
+
error.data = { version };
|
|
138
|
+
}
|
|
139
|
+
else if (typeof error.data === 'object') {
|
|
140
|
+
error.data.version = version;
|
|
141
|
+
}
|
|
142
|
+
return error;
|
|
141
143
|
}
|
|
142
144
|
});
|
|
143
145
|
}
|
|
144
|
-
function
|
|
146
|
+
function getProjectAndTsConfig(uri) {
|
|
145
147
|
var _a;
|
|
146
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
149
|
const rootUris = [...workspaces.keys()]
|
|
148
150
|
.filter(rootUri => shared.isFileInDir(shared.getPathOfUri(uri), shared.getPathOfUri(rootUri)))
|
|
149
151
|
.sort((a, b) => (0, workspace_1.sortTsConfigs)(shared.getPathOfUri(uri), shared.getPathOfUri(a), shared.getPathOfUri(b)));
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
if (context.initOptions.serverMode !== types_1.ServerMode.Syntactic) {
|
|
153
|
+
for (const rootUri of rootUris) {
|
|
154
|
+
const workspace = yield workspaces.get(rootUri);
|
|
155
|
+
const projectAndTsConfig = yield (workspace === null || workspace === void 0 ? void 0 : workspace.getProjectAndTsConfig(uri));
|
|
156
|
+
if (projectAndTsConfig) {
|
|
157
|
+
return projectAndTsConfig;
|
|
158
|
+
}
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
161
|
if (rootUris.length) {
|
package/out/node/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver/node';
|
|
1
2
|
import { LanguageServerPlugin } from '../types';
|
|
2
3
|
export * from '../index';
|
|
3
|
-
export declare function
|
|
4
|
+
export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._>;
|
|
5
|
+
export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
|
package/out/node/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.startLanguageServer = exports.createConnection = void 0;
|
|
26
26
|
const shared = require("@volar/shared");
|
|
27
27
|
const fs = require("fs");
|
|
28
28
|
const request_light_1 = require("request-light");
|
|
@@ -33,9 +33,12 @@ const file_1 = require("../common/schemaRequestHandlers/file");
|
|
|
33
33
|
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
34
34
|
const fileSystem_1 = require("./fileSystem");
|
|
35
35
|
__exportStar(require("../index"), exports);
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
function createConnection() {
|
|
37
|
+
return vscode.createConnection(vscode.ProposedFeatures.all);
|
|
38
|
+
}
|
|
39
|
+
exports.createConnection = createConnection;
|
|
40
|
+
function startLanguageServer(connection, ...plugins) {
|
|
41
|
+
(0, server_1.startCommonLanguageServer)({
|
|
39
42
|
plugins,
|
|
40
43
|
connection,
|
|
41
44
|
runtimeEnv: {
|
|
@@ -103,5 +106,5 @@ function createLanguageServer(plugins) {
|
|
|
103
106
|
},
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
|
-
exports.
|
|
109
|
+
exports.startLanguageServer = startLanguageServer;
|
|
107
110
|
//# sourceMappingURL=index.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
6
|
import * as vscode from 'vscode-languageserver';
|
|
7
7
|
import { URI } from 'vscode-uri';
|
|
8
|
+
import { LanguageServiceRuntimeContext } from '@volar/language-service';
|
|
8
9
|
export type FileSystemHost = {
|
|
9
10
|
ready(connection: vscode.Connection): void;
|
|
10
11
|
reload(): void;
|
|
@@ -23,18 +24,11 @@ export interface RuntimeEnvironment {
|
|
|
23
24
|
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities) => FileSystemHost;
|
|
24
25
|
}
|
|
25
26
|
export type LanguageServerPlugin<A extends LanguageServerInitializationOptions = LanguageServerInitializationOptions, B extends embedded.LanguageServiceHost = embedded.LanguageServiceHost, C = embeddedLS.LanguageService> = (initOptions: A) => {
|
|
26
|
-
extraFileExtensions
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
onInitialize?(connection: vscode.Connection, getLanguageService: (uri: string) => Promise<C>): void;
|
|
32
|
-
};
|
|
33
|
-
syntacticService?: {
|
|
34
|
-
getLanguageModules?(ts: typeof import('typescript/lib/tsserverlibrary'), env: embeddedLS.LanguageServicePluginContext['env']): embedded.LanguageModule[];
|
|
35
|
-
getServicePlugins?(context: embeddedLS.DocumentServiceRuntimeContext): embeddedLS.LanguageServicePlugin[];
|
|
36
|
-
onInitialize?(connection: vscode.Connection): void;
|
|
37
|
-
};
|
|
27
|
+
extraFileExtensions?: ts.FileExtensionInfo[];
|
|
28
|
+
resolveLanguageServiceHost?(ts: typeof import('typescript/lib/tsserverlibrary'), sys: FileSystem, tsConfig: string | ts.CompilerOptions, host: embedded.LanguageServiceHost): B;
|
|
29
|
+
getLanguageModules?(host: B): embedded.LanguageModule[];
|
|
30
|
+
getLanguageServicePlugins?(host: B, context: LanguageServiceRuntimeContext): embeddedLS.LanguageServicePlugin[];
|
|
31
|
+
onInitialize?(connection: vscode.Connection, getLanguageService: (uri: string) => Promise<C>): void;
|
|
38
32
|
};
|
|
39
33
|
export declare enum ServerMode {
|
|
40
34
|
Semantic = 0,
|
|
@@ -46,7 +40,7 @@ export declare enum DiagnosticModel {
|
|
|
46
40
|
Pull = 2
|
|
47
41
|
}
|
|
48
42
|
export interface LanguageServerInitializationOptions {
|
|
49
|
-
typescript
|
|
43
|
+
typescript?: {
|
|
50
44
|
tsdk: string;
|
|
51
45
|
};
|
|
52
46
|
serverMode?: ServerMode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,9 +17,9 @@
|
|
|
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.
|
|
20
|
+
"@volar/language-core": "1.0.20",
|
|
21
|
+
"@volar/language-service": "1.0.20",
|
|
22
|
+
"@volar/shared": "1.0.20",
|
|
23
23
|
"request-light": "^0.6.0",
|
|
24
24
|
"typesafe-path": "^0.2.2",
|
|
25
25
|
"vscode-html-languageservice": "^5.0.3",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
29
29
|
"vscode-uri": "^3.0.7"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "e00f068e812677791c93efe9cf20995764350ec6"
|
|
32
32
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,73 +0,0 @@
|
|
|
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 protocol_1 = require("../../protocol");
|
|
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(protocol_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
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as embedded from '@volar/language-service';
|
|
2
|
-
import { URI } from 'vscode-uri';
|
|
3
|
-
import { LanguageServerInitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
4
|
-
import type * as _ from 'vscode-languageserver-textdocument';
|
|
5
|
-
export declare function createSyntaxServicesHost(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], ts: typeof import('typescript/lib/tsserverlibrary'), configHost: embedded.ConfigurationHost | undefined, initOptions: LanguageServerInitializationOptions): {
|
|
6
|
-
add: (rootUri: URI) => void;
|
|
7
|
-
remove: (rootUri: URI) => void;
|
|
8
|
-
get: (documentUri: string) => {
|
|
9
|
-
format: (document: _.TextDocument, options: embedded.FormattingOptions, range?: embedded.Range | undefined, onTypeParams?: {
|
|
10
|
-
ch: string;
|
|
11
|
-
position: embedded.Position;
|
|
12
|
-
} | undefined) => Promise<embedded.TextEdit[] | undefined>;
|
|
13
|
-
getFoldingRanges: (document: _.TextDocument) => Promise<embedded.FoldingRange[] | undefined>;
|
|
14
|
-
getSelectionRanges: (document: _.TextDocument, positions: embedded.Position[]) => Promise<embedded.SelectionRange[] | undefined>;
|
|
15
|
-
findLinkedEditingRanges: (document: _.TextDocument, position: embedded.Position) => Promise<embedded.LinkedEditingRanges | undefined>;
|
|
16
|
-
findDocumentSymbols: (document: _.TextDocument) => Promise<embedded.SymbolInformation[] | undefined>;
|
|
17
|
-
findDocumentColors: (document: _.TextDocument) => Promise<embedded.ColorInformation[] | undefined>;
|
|
18
|
-
getColorPresentations: (document: _.TextDocument, color: embedded.Color, range: embedded.Range) => Promise<embedded.ColorPresentation[] | undefined>;
|
|
19
|
-
doAutoInsert: (document: _.TextDocument, position: embedded.Position, options: {
|
|
20
|
-
lastChange: {
|
|
21
|
-
range: embedded.Range;
|
|
22
|
-
rangeOffset: number;
|
|
23
|
-
rangeLength: number;
|
|
24
|
-
text: string;
|
|
25
|
-
};
|
|
26
|
-
}) => Promise<NonNullable<string | embedded.TextEdit | null | undefined> | undefined>;
|
|
27
|
-
context: embedded.DocumentServiceRuntimeContext;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.createSyntaxServicesHost = void 0;
|
|
3
|
-
const embedded = require("@volar/language-service");
|
|
4
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
-
const serverConfig_1 = require("./utils/serverConfig");
|
|
6
|
-
function createSyntaxServicesHost(runtimeEnv, plugins, ts, configHost, initOptions) {
|
|
7
|
-
const services = new Map();
|
|
8
|
-
const untitledService = create(vscode_uri_1.URI.from({ scheme: 'untitled' }));
|
|
9
|
-
return {
|
|
10
|
-
add,
|
|
11
|
-
remove,
|
|
12
|
-
get,
|
|
13
|
-
};
|
|
14
|
-
function add(rootUri) {
|
|
15
|
-
services.set(rootUri.toString(), create(rootUri));
|
|
16
|
-
}
|
|
17
|
-
function remove(rootUri) {
|
|
18
|
-
services.delete(rootUri.toString());
|
|
19
|
-
}
|
|
20
|
-
function get(documentUri) {
|
|
21
|
-
for (const [rootUri, service] of services) {
|
|
22
|
-
if (documentUri.startsWith(rootUri)) {
|
|
23
|
-
return service;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return untitledService;
|
|
27
|
-
}
|
|
28
|
-
function create(rootUri) {
|
|
29
|
-
const env = {
|
|
30
|
-
rootUri,
|
|
31
|
-
configurationHost: configHost,
|
|
32
|
-
fileSystemProvider: runtimeEnv.fileSystemProvide,
|
|
33
|
-
};
|
|
34
|
-
const serviceContext = embedded.createDocumentServiceContext({
|
|
35
|
-
ts,
|
|
36
|
-
env,
|
|
37
|
-
getLanguageModules() {
|
|
38
|
-
return plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.syntacticService) === null || _a === void 0 ? void 0 : _a.getLanguageModules) === null || _b === void 0 ? void 0 : _b.call(_a, ts, env)) !== null && _c !== void 0 ? _c : []; }).flat();
|
|
39
|
-
},
|
|
40
|
-
getPlugins() {
|
|
41
|
-
return [
|
|
42
|
-
...(0, serverConfig_1.loadCustomPlugins)(rootUri.fsPath, initOptions.configFilePath),
|
|
43
|
-
...plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.syntacticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, serviceContext)) !== null && _c !== void 0 ? _c : []; }).flat(),
|
|
44
|
-
];
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
return embedded.createDocumentService(serviceContext);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.createSyntaxServicesHost = createSyntaxServicesHost;
|
|
51
|
-
//# sourceMappingURL=syntaxServicesHost.js.map
|