@volar/language-server 1.0.19 → 1.0.21
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 +25 -5
- package/out/common/project.js +61 -39
- package/out/common/server.d.ts +1 -1
- package/out/common/server.js +13 -36
- 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/workspace.d.ts +218 -38
- package/out/common/workspace.js +18 -14
- package/out/common/workspaces.d.ts +269 -49
- package/out/common/workspaces.js +12 -9
- 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 -53
package/out/common/workspaces.js
CHANGED
|
@@ -14,7 +14,7 @@ const vscode = require("vscode-languageserver");
|
|
|
14
14
|
const types_1 = require("../types");
|
|
15
15
|
const workspace_1 = require("./workspace");
|
|
16
16
|
function createWorkspaces(context) {
|
|
17
|
-
var _a, _b;
|
|
17
|
+
var _a, _b, _c;
|
|
18
18
|
const workspaces = new Map();
|
|
19
19
|
let semanticTokensReq = 0;
|
|
20
20
|
let documentUpdatedReq = 0;
|
|
@@ -24,7 +24,7 @@ function createWorkspaces(context) {
|
|
|
24
24
|
context.documents.onDidClose(({ textDocument }) => {
|
|
25
25
|
context.server.connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
|
|
26
26
|
});
|
|
27
|
-
context.fileSystemHost.onDidChangeWatchedFiles(({ changes }) => {
|
|
27
|
+
(_a = context.fileSystemHost) === null || _a === void 0 ? void 0 : _a.onDidChangeWatchedFiles(({ changes }) => {
|
|
28
28
|
const tsConfigChanges = changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
|
|
29
29
|
if (tsConfigChanges.length) {
|
|
30
30
|
reloadDiagnostics();
|
|
@@ -33,7 +33,7 @@ function createWorkspaces(context) {
|
|
|
33
33
|
updateDiagnosticsAndSemanticTokens();
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
(
|
|
36
|
+
(_c = (_b = context.server.runtimeEnv).onDidChangeConfiguration) === null || _c === void 0 ? void 0 : _c.call(_b, () => __awaiter(this, void 0, void 0, function* () {
|
|
37
37
|
updateDiagnosticsAndSemanticTokens();
|
|
38
38
|
}));
|
|
39
39
|
return {
|
|
@@ -58,8 +58,9 @@ function createWorkspaces(context) {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
function reloadProject() {
|
|
61
|
+
var _a;
|
|
61
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
context.fileSystemHost.reload();
|
|
63
|
+
(_a = context.fileSystemHost) === null || _a === void 0 ? void 0 : _a.reload();
|
|
63
64
|
for (const [_, workspace] of workspaces) {
|
|
64
65
|
(yield workspace).reload();
|
|
65
66
|
}
|
|
@@ -148,11 +149,13 @@ function createWorkspaces(context) {
|
|
|
148
149
|
const rootUris = [...workspaces.keys()]
|
|
149
150
|
.filter(rootUri => shared.isFileInDir(shared.getPathOfUri(uri), shared.getPathOfUri(rootUri)))
|
|
150
151
|
.sort((a, b) => (0, workspace_1.sortTsConfigs)(shared.getPathOfUri(uri), shared.getPathOfUri(a), shared.getPathOfUri(b)));
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
+
}
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
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.21",
|
|
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.21",
|
|
21
|
+
"@volar/language-service": "1.0.21",
|
|
22
|
+
"@volar/shared": "1.0.21",
|
|
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": "72332760759e06eed18e62026185cbad70250367"
|
|
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,53 +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 serverConfig = (0, serverConfig_1.loadServerConfig)(rootUri.fsPath, initOptions.configFilePath);
|
|
35
|
-
const serviceContext = embedded.createDocumentServiceContext({
|
|
36
|
-
ts,
|
|
37
|
-
env,
|
|
38
|
-
getLanguageModules() {
|
|
39
|
-
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();
|
|
40
|
-
},
|
|
41
|
-
getPlugins() {
|
|
42
|
-
var _a;
|
|
43
|
-
return [
|
|
44
|
-
...(_a = serverConfig === null || serverConfig === void 0 ? void 0 : serverConfig.plugins) !== null && _a !== void 0 ? _a : [],
|
|
45
|
-
...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(),
|
|
46
|
-
];
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
return embedded.createDocumentService(serviceContext);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.createSyntaxServicesHost = createSyntaxServicesHost;
|
|
53
|
-
//# sourceMappingURL=syntaxServicesHost.js.map
|