@volar/language-server 1.0.12 → 1.0.14
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.js +19 -2
- package/out/features/customFeatures.js +3 -5
- package/out/node.js +16 -5
- package/out/protocol.d.ts +10 -13
- package/out/protocol.js +13 -16
- package/out/registerFeatures.js +10 -7
- package/out/server.js +2 -2
- package/out/types.d.ts +4 -2
- package/out/utils/config.d.ts +1 -1
- package/out/utils/config.js +3 -2
- package/out/utils/documentServiceHost.d.ts +14 -14
- package/out/utils/documentServiceHost.js +2 -2
- package/out/utils/nodeFileSystemHost.js +1 -1
- package/out/utils/project.d.ts +61 -63
- package/out/utils/project.js +15 -7
- package/out/utils/snapshots.d.ts +4 -5
- package/out/utils/uriMap.d.ts +4 -5
- package/out/utils/uriMap.js +17 -22
- package/out/utils/webFileSystemHost.js +86 -39
- package/out/utils/workspaceProjects.d.ts +10 -11
- package/out/utils/workspaceProjects.js +23 -24
- package/out/utils/workspaces.d.ts +20 -21
- package/out/utils/workspaces.js +2 -4
- package/package.json +5 -5
package/out/browser.js
CHANGED
|
@@ -12,6 +12,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
12
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
13
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
14
|
};
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
15
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
25
|
exports.createLanguageServer = void 0;
|
|
17
26
|
const request_light_1 = require("request-light");
|
|
@@ -20,6 +29,7 @@ const vscode = require("vscode-languageserver/browser");
|
|
|
20
29
|
const server_1 = require("./server");
|
|
21
30
|
const http_1 = require("./schemaRequestHandlers/http");
|
|
22
31
|
const webFileSystemHost_1 = require("./utils/webFileSystemHost");
|
|
32
|
+
const shared = require("@volar/shared");
|
|
23
33
|
function createLanguageServer(plugins) {
|
|
24
34
|
const messageReader = new vscode.BrowserMessageReader(self);
|
|
25
35
|
const messageWriter = new vscode.BrowserMessageWriter(self);
|
|
@@ -28,8 +38,15 @@ function createLanguageServer(plugins) {
|
|
|
28
38
|
loadTypescript() {
|
|
29
39
|
return ts; // not support load by user config in web
|
|
30
40
|
},
|
|
31
|
-
loadTypescriptLocalized() {
|
|
32
|
-
|
|
41
|
+
loadTypescriptLocalized(tsdk, locale) {
|
|
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
|
+
});
|
|
33
50
|
},
|
|
34
51
|
schemaRequestHandlers: {
|
|
35
52
|
http: http_1.default,
|
|
@@ -68,10 +68,8 @@ function register(connection, projects) {
|
|
|
68
68
|
}));
|
|
69
69
|
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
const project = (yield projects.getProject(params.uri));
|
|
71
|
-
if (project) {
|
|
72
|
-
return {
|
|
73
|
-
fileName: project.tsconfig,
|
|
74
|
-
};
|
|
71
|
+
if (project === null || project === void 0 ? void 0 : project.tsconfig) {
|
|
72
|
+
return { uri: shared.getUriByPath(project.tsconfig) };
|
|
75
73
|
}
|
|
76
74
|
}));
|
|
77
75
|
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -81,7 +79,7 @@ function register(connection, projects) {
|
|
|
81
79
|
if (project) {
|
|
82
80
|
const sourceFile = (_p = (_o = project.project) === null || _o === void 0 ? void 0 : _o.getLanguageService().context.core.mapper.get(shared.getPathOfUri(document.uri))) === null || _p === void 0 ? void 0 : _p[0];
|
|
83
81
|
if (sourceFile) {
|
|
84
|
-
(0, language_core_1.forEachEmbeddeds)(sourceFile
|
|
82
|
+
(0, language_core_1.forEachEmbeddeds)(sourceFile, e => {
|
|
85
83
|
if (e.text && e.kind === 1) {
|
|
86
84
|
fileNames.push(e.fileName);
|
|
87
85
|
}
|
package/out/node.js
CHANGED
|
@@ -12,6 +12,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
12
12
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
13
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
14
|
};
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
15
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
25
|
exports.createLanguageServer = void 0;
|
|
17
26
|
const shared = require("@volar/shared");
|
|
@@ -36,11 +45,13 @@ function createLanguageServer(plugins) {
|
|
|
36
45
|
}
|
|
37
46
|
},
|
|
38
47
|
loadTypescriptLocalized(tsdk, locale) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
51
|
+
return require(path);
|
|
52
|
+
}
|
|
53
|
+
catch (_a) { }
|
|
54
|
+
});
|
|
44
55
|
},
|
|
45
56
|
schemaRequestHandlers: {
|
|
46
57
|
file: file_1.default,
|
package/out/protocol.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ export declare namespace ShowReferencesNotification {
|
|
|
9
9
|
};
|
|
10
10
|
const type: vscode.NotificationType<ResponseType>;
|
|
11
11
|
}
|
|
12
|
+
export declare namespace FsStatRequest {
|
|
13
|
+
const type: vscode.RequestType<string, html.FileStat | null | undefined, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare namespace FsReadFileRequest {
|
|
16
|
+
const type: vscode.RequestType<string, string | null | undefined, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace FsReadDirectoryRequest {
|
|
19
|
+
const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
|
|
20
|
+
}
|
|
12
21
|
/**
|
|
13
22
|
* Client request server
|
|
14
23
|
*/
|
|
@@ -23,7 +32,7 @@ export declare namespace FindFileReferenceRequest {
|
|
|
23
32
|
export declare namespace GetMatchTsConfigRequest {
|
|
24
33
|
type ParamsType = vscode.TextDocumentIdentifier;
|
|
25
34
|
type ResponseType = {
|
|
26
|
-
|
|
35
|
+
uri: string;
|
|
27
36
|
} | null | undefined;
|
|
28
37
|
type ErrorType = never;
|
|
29
38
|
const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
|
|
@@ -77,15 +86,3 @@ export declare namespace GetVirtualFileRequest {
|
|
|
77
86
|
export declare namespace ReportStats {
|
|
78
87
|
const type: vscode.NotificationType0;
|
|
79
88
|
}
|
|
80
|
-
/**
|
|
81
|
-
* FS request for browser
|
|
82
|
-
*/
|
|
83
|
-
export declare namespace FsStatRequest {
|
|
84
|
-
const type: vscode.RequestType<string, html.FileStat | undefined, unknown>;
|
|
85
|
-
}
|
|
86
|
-
export declare namespace FsReadFileRequest {
|
|
87
|
-
const type: vscode.RequestType<string, string | undefined, unknown>;
|
|
88
|
-
}
|
|
89
|
-
export declare namespace FsReadDirectoryRequest {
|
|
90
|
-
const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
|
|
91
|
-
}
|
package/out/protocol.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ShowReferencesNotification = void 0;
|
|
3
3
|
const vscode = require("vscode-languageserver-protocol");
|
|
4
4
|
/**
|
|
5
5
|
* Server request client
|
|
@@ -8,6 +8,18 @@ var ShowReferencesNotification;
|
|
|
8
8
|
(function (ShowReferencesNotification) {
|
|
9
9
|
ShowReferencesNotification.type = new vscode.NotificationType('vue.findReferences');
|
|
10
10
|
})(ShowReferencesNotification = exports.ShowReferencesNotification || (exports.ShowReferencesNotification = {}));
|
|
11
|
+
var FsStatRequest;
|
|
12
|
+
(function (FsStatRequest) {
|
|
13
|
+
FsStatRequest.type = new vscode.RequestType('fs/stat');
|
|
14
|
+
})(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
|
|
15
|
+
var FsReadFileRequest;
|
|
16
|
+
(function (FsReadFileRequest) {
|
|
17
|
+
FsReadFileRequest.type = new vscode.RequestType('fs/readFile');
|
|
18
|
+
})(FsReadFileRequest = exports.FsReadFileRequest || (exports.FsReadFileRequest = {}));
|
|
19
|
+
var FsReadDirectoryRequest;
|
|
20
|
+
(function (FsReadDirectoryRequest) {
|
|
21
|
+
FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
|
|
22
|
+
})(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
|
|
11
23
|
/**
|
|
12
24
|
* Client request server
|
|
13
25
|
*/
|
|
@@ -47,19 +59,4 @@ var ReportStats;
|
|
|
47
59
|
(function (ReportStats) {
|
|
48
60
|
ReportStats.type = new vscode.NotificationType0('vue/stats');
|
|
49
61
|
})(ReportStats = exports.ReportStats || (exports.ReportStats = {}));
|
|
50
|
-
/**
|
|
51
|
-
* FS request for browser
|
|
52
|
-
*/
|
|
53
|
-
var FsStatRequest;
|
|
54
|
-
(function (FsStatRequest) {
|
|
55
|
-
FsStatRequest.type = new vscode.RequestType('fs/stat');
|
|
56
|
-
})(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
|
|
57
|
-
var FsReadFileRequest;
|
|
58
|
-
(function (FsReadFileRequest) {
|
|
59
|
-
FsReadFileRequest.type = new vscode.RequestType('fs/readFile');
|
|
60
|
-
})(FsReadFileRequest = exports.FsReadFileRequest || (exports.FsReadFileRequest = {}));
|
|
61
|
-
var FsReadDirectoryRequest;
|
|
62
|
-
(function (FsReadDirectoryRequest) {
|
|
63
|
-
FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
|
|
64
|
-
})(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
|
|
65
62
|
//# sourceMappingURL=protocol.js.map
|
package/out/registerFeatures.js
CHANGED
|
@@ -70,7 +70,11 @@ function setupSyntacticCapabilities(params, server, initOptions) {
|
|
|
70
70
|
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
|
|
71
71
|
server.documentOnTypeFormattingProvider = {
|
|
72
72
|
firstTriggerCharacter: ';',
|
|
73
|
-
moreTriggerCharacter: [
|
|
73
|
+
moreTriggerCharacter: [
|
|
74
|
+
'}',
|
|
75
|
+
'\n',
|
|
76
|
+
'{', // addSpaceBetweenDoubleCurlyBrackets
|
|
77
|
+
],
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
80
|
}
|
|
@@ -161,12 +165,11 @@ function setupSemanticCapabilities(params, server, initOptions, plugins) {
|
|
|
161
165
|
server.codeLensProvider = {
|
|
162
166
|
resolveProvider: true,
|
|
163
167
|
};
|
|
164
|
-
server.executeCommandProvider = {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
};
|
|
168
|
+
server.executeCommandProvider = { commands: [...(_s = (_r = server.executeCommandProvider) === null || _r === void 0 ? void 0 : _r.commands) !== null && _s !== void 0 ? _s : []] };
|
|
169
|
+
// @ts-expect-error
|
|
170
|
+
if (!initOptions.__noPluginCommands) {
|
|
171
|
+
server.executeCommandProvider.commands.push(embedded.executePluginCommand);
|
|
172
|
+
}
|
|
170
173
|
}
|
|
171
174
|
if (!initOptions.respectClientCapabilities || ((_t = params.textDocument) === null || _t === void 0 ? void 0 : _t.semanticTokens)) {
|
|
172
175
|
server.semanticTokensProvider = {
|
package/out/server.js
CHANGED
|
@@ -111,7 +111,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
111
111
|
var _a, _b;
|
|
112
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
113
|
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
|
|
114
|
-
documentServiceHost = (0, documentServiceHost_1.createDocumentServiceHost)(runtimeEnv, plugins, ts, configHost);
|
|
114
|
+
documentServiceHost = (0, documentServiceHost_1.createDocumentServiceHost)(runtimeEnv, plugins, ts, configHost, options);
|
|
115
115
|
for (const root of roots) {
|
|
116
116
|
documentServiceHost.add(root);
|
|
117
117
|
}
|
|
@@ -126,7 +126,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
|
|
|
126
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
127
|
const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
|
|
128
128
|
fsHost = runtimeEnv.createFileSystemHost(ts, params.capabilities);
|
|
129
|
-
const tsLocalized = params.locale ? runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
|
|
129
|
+
const tsLocalized = params.locale ? yield runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
|
|
130
130
|
const cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
|
|
131
131
|
const _projects = (0, workspaces_1.createWorkspaces)(runtimeEnv, plugins, fsHost, configHost, ts, tsLocalized, params.capabilities, options, documents, connection, cancelTokenHost);
|
|
132
132
|
projects = _projects;
|
package/out/types.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ export type FileSystemHost = {
|
|
|
11
11
|
ready(connection: vscode.Connection): void;
|
|
12
12
|
clearCache(): void;
|
|
13
13
|
getWorkspaceFileSystem(rootUri: URI): FileSystem;
|
|
14
|
-
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams
|
|
14
|
+
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
|
|
15
15
|
};
|
|
16
16
|
export type FileSystem = Pick<ts.System, 'newLine' | 'useCaseSensitiveFileNames' | 'fileExists' | 'readFile' | 'readDirectory' | 'getCurrentDirectory' | 'realpath' | 'resolvePath'> & Partial<ts.System>;
|
|
17
17
|
export interface RuntimeEnvironment {
|
|
18
18
|
loadTypescript: (tsdk: string) => typeof import('typescript/lib/tsserverlibrary');
|
|
19
|
-
loadTypescriptLocalized: (tsdk: string, locale: string) =>
|
|
19
|
+
loadTypescriptLocalized: (tsdk: string, locale: string) => Promise<{} | undefined>;
|
|
20
20
|
schemaRequestHandlers: {
|
|
21
21
|
[schema: string]: (uri: string, encoding?: BufferEncoding) => Promise<string>;
|
|
22
22
|
};
|
|
@@ -66,4 +66,6 @@ export interface LanguageServerInitializationOptions {
|
|
|
66
66
|
* Enable this option to make language server setup server capabilities based on client capabilities to support multiple servers.
|
|
67
67
|
*/
|
|
68
68
|
respectClientCapabilities?: boolean;
|
|
69
|
+
maxFileSize?: number;
|
|
70
|
+
configFilePath?: string;
|
|
69
71
|
}
|
package/out/utils/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
-
export declare function loadCustomPlugins(dir: string): LanguageServicePlugin[];
|
|
2
|
+
export declare function loadCustomPlugins(dir: string, configFile: string | undefined): LanguageServicePlugin[];
|
package/out/utils/config.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.loadCustomPlugins = void 0;
|
|
3
|
-
function loadCustomPlugins(dir) {
|
|
3
|
+
function loadCustomPlugins(dir, configFile) {
|
|
4
4
|
var _a;
|
|
5
5
|
let configPath;
|
|
6
6
|
try {
|
|
7
|
-
configPath = require.resolve('./volar.config.js', { paths: [dir] });
|
|
7
|
+
configPath = require.resolve(configFile !== null && configFile !== void 0 ? configFile : './volar.config.js', { paths: [dir] });
|
|
8
8
|
}
|
|
9
9
|
catch (_b) { }
|
|
10
10
|
try {
|
|
11
11
|
if (configPath) {
|
|
12
12
|
const config = require(configPath);
|
|
13
|
+
delete require.cache[configPath];
|
|
13
14
|
return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
1
|
+
import { LanguageServerInitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
2
2
|
import * as embedded from '@volar/language-service';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
4
|
import type * as _ from 'vscode-languageserver-textdocument';
|
|
5
|
-
export declare function createDocumentServiceHost(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], ts: typeof import('typescript/lib/tsserverlibrary'), configHost: embedded.ConfigurationHost | undefined): {
|
|
5
|
+
export declare function createDocumentServiceHost(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], ts: typeof import('typescript/lib/tsserverlibrary'), configHost: embedded.ConfigurationHost | undefined, initOptions: LanguageServerInitializationOptions): {
|
|
6
6
|
add: (rootUri: URI) => void;
|
|
7
7
|
remove: (rootUri: URI) => void;
|
|
8
8
|
get: (documentUri: string) => {
|
|
9
|
-
format: (document: _.TextDocument, options:
|
|
9
|
+
format: (document: _.TextDocument, options: embedded.FormattingOptions, range?: embedded.Range | undefined, onTypeParams?: {
|
|
10
10
|
ch: string;
|
|
11
|
-
position:
|
|
12
|
-
} | undefined) => Promise<
|
|
13
|
-
getFoldingRanges: (document: _.TextDocument) => Promise<
|
|
14
|
-
getSelectionRanges: (document: _.TextDocument, positions:
|
|
15
|
-
findLinkedEditingRanges: (document: _.TextDocument, position:
|
|
16
|
-
findDocumentSymbols: (document: _.TextDocument) => Promise<
|
|
17
|
-
findDocumentColors: (document: _.TextDocument) => Promise<
|
|
18
|
-
getColorPresentations: (document: _.TextDocument, color:
|
|
19
|
-
doAutoInsert: (document: _.TextDocument, position:
|
|
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
20
|
lastChange: {
|
|
21
|
-
range:
|
|
21
|
+
range: embedded.Range;
|
|
22
22
|
rangeOffset: number;
|
|
23
23
|
rangeLength: number;
|
|
24
24
|
text: string;
|
|
25
25
|
};
|
|
26
|
-
}) => Promise<NonNullable<string |
|
|
26
|
+
}) => Promise<NonNullable<string | embedded.TextEdit | null | undefined> | undefined>;
|
|
27
27
|
context: embedded.DocumentServiceRuntimeContext;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
@@ -3,7 +3,7 @@ exports.createDocumentServiceHost = void 0;
|
|
|
3
3
|
const embedded = require("@volar/language-service");
|
|
4
4
|
const vscode_uri_1 = require("vscode-uri");
|
|
5
5
|
const config_1 = require("./config");
|
|
6
|
-
function createDocumentServiceHost(runtimeEnv, plugins, ts, configHost) {
|
|
6
|
+
function createDocumentServiceHost(runtimeEnv, plugins, ts, configHost, initOptions) {
|
|
7
7
|
const workspaceServices = new Map();
|
|
8
8
|
const untitledService = create(vscode_uri_1.URI.from({ scheme: 'untitled' }));
|
|
9
9
|
return {
|
|
@@ -39,7 +39,7 @@ function createDocumentServiceHost(runtimeEnv, plugins, ts, configHost) {
|
|
|
39
39
|
},
|
|
40
40
|
getPlugins() {
|
|
41
41
|
return [
|
|
42
|
-
...(0, config_1.loadCustomPlugins)(rootUri.fsPath),
|
|
42
|
+
...(0, config_1.loadCustomPlugins)(rootUri.fsPath, initOptions.configFilePath),
|
|
43
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
44
|
];
|
|
45
45
|
},
|
package/out/utils/project.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as shared from '@volar/shared';
|
|
2
1
|
import * as embeddedLS from '@volar/language-service';
|
|
3
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
|
-
import * as vscode from 'vscode-languageserver';
|
|
5
3
|
import { URI } from 'vscode-uri';
|
|
6
4
|
import { FileSystemHost, LanguageServerInitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types';
|
|
7
5
|
import { createSnapshots } from './snapshots';
|
|
@@ -11,7 +9,7 @@ import { CancellationTokenHost } from './cancellationPipe';
|
|
|
11
9
|
export interface Project extends ReturnType<typeof createProject> {
|
|
12
10
|
}
|
|
13
11
|
export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'), rootUri: URI, tsConfig: path.PosixPath | ts.CompilerOptions, tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, documentRegistry: ts.DocumentRegistry | undefined, cancelTokenHost: CancellationTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
|
|
14
|
-
tsConfig:
|
|
12
|
+
tsConfig: ts.CompilerOptions | path.PosixPath;
|
|
15
13
|
scripts: {
|
|
16
14
|
clear: () => void;
|
|
17
15
|
values: () => IterableIterator<{
|
|
@@ -34,20 +32,20 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
34
32
|
snapshot: ts.IScriptSnapshot | undefined;
|
|
35
33
|
snapshotVersion: number | undefined;
|
|
36
34
|
}) => void;
|
|
37
|
-
pathDelete: (
|
|
38
|
-
pathGet: (
|
|
35
|
+
pathDelete: (path: string) => boolean;
|
|
36
|
+
pathGet: (path: string) => {
|
|
39
37
|
version: number;
|
|
40
38
|
fileName: string;
|
|
41
39
|
snapshot: ts.IScriptSnapshot | undefined;
|
|
42
40
|
snapshotVersion: number | undefined;
|
|
43
41
|
} | undefined;
|
|
44
|
-
pathHas: (
|
|
42
|
+
pathHas: (path: string) => {
|
|
45
43
|
version: number;
|
|
46
44
|
fileName: string;
|
|
47
45
|
snapshot: ts.IScriptSnapshot | undefined;
|
|
48
46
|
snapshotVersion: number | undefined;
|
|
49
47
|
} | undefined;
|
|
50
|
-
pathSet: (
|
|
48
|
+
pathSet: (path: string, item: {
|
|
51
49
|
version: number;
|
|
52
50
|
fileName: string;
|
|
53
51
|
snapshot: ts.IScriptSnapshot | undefined;
|
|
@@ -56,81 +54,81 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
56
54
|
};
|
|
57
55
|
languageServiceHost: embeddedLS.LanguageServiceHost;
|
|
58
56
|
getLanguageService: () => {
|
|
59
|
-
doValidation: (uri: string, token?:
|
|
60
|
-
findReferences: (uri: string, position:
|
|
61
|
-
findFileReferences: (uri: string) => embeddedLS.NullableResult<
|
|
62
|
-
findDefinition: (uri: string, position:
|
|
63
|
-
findTypeDefinition: (uri: string, position:
|
|
64
|
-
findImplementations: (uri: string, position:
|
|
65
|
-
prepareRename: (uri: string, position:
|
|
66
|
-
doRename: (uri: string, position:
|
|
67
|
-
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<
|
|
68
|
-
getSemanticTokens: (uri: string, range:
|
|
69
|
-
doHover: (uri: string, position:
|
|
70
|
-
doComplete: (uri: string, position:
|
|
71
|
-
doCodeActions: (uri: string, range:
|
|
72
|
-
doCodeActionResolve: (item:
|
|
73
|
-
doCompletionResolve: (item:
|
|
74
|
-
getSignatureHelp: (uri: string, position:
|
|
75
|
-
doCodeLens: (uri: string) => Promise<
|
|
76
|
-
doCodeLensResolve: (item:
|
|
77
|
-
findDocumentHighlights: (uri: string, position:
|
|
78
|
-
findDocumentLinks: (uri: string) => Promise<
|
|
79
|
-
findWorkspaceSymbols: (query: string) => Promise<
|
|
80
|
-
doAutoInsert: (uri: string, position:
|
|
57
|
+
doValidation: (uri: string, token?: embeddedLS.CancellationToken | undefined, response?: ((result: embeddedLS.Diagnostic[]) => void) | undefined) => Promise<embeddedLS.Diagnostic[]>;
|
|
58
|
+
findReferences: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Location[] | undefined>;
|
|
59
|
+
findFileReferences: (uri: string) => embeddedLS.NullableResult<embeddedLS.Location[]>;
|
|
60
|
+
findDefinition: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
61
|
+
findTypeDefinition: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
62
|
+
findImplementations: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
63
|
+
prepareRename: (uri: string, position: embeddedLS.Position) => Promise<NonNullable<embeddedLS.Range | embeddedLS.ResponseError<void> | null | undefined> | undefined>;
|
|
64
|
+
doRename: (uri: string, position: embeddedLS.Position, newName: string) => Promise<embeddedLS.WorkspaceEdit | undefined>;
|
|
65
|
+
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<embeddedLS.WorkspaceEdit | undefined>;
|
|
66
|
+
getSemanticTokens: (uri: string, range: embeddedLS.Range | undefined, legend: embeddedLS.SemanticTokensLegend, cancelToken: embeddedLS.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
67
|
+
doHover: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Hover | undefined>;
|
|
68
|
+
doComplete: (uri: string, position: embeddedLS.Position, completionContext?: embeddedLS.CompletionContext | undefined) => Promise<embeddedLS.CompletionList>;
|
|
69
|
+
doCodeActions: (uri: string, range: embeddedLS.Range, codeActionContext: embeddedLS.CodeActionContext) => Promise<embeddedLS.CodeAction[] | undefined>;
|
|
70
|
+
doCodeActionResolve: (item: embeddedLS.CodeAction) => Promise<embeddedLS.CodeAction>;
|
|
71
|
+
doCompletionResolve: (item: embeddedLS.CompletionItem) => Promise<embeddedLS.CompletionItem>;
|
|
72
|
+
getSignatureHelp: (uri: string, position: embeddedLS.Position, signatureHelpContext?: embeddedLS.SignatureHelpContext | undefined) => Promise<embeddedLS.SignatureHelp | undefined>;
|
|
73
|
+
doCodeLens: (uri: string) => Promise<embeddedLS.CodeLens[]>;
|
|
74
|
+
doCodeLensResolve: (item: embeddedLS.CodeLens) => Promise<embeddedLS.CodeLens>;
|
|
75
|
+
findDocumentHighlights: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.DocumentHighlight[] | undefined>;
|
|
76
|
+
findDocumentLinks: (uri: string) => Promise<embeddedLS.DocumentLink[]>;
|
|
77
|
+
findWorkspaceSymbols: (query: string) => Promise<embeddedLS.SymbolInformation[]>;
|
|
78
|
+
doAutoInsert: (uri: string, position: embeddedLS.Position, autoInsertContext: {
|
|
81
79
|
lastChange: {
|
|
82
|
-
range:
|
|
80
|
+
range: embeddedLS.Range;
|
|
83
81
|
rangeOffset: number;
|
|
84
82
|
rangeLength: number;
|
|
85
83
|
text: string;
|
|
86
84
|
};
|
|
87
|
-
}) => Promise<NonNullable<string |
|
|
85
|
+
}) => Promise<NonNullable<string | embeddedLS.TextEdit | null | undefined> | undefined>;
|
|
88
86
|
doExecuteCommand: (command: string, args: embeddedLS.ExecutePluginCommandArgs, executeCommandContext: embeddedLS.ExecuteCommandContext) => Promise<void>;
|
|
89
|
-
getInlayHints: (uri: string, range:
|
|
87
|
+
getInlayHints: (uri: string, range: embeddedLS.Range) => Promise<embeddedLS.InlayHint[] | undefined>;
|
|
90
88
|
callHierarchy: {
|
|
91
|
-
doPrepare(uri: string, position:
|
|
92
|
-
getIncomingCalls(item:
|
|
93
|
-
getOutgoingCalls(item:
|
|
89
|
+
doPrepare(uri: string, position: embeddedLS.Position): Promise<embeddedLS.CallHierarchyItem[] | undefined>;
|
|
90
|
+
getIncomingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyIncomingCall[]>;
|
|
91
|
+
getOutgoingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyOutgoingCall[]>;
|
|
94
92
|
};
|
|
95
93
|
dispose: () => void;
|
|
96
94
|
context: embeddedLS.LanguageServiceRuntimeContext;
|
|
97
95
|
};
|
|
98
96
|
getLanguageServiceDontCreate: () => {
|
|
99
|
-
doValidation: (uri: string, token?:
|
|
100
|
-
findReferences: (uri: string, position:
|
|
101
|
-
findFileReferences: (uri: string) => embeddedLS.NullableResult<
|
|
102
|
-
findDefinition: (uri: string, position:
|
|
103
|
-
findTypeDefinition: (uri: string, position:
|
|
104
|
-
findImplementations: (uri: string, position:
|
|
105
|
-
prepareRename: (uri: string, position:
|
|
106
|
-
doRename: (uri: string, position:
|
|
107
|
-
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<
|
|
108
|
-
getSemanticTokens: (uri: string, range:
|
|
109
|
-
doHover: (uri: string, position:
|
|
110
|
-
doComplete: (uri: string, position:
|
|
111
|
-
doCodeActions: (uri: string, range:
|
|
112
|
-
doCodeActionResolve: (item:
|
|
113
|
-
doCompletionResolve: (item:
|
|
114
|
-
getSignatureHelp: (uri: string, position:
|
|
115
|
-
doCodeLens: (uri: string) => Promise<
|
|
116
|
-
doCodeLensResolve: (item:
|
|
117
|
-
findDocumentHighlights: (uri: string, position:
|
|
118
|
-
findDocumentLinks: (uri: string) => Promise<
|
|
119
|
-
findWorkspaceSymbols: (query: string) => Promise<
|
|
120
|
-
doAutoInsert: (uri: string, position:
|
|
97
|
+
doValidation: (uri: string, token?: embeddedLS.CancellationToken | undefined, response?: ((result: embeddedLS.Diagnostic[]) => void) | undefined) => Promise<embeddedLS.Diagnostic[]>;
|
|
98
|
+
findReferences: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Location[] | undefined>;
|
|
99
|
+
findFileReferences: (uri: string) => embeddedLS.NullableResult<embeddedLS.Location[]>;
|
|
100
|
+
findDefinition: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
101
|
+
findTypeDefinition: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
102
|
+
findImplementations: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.LocationLink[] | undefined>;
|
|
103
|
+
prepareRename: (uri: string, position: embeddedLS.Position) => Promise<NonNullable<embeddedLS.Range | embeddedLS.ResponseError<void> | null | undefined> | undefined>;
|
|
104
|
+
doRename: (uri: string, position: embeddedLS.Position, newName: string) => Promise<embeddedLS.WorkspaceEdit | undefined>;
|
|
105
|
+
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<embeddedLS.WorkspaceEdit | undefined>;
|
|
106
|
+
getSemanticTokens: (uri: string, range: embeddedLS.Range | undefined, legend: embeddedLS.SemanticTokensLegend, cancelToken: embeddedLS.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
107
|
+
doHover: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Hover | undefined>;
|
|
108
|
+
doComplete: (uri: string, position: embeddedLS.Position, completionContext?: embeddedLS.CompletionContext | undefined) => Promise<embeddedLS.CompletionList>;
|
|
109
|
+
doCodeActions: (uri: string, range: embeddedLS.Range, codeActionContext: embeddedLS.CodeActionContext) => Promise<embeddedLS.CodeAction[] | undefined>;
|
|
110
|
+
doCodeActionResolve: (item: embeddedLS.CodeAction) => Promise<embeddedLS.CodeAction>;
|
|
111
|
+
doCompletionResolve: (item: embeddedLS.CompletionItem) => Promise<embeddedLS.CompletionItem>;
|
|
112
|
+
getSignatureHelp: (uri: string, position: embeddedLS.Position, signatureHelpContext?: embeddedLS.SignatureHelpContext | undefined) => Promise<embeddedLS.SignatureHelp | undefined>;
|
|
113
|
+
doCodeLens: (uri: string) => Promise<embeddedLS.CodeLens[]>;
|
|
114
|
+
doCodeLensResolve: (item: embeddedLS.CodeLens) => Promise<embeddedLS.CodeLens>;
|
|
115
|
+
findDocumentHighlights: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.DocumentHighlight[] | undefined>;
|
|
116
|
+
findDocumentLinks: (uri: string) => Promise<embeddedLS.DocumentLink[]>;
|
|
117
|
+
findWorkspaceSymbols: (query: string) => Promise<embeddedLS.SymbolInformation[]>;
|
|
118
|
+
doAutoInsert: (uri: string, position: embeddedLS.Position, autoInsertContext: {
|
|
121
119
|
lastChange: {
|
|
122
|
-
range:
|
|
120
|
+
range: embeddedLS.Range;
|
|
123
121
|
rangeOffset: number;
|
|
124
122
|
rangeLength: number;
|
|
125
123
|
text: string;
|
|
126
124
|
};
|
|
127
|
-
}) => Promise<NonNullable<string |
|
|
125
|
+
}) => Promise<NonNullable<string | embeddedLS.TextEdit | null | undefined> | undefined>;
|
|
128
126
|
doExecuteCommand: (command: string, args: embeddedLS.ExecutePluginCommandArgs, executeCommandContext: embeddedLS.ExecuteCommandContext) => Promise<void>;
|
|
129
|
-
getInlayHints: (uri: string, range:
|
|
127
|
+
getInlayHints: (uri: string, range: embeddedLS.Range) => Promise<embeddedLS.InlayHint[] | undefined>;
|
|
130
128
|
callHierarchy: {
|
|
131
|
-
doPrepare(uri: string, position:
|
|
132
|
-
getIncomingCalls(item:
|
|
133
|
-
getOutgoingCalls(item:
|
|
129
|
+
doPrepare(uri: string, position: embeddedLS.Position): Promise<embeddedLS.CallHierarchyItem[] | undefined>;
|
|
130
|
+
getIncomingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyIncomingCall[]>;
|
|
131
|
+
getOutgoingCalls(item: embeddedLS.CallHierarchyItem): Promise<embeddedLS.CallHierarchyOutgoingCall[]>;
|
|
134
132
|
};
|
|
135
133
|
dispose: () => void;
|
|
136
134
|
context: embeddedLS.LanguageServiceRuntimeContext;
|
package/out/utils/project.js
CHANGED
|
@@ -57,7 +57,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
57
57
|
context: languageContext,
|
|
58
58
|
getPlugins() {
|
|
59
59
|
return [
|
|
60
|
-
...(0, config_1.loadCustomPlugins)(languageServiceHost.getCurrentDirectory()),
|
|
60
|
+
...(0, config_1.loadCustomPlugins)(languageServiceHost.getCurrentDirectory(), serverOptions.configFilePath),
|
|
61
61
|
...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
62
|
];
|
|
63
63
|
},
|
|
@@ -138,7 +138,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
138
138
|
}
|
|
139
139
|
catch (_a) {
|
|
140
140
|
// web
|
|
141
|
-
return
|
|
141
|
+
return serverOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
getProjectVersion: () => projectVersion.toString(),
|
|
@@ -164,22 +164,30 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
164
164
|
return host;
|
|
165
165
|
function getScriptVersion(fileName) {
|
|
166
166
|
var _a, _b;
|
|
167
|
-
const doc = documents.data.pathGet(
|
|
167
|
+
const doc = documents.data.pathGet(fileName);
|
|
168
168
|
if (doc) {
|
|
169
169
|
return doc.version.toString();
|
|
170
170
|
}
|
|
171
|
-
return (_b = (_a = scripts.pathGet(
|
|
171
|
+
return (_b = (_a = scripts.pathGet(fileName)) === null || _a === void 0 ? void 0 : _a.version.toString()) !== null && _b !== void 0 ? _b : '';
|
|
172
172
|
}
|
|
173
173
|
function getScriptSnapshot(fileName) {
|
|
174
|
-
|
|
174
|
+
var _a;
|
|
175
|
+
const doc = documents.data.pathGet(fileName);
|
|
175
176
|
if (doc) {
|
|
176
177
|
return doc.getSnapshot();
|
|
177
178
|
}
|
|
178
|
-
const script = scripts.pathGet(
|
|
179
|
+
const script = scripts.pathGet(fileName);
|
|
179
180
|
if (script && script.snapshotVersion === script.version) {
|
|
180
181
|
return script.snapshot;
|
|
181
182
|
}
|
|
182
183
|
if (sys.fileExists(fileName)) {
|
|
184
|
+
if (serverOptions.maxFileSize) {
|
|
185
|
+
const fileSize = (_a = sys.getFileSize) === null || _a === void 0 ? void 0 : _a.call(sys, fileName);
|
|
186
|
+
if (fileSize !== undefined && fileSize > serverOptions.maxFileSize) {
|
|
187
|
+
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${serverOptions.maxFileSize}bytes)`);
|
|
188
|
+
return ts.ScriptSnapshot.fromString('');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
183
191
|
const text = sys.readFile(fileName, 'utf8');
|
|
184
192
|
if (text !== undefined) {
|
|
185
193
|
const snapshot = ts.ScriptSnapshot.fromString(text);
|
|
@@ -188,7 +196,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
188
196
|
script.snapshotVersion = script.version;
|
|
189
197
|
}
|
|
190
198
|
else {
|
|
191
|
-
scripts.pathSet(
|
|
199
|
+
scripts.pathSet(fileName, {
|
|
192
200
|
version: -1,
|
|
193
201
|
fileName: fileName,
|
|
194
202
|
snapshot: snapshot,
|