@volar/language-server 1.11.1 → 2.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/browser.d.ts +4 -3
- package/browser.js +16 -6
- package/index.d.ts +0 -1
- package/lib/cancellationToken.d.ts +3 -0
- package/lib/{node/cancellationPipe.js → cancellationToken.js} +2 -3
- package/lib/config.d.ts +5 -0
- package/lib/config.js +32 -0
- package/lib/{common/configurationHost.d.ts → configurationHost.d.ts} +1 -2
- package/lib/project/inferredCompilerOptions.d.ts +3 -0
- package/lib/{common/utils → project}/inferredCompilerOptions.js +3 -3
- package/lib/project/simpleProject.d.ts +4 -0
- package/lib/project/simpleProject.js +34 -0
- package/lib/project/simpleProjectProvider.d.ts +25 -0
- package/lib/project/simpleProjectProvider.js +67 -0
- package/lib/project/typescriptProject.d.ts +11 -0
- package/lib/project/typescriptProject.js +136 -0
- package/lib/project/typescriptProjectProvider.d.ts +4 -0
- package/lib/project/typescriptProjectProvider.js +232 -0
- package/lib/register/registerEditorFeatures.d.ts +3 -0
- package/lib/register/registerEditorFeatures.js +157 -0
- package/lib/register/registerLanguageFeatures.d.ts +5 -0
- package/lib/{common/features/languageFeatures.js → register/registerLanguageFeatures.js} +17 -31
- package/lib/{common/schemaRequestHandlers → schemaRequestHandlers}/http.d.ts +0 -1
- package/lib/server.d.ts +14 -0
- package/lib/server.js +325 -0
- package/lib/setupCapabilities.d.ts +4 -0
- package/lib/{common/utils/registerFeatures.js → setupCapabilities.js} +6 -9
- package/lib/types.d.ts +39 -17
- package/lib/{common/utils → utils}/isFileInDir.d.ts +0 -1
- package/lib/{common/utils → utils}/uriMap.d.ts +1 -1
- package/lib/workspaceFolderManager.d.ts +16 -0
- package/lib/workspaceFolderManager.js +39 -0
- package/node.d.ts +4 -3
- package/node.js +18 -8
- package/package.json +7 -7
- package/protocol.d.ts +40 -12
- package/protocol.js +16 -1
- package/lib/common/documents.d.ts +0 -47
- package/lib/common/documents.js +0 -216
- package/lib/common/features/customFeatures.d.ts +0 -5
- package/lib/common/features/customFeatures.js +0 -138
- package/lib/common/features/languageFeatures.d.ts +0 -7
- package/lib/common/project.d.ts +0 -141
- package/lib/common/project.js +0 -202
- package/lib/common/server.d.ts +0 -15
- package/lib/common/server.js +0 -227
- package/lib/common/utils/inferredCompilerOptions.d.ts +0 -4
- package/lib/common/utils/registerFeatures.d.ts +0 -5
- package/lib/common/utils/serverConfig.d.ts +0 -3
- package/lib/common/utils/serverConfig.js +0 -22
- package/lib/common/workspaces.d.ts +0 -1824
- package/lib/common/workspaces.js +0 -347
- package/lib/node/cancellationPipe.d.ts +0 -3
- /package/lib/{common/configurationHost.js → configurationHost.js} +0 -0
- /package/lib/{common/schemaRequestHandlers → schemaRequestHandlers}/http.js +0 -0
- /package/lib/{common/utils → utils}/isFileInDir.js +0 -0
- /package/lib/{common/utils → utils}/uriMap.js +0 -0
package/lib/common/project.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProject = void 0;
|
|
4
|
-
const language_service_1 = require("@volar/language-service");
|
|
5
|
-
const path = require("path-browserify");
|
|
6
|
-
const vscode = require("vscode-languageserver");
|
|
7
|
-
const serverConfig_1 = require("./utils/serverConfig");
|
|
8
|
-
const uriMap_1 = require("./utils/uriMap");
|
|
9
|
-
const typescript_1 = require("@volar/typescript");
|
|
10
|
-
const globalSnapshots = new WeakMap();
|
|
11
|
-
async function createProject(context) {
|
|
12
|
-
let projectVersion = 0;
|
|
13
|
-
let token = context.server.runtimeEnv.getCancellationToken();
|
|
14
|
-
let languageService;
|
|
15
|
-
const tsToken = {
|
|
16
|
-
isCancellationRequested() {
|
|
17
|
-
return token.isCancellationRequested;
|
|
18
|
-
},
|
|
19
|
-
throwIfCancellationRequested() { },
|
|
20
|
-
};
|
|
21
|
-
const { uriToFileName, fileNameToUri, fs } = context.server.runtimeEnv;
|
|
22
|
-
const env = {
|
|
23
|
-
uriToFileName,
|
|
24
|
-
fileNameToUri,
|
|
25
|
-
fs,
|
|
26
|
-
console: context.server.runtimeEnv.console,
|
|
27
|
-
locale: context.workspaces.initParams.locale,
|
|
28
|
-
workspaceUri: context.project.workspaceUri,
|
|
29
|
-
rootUri: context.project.rootUri,
|
|
30
|
-
clientCapabilities: context.workspaces.initParams.capabilities,
|
|
31
|
-
getConfiguration: context.server.configurationHost?.getConfiguration,
|
|
32
|
-
onDidChangeConfiguration: context.server.configurationHost?.onDidChangeConfiguration,
|
|
33
|
-
onDidChangeWatchedFiles: context.server.onDidChangeWatchedFiles,
|
|
34
|
-
};
|
|
35
|
-
if (!globalSnapshots.has(fs)) {
|
|
36
|
-
globalSnapshots.set(fs, (0, uriMap_1.createUriMap)(fileNameToUri));
|
|
37
|
-
}
|
|
38
|
-
const askedFiles = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
39
|
-
const languageHost = {
|
|
40
|
-
workspacePath: uriToFileName(context.project.workspaceUri.toString()),
|
|
41
|
-
rootPath: uriToFileName(context.project.rootUri.toString()),
|
|
42
|
-
getProjectVersion: () => projectVersion.toString(),
|
|
43
|
-
getScriptFileNames: () => parsedCommandLine.fileNames,
|
|
44
|
-
getScriptSnapshot: (fileName) => {
|
|
45
|
-
askedFiles.pathSet(fileName, true);
|
|
46
|
-
const doc = context.workspaces.documents.data.pathGet(fileName);
|
|
47
|
-
if (doc) {
|
|
48
|
-
return doc.getSnapshot();
|
|
49
|
-
}
|
|
50
|
-
const fsSnapshot = globalSnapshots.get(fs).pathGet(fileName);
|
|
51
|
-
if (fsSnapshot) {
|
|
52
|
-
return fsSnapshot;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
getLanguageId: (fileName) => context.workspaces.documents.data.pathGet(fileName)?.languageId,
|
|
56
|
-
getCancellationToken: () => tsToken,
|
|
57
|
-
getCompilationSettings: () => parsedCommandLine.options,
|
|
58
|
-
getLocalizedDiagnosticMessages: context.workspaces.tsLocalized ? () => context.workspaces.tsLocalized : undefined,
|
|
59
|
-
getProjectReferences: () => parsedCommandLine.projectReferences,
|
|
60
|
-
};
|
|
61
|
-
const docChangeWatcher = context.workspaces.documents.onDidChangeContent(() => {
|
|
62
|
-
projectVersion++;
|
|
63
|
-
token = context.server.runtimeEnv.getCancellationToken();
|
|
64
|
-
});
|
|
65
|
-
const fileWatch = env.onDidChangeWatchedFiles?.(params => {
|
|
66
|
-
onWorkspaceFilesChanged(params.changes);
|
|
67
|
-
});
|
|
68
|
-
let existingOptions;
|
|
69
|
-
for (const plugin of context.workspaces.plugins) {
|
|
70
|
-
if (plugin.resolveExistingOptions) {
|
|
71
|
-
existingOptions = plugin.resolveExistingOptions(existingOptions);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
let parsedCommandLine = await createParsedCommandLine(context.workspaces.ts, env, uriToFileName(context.project.rootUri.toString()), context.project.tsConfig, context.workspaces.plugins, existingOptions);
|
|
75
|
-
let config = (context.project.workspaceUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.server.runtimeEnv.console, context.server.runtimeEnv.uriToFileName(context.project.workspaceUri.toString()), context.workspaces.initOptions.configFilePath) : {}) ?? {};
|
|
76
|
-
for (const plugin of context.workspaces.plugins) {
|
|
77
|
-
if (plugin.resolveConfig) {
|
|
78
|
-
config = await plugin.resolveConfig(config, {
|
|
79
|
-
...context,
|
|
80
|
-
env,
|
|
81
|
-
host: languageHost,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
await syncRootScriptSnapshots();
|
|
86
|
-
return {
|
|
87
|
-
context,
|
|
88
|
-
tsConfig: context.project.tsConfig,
|
|
89
|
-
languageHost,
|
|
90
|
-
getLanguageService,
|
|
91
|
-
getLanguageServiceDontCreate: () => languageService,
|
|
92
|
-
getParsedCommandLine: () => parsedCommandLine,
|
|
93
|
-
tryAddFile: (fileName) => {
|
|
94
|
-
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
95
|
-
parsedCommandLine.fileNames.push(fileName);
|
|
96
|
-
projectVersion++;
|
|
97
|
-
token = context.server.runtimeEnv.getCancellationToken();
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
askedFiles,
|
|
101
|
-
dispose,
|
|
102
|
-
};
|
|
103
|
-
function getLanguageService() {
|
|
104
|
-
if (!languageService) {
|
|
105
|
-
languageService = (0, language_service_1.createLanguageService)({ typescript: context.workspaces.ts }, env, config, languageHost);
|
|
106
|
-
}
|
|
107
|
-
return languageService;
|
|
108
|
-
}
|
|
109
|
-
async function syncRootScriptSnapshots() {
|
|
110
|
-
const promises = [];
|
|
111
|
-
let dirty = false;
|
|
112
|
-
for (const fileName of parsedCommandLine.fileNames) {
|
|
113
|
-
const uri = fileNameToUri(fileName);
|
|
114
|
-
if (!globalSnapshots.get(fs).uriGet(uri)) {
|
|
115
|
-
dirty = true;
|
|
116
|
-
promises.push(updateRootScriptSnapshot(uri));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
await Promise.all(promises);
|
|
120
|
-
return dirty;
|
|
121
|
-
}
|
|
122
|
-
async function updateRootScriptSnapshot(uri) {
|
|
123
|
-
const text = await context.server.runtimeEnv.fs.readFile(uri);
|
|
124
|
-
globalSnapshots.get(fs).uriSet(uri, text !== undefined ? {
|
|
125
|
-
getText: (start, end) => text.substring(start, end),
|
|
126
|
-
getLength: () => text.length,
|
|
127
|
-
getChangeRange: () => undefined,
|
|
128
|
-
} : undefined);
|
|
129
|
-
}
|
|
130
|
-
async function onWorkspaceFilesChanged(changes) {
|
|
131
|
-
const oldProjectVersion = projectVersion;
|
|
132
|
-
const creates = changes.filter(change => change.type === vscode.FileChangeType.Created);
|
|
133
|
-
if (creates.length) {
|
|
134
|
-
parsedCommandLine = await createParsedCommandLine(context.workspaces.ts, env, uriToFileName(context.project.rootUri.toString()), context.project.tsConfig, context.workspaces.plugins, existingOptions);
|
|
135
|
-
if (await syncRootScriptSnapshots()) {
|
|
136
|
-
projectVersion++;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
await Promise.all(changes.map(async (change) => {
|
|
140
|
-
if (askedFiles.uriGet(change.uri) && globalSnapshots.get(fs).uriGet(change.uri)) {
|
|
141
|
-
if (change.type === vscode.FileChangeType.Changed) {
|
|
142
|
-
await updateRootScriptSnapshot(change.uri);
|
|
143
|
-
}
|
|
144
|
-
else if (change.type === vscode.FileChangeType.Deleted) {
|
|
145
|
-
globalSnapshots.get(fs).uriSet(change.uri, undefined);
|
|
146
|
-
}
|
|
147
|
-
projectVersion++;
|
|
148
|
-
}
|
|
149
|
-
}));
|
|
150
|
-
if (oldProjectVersion !== projectVersion) {
|
|
151
|
-
token = context.server.runtimeEnv.getCancellationToken();
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
function dispose() {
|
|
155
|
-
languageService?.dispose();
|
|
156
|
-
fileWatch?.dispose();
|
|
157
|
-
docChangeWatcher.dispose();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.createProject = createProject;
|
|
161
|
-
async function createParsedCommandLine(ts, env, rootPath, tsConfig, plugins, existingOptions) {
|
|
162
|
-
const extraFileExtensions = plugins.map(plugin => plugin.extraFileExtensions ?? []).flat();
|
|
163
|
-
if (ts) {
|
|
164
|
-
const sys = (0, typescript_1.createSys)(ts, {
|
|
165
|
-
...env,
|
|
166
|
-
onDidChangeWatchedFiles: undefined,
|
|
167
|
-
});
|
|
168
|
-
let content;
|
|
169
|
-
let sysVersion;
|
|
170
|
-
let newSysVersion = await sys.sync();
|
|
171
|
-
while (sysVersion !== newSysVersion) {
|
|
172
|
-
sysVersion = newSysVersion;
|
|
173
|
-
try {
|
|
174
|
-
if (typeof tsConfig === 'string') {
|
|
175
|
-
const config = ts.readJsonConfigFile(tsConfig, sys.readFile);
|
|
176
|
-
content = ts.parseJsonSourceFileConfigFileContent(config, sys, path.dirname(tsConfig), existingOptions, tsConfig, undefined, extraFileExtensions);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
content = ts.parseJsonConfigFileContent({ files: [] }, sys, rootPath, { ...tsConfig, ...existingOptions }, rootPath + '/jsconfig.json', undefined, extraFileExtensions);
|
|
180
|
-
}
|
|
181
|
-
// fix https://github.com/johnsoncodehk/volar/issues/1786
|
|
182
|
-
// https://github.com/microsoft/TypeScript/issues/30457
|
|
183
|
-
// patching ts server broke with outDir + rootDir + composite/incremental
|
|
184
|
-
content.options.outDir = undefined;
|
|
185
|
-
content.fileNames = content.fileNames.map(fileName => fileName.replace(/\\/g, '/'));
|
|
186
|
-
}
|
|
187
|
-
catch {
|
|
188
|
-
// will be failed if web fs host first result not ready
|
|
189
|
-
}
|
|
190
|
-
newSysVersion = await sys.sync();
|
|
191
|
-
}
|
|
192
|
-
if (content) {
|
|
193
|
-
return content;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
errors: [],
|
|
198
|
-
fileNames: [],
|
|
199
|
-
options: {},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//# sourceMappingURL=project.js.map
|
package/lib/common/server.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as vscode from 'vscode-languageserver';
|
|
2
|
-
import { InitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types.js';
|
|
3
|
-
import { createConfigurationHost } from './configurationHost.js';
|
|
4
|
-
export interface ServerContext {
|
|
5
|
-
server: {
|
|
6
|
-
initializeParams: vscode.InitializeParams;
|
|
7
|
-
connection: vscode.Connection;
|
|
8
|
-
runtimeEnv: RuntimeEnvironment;
|
|
9
|
-
plugins: LanguageServerPlugin[];
|
|
10
|
-
onDidChangeWatchedFiles: vscode.Connection['onDidChangeWatchedFiles'];
|
|
11
|
-
configurationHost: ReturnType<typeof createConfigurationHost> | undefined;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare function startCommonLanguageServer(connection: vscode.Connection, _plugins: LanguageServerPlugin[], getRuntimeEnv: (params: vscode.InitializeParams, options: InitializationOptions) => RuntimeEnvironment): void;
|
|
15
|
-
//# sourceMappingURL=server.d.ts.map
|
package/lib/common/server.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startCommonLanguageServer = void 0;
|
|
4
|
-
const index_js_1 = require("@volar/language-service/index.js");
|
|
5
|
-
const l10n = require("@vscode/l10n");
|
|
6
|
-
const vscode = require("vscode-languageserver");
|
|
7
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
8
|
-
const types_js_1 = require("../types.js");
|
|
9
|
-
const configurationHost_js_1 = require("./configurationHost.js");
|
|
10
|
-
const documents_js_1 = require("./documents.js");
|
|
11
|
-
const registerFeatures_js_1 = require("./utils/registerFeatures.js");
|
|
12
|
-
const serverConfig_js_1 = require("./utils/serverConfig.js");
|
|
13
|
-
const workspaces_js_1 = require("./workspaces.js");
|
|
14
|
-
const request_light_1 = require("request-light");
|
|
15
|
-
function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
16
|
-
let initParams;
|
|
17
|
-
let options;
|
|
18
|
-
let roots = [];
|
|
19
|
-
let workspaces;
|
|
20
|
-
let plugins;
|
|
21
|
-
let documents;
|
|
22
|
-
let context;
|
|
23
|
-
let ts;
|
|
24
|
-
let tsLocalized;
|
|
25
|
-
const didChangeWatchedFilesCallbacks = new Set();
|
|
26
|
-
connection.onInitialize(async (_params) => {
|
|
27
|
-
initParams = _params;
|
|
28
|
-
options = initParams.initializationOptions;
|
|
29
|
-
const env = getRuntimeEnv(initParams, options);
|
|
30
|
-
context = {
|
|
31
|
-
server: {
|
|
32
|
-
initializeParams: initParams,
|
|
33
|
-
connection,
|
|
34
|
-
runtimeEnv: {
|
|
35
|
-
...env,
|
|
36
|
-
fs: createFsWithCache(env.fs),
|
|
37
|
-
},
|
|
38
|
-
plugins: _plugins,
|
|
39
|
-
configurationHost: initParams.capabilities.workspace?.configuration ? (0, configurationHost_js_1.createConfigurationHost)(initParams, connection) : undefined,
|
|
40
|
-
onDidChangeWatchedFiles: cb => {
|
|
41
|
-
didChangeWatchedFilesCallbacks.add(cb);
|
|
42
|
-
return {
|
|
43
|
-
dispose: () => {
|
|
44
|
-
didChangeWatchedFilesCallbacks.delete(cb);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
ts = await context.server.runtimeEnv.loadTypeScript(options);
|
|
51
|
-
tsLocalized = initParams.locale
|
|
52
|
-
? await context.server.runtimeEnv.loadTypeScriptLocalized(options, initParams.locale)
|
|
53
|
-
: undefined;
|
|
54
|
-
plugins = context.server.plugins.map(plugin => plugin(options, { typescript: ts }));
|
|
55
|
-
documents = (0, documents_js_1.createDocuments)(context.server.runtimeEnv, connection);
|
|
56
|
-
if (options.l10n) {
|
|
57
|
-
await l10n.config({ uri: options.l10n.location });
|
|
58
|
-
}
|
|
59
|
-
if (initParams.capabilities.workspace?.workspaceFolders && initParams.workspaceFolders) {
|
|
60
|
-
roots = initParams.workspaceFolders.map(folder => vscode_uri_1.URI.parse(folder.uri));
|
|
61
|
-
}
|
|
62
|
-
else if (initParams.rootUri) {
|
|
63
|
-
roots = [vscode_uri_1.URI.parse(initParams.rootUri)];
|
|
64
|
-
}
|
|
65
|
-
else if (initParams.rootPath) {
|
|
66
|
-
roots = [vscode_uri_1.URI.file(initParams.rootPath)];
|
|
67
|
-
}
|
|
68
|
-
const result = {
|
|
69
|
-
capabilities: {
|
|
70
|
-
textDocumentSync: vscode.TextDocumentSyncKind.Incremental,
|
|
71
|
-
workspace: {
|
|
72
|
-
// #18
|
|
73
|
-
workspaceFolders: {
|
|
74
|
-
supported: true,
|
|
75
|
-
changeNotifications: true,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
let config = {};
|
|
81
|
-
for (const root of roots) {
|
|
82
|
-
if (root.scheme === 'file') {
|
|
83
|
-
const workspaceConfig = (0, serverConfig_js_1.loadConfig)(env.console, root.path, options.configFilePath);
|
|
84
|
-
if (workspaceConfig) {
|
|
85
|
-
config = workspaceConfig;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
for (const plugin of plugins) {
|
|
91
|
-
if (plugin.resolveConfig) {
|
|
92
|
-
config = await plugin.resolveConfig(config, undefined);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
(0, registerFeatures_js_1.setupCapabilities)(result.capabilities, options, plugins, getSemanticTokensLegend(), config.services ?? {});
|
|
96
|
-
await createLanguageServiceHost();
|
|
97
|
-
try {
|
|
98
|
-
// show version on LSP logs
|
|
99
|
-
const packageJson = require('../package.json');
|
|
100
|
-
result.serverInfo = {
|
|
101
|
-
name: packageJson.name,
|
|
102
|
-
version: packageJson.version,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
catch { }
|
|
106
|
-
return result;
|
|
107
|
-
});
|
|
108
|
-
connection.onInitialized(async () => {
|
|
109
|
-
context.server.configurationHost?.ready();
|
|
110
|
-
context.server.configurationHost?.onDidChangeConfiguration?.(updateHttpSettings);
|
|
111
|
-
updateHttpSettings();
|
|
112
|
-
if (initParams.capabilities.workspace?.workspaceFolders) {
|
|
113
|
-
connection.workspace.onDidChangeWorkspaceFolders(e => {
|
|
114
|
-
for (const folder of e.added) {
|
|
115
|
-
workspaces?.add(vscode_uri_1.URI.parse(folder.uri));
|
|
116
|
-
}
|
|
117
|
-
for (const folder of e.removed) {
|
|
118
|
-
workspaces?.remove(vscode_uri_1.URI.parse(folder.uri));
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
if (options.serverMode !== types_js_1.ServerMode.Syntactic
|
|
123
|
-
&& initParams.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration) {
|
|
124
|
-
const exts = plugins.map(plugin => plugin.watchFileExtensions).flat();
|
|
125
|
-
if (exts.length) {
|
|
126
|
-
connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
|
|
127
|
-
watchers: [
|
|
128
|
-
{
|
|
129
|
-
globPattern: `**/*.{${exts.join(',')}}`
|
|
130
|
-
},
|
|
131
|
-
]
|
|
132
|
-
});
|
|
133
|
-
connection.onDidChangeWatchedFiles(e => {
|
|
134
|
-
for (const cb of didChangeWatchedFilesCallbacks) {
|
|
135
|
-
cb(e);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
async function updateHttpSettings() {
|
|
141
|
-
const httpSettings = await context.server.configurationHost?.getConfiguration?.('http');
|
|
142
|
-
(0, request_light_1.configure)(httpSettings?.proxy, httpSettings?.proxyStrictSSL ?? false);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
connection.onShutdown(async () => {
|
|
146
|
-
workspaces?.reloadProjects();
|
|
147
|
-
});
|
|
148
|
-
connection.listen();
|
|
149
|
-
function createFsWithCache(fs) {
|
|
150
|
-
const readFileCache = new Map();
|
|
151
|
-
const statCache = new Map();
|
|
152
|
-
const readDirectoryCache = new Map();
|
|
153
|
-
didChangeWatchedFilesCallbacks.add(({ changes }) => {
|
|
154
|
-
for (const change of changes) {
|
|
155
|
-
if (change.type === vscode.FileChangeType.Deleted) {
|
|
156
|
-
readFileCache.set(change.uri, undefined);
|
|
157
|
-
statCache.set(change.uri, undefined);
|
|
158
|
-
const dir = change.uri.substring(0, change.uri.lastIndexOf('/'));
|
|
159
|
-
readDirectoryCache.delete(dir);
|
|
160
|
-
}
|
|
161
|
-
else if (change.type === vscode.FileChangeType.Changed) {
|
|
162
|
-
readFileCache.delete(change.uri);
|
|
163
|
-
statCache.delete(change.uri);
|
|
164
|
-
}
|
|
165
|
-
else if (change.type === vscode.FileChangeType.Created) {
|
|
166
|
-
readFileCache.delete(change.uri);
|
|
167
|
-
statCache.delete(change.uri);
|
|
168
|
-
const dir = change.uri.substring(0, change.uri.lastIndexOf('/'));
|
|
169
|
-
readDirectoryCache.delete(dir);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
return {
|
|
174
|
-
readFile: uri => {
|
|
175
|
-
if (!readFileCache.has(uri)) {
|
|
176
|
-
readFileCache.set(uri, fs.readFile(uri));
|
|
177
|
-
}
|
|
178
|
-
return readFileCache.get(uri);
|
|
179
|
-
},
|
|
180
|
-
stat: uri => {
|
|
181
|
-
if (!statCache.has(uri)) {
|
|
182
|
-
statCache.set(uri, fs.stat(uri));
|
|
183
|
-
}
|
|
184
|
-
return statCache.get(uri);
|
|
185
|
-
},
|
|
186
|
-
readDirectory: uri => {
|
|
187
|
-
if (!readDirectoryCache.has(uri)) {
|
|
188
|
-
readDirectoryCache.set(uri, fs.readDirectory(uri));
|
|
189
|
-
}
|
|
190
|
-
return readDirectoryCache.get(uri);
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
async function createLanguageServiceHost() {
|
|
195
|
-
workspaces = (0, workspaces_js_1.createWorkspaces)({
|
|
196
|
-
...context,
|
|
197
|
-
workspaces: {
|
|
198
|
-
ts,
|
|
199
|
-
tsLocalized,
|
|
200
|
-
initParams,
|
|
201
|
-
initOptions: options,
|
|
202
|
-
documents,
|
|
203
|
-
plugins,
|
|
204
|
-
},
|
|
205
|
-
}, roots);
|
|
206
|
-
(await import('./features/customFeatures.js')).register(connection, workspaces, context.server.runtimeEnv);
|
|
207
|
-
(await import('./features/languageFeatures.js')).register(connection, workspaces, initParams, options, getSemanticTokensLegend(), context.server.runtimeEnv, documents);
|
|
208
|
-
for (const plugin of plugins) {
|
|
209
|
-
plugin.onInitialized?.(getLanguageService, context.server.runtimeEnv);
|
|
210
|
-
}
|
|
211
|
-
async function getLanguageService(uri) {
|
|
212
|
-
const project = (await workspaces.getProject(uri))?.project;
|
|
213
|
-
return project?.getLanguageService();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function getSemanticTokensLegend() {
|
|
217
|
-
if (!options.semanticTokensLegend) {
|
|
218
|
-
return index_js_1.standardSemanticTokensLegend;
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
tokenTypes: [...index_js_1.standardSemanticTokensLegend.tokenTypes, ...options.semanticTokensLegend.tokenTypes],
|
|
222
|
-
tokenModifiers: [...index_js_1.standardSemanticTokensLegend.tokenModifiers, ...options.semanticTokensLegend.tokenModifiers],
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
exports.startCommonLanguageServer = startCommonLanguageServer;
|
|
227
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ServiceEnvironment } from '@volar/language-service';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
export declare function getInferredCompilerOptions(ctx: Pick<ServiceEnvironment, 'getConfiguration' | 'onDidChangeConfiguration'> | undefined): Promise<ts.CompilerOptions>;
|
|
4
|
-
//# sourceMappingURL=inferredCompilerOptions.d.ts.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { LanguageServerPlugin, InitializationOptions } from '../../types';
|
|
2
|
-
import * as vscode from 'vscode-languageserver';
|
|
3
|
-
import { Config } from '@volar/language-service';
|
|
4
|
-
export declare function setupCapabilities(server: vscode.ServerCapabilities, initOptions: InitializationOptions, plugins: ReturnType<LanguageServerPlugin>[], semanticTokensLegend: vscode.SemanticTokensLegend, services: NonNullable<Config['services']>): void;
|
|
5
|
-
//# sourceMappingURL=registerFeatures.d.ts.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadConfig = void 0;
|
|
4
|
-
function loadConfig(console, dir, configFile) {
|
|
5
|
-
let configPath;
|
|
6
|
-
try {
|
|
7
|
-
configPath = require.resolve(configFile ?? './volar.config.js', { paths: [dir] });
|
|
8
|
-
}
|
|
9
|
-
catch { }
|
|
10
|
-
try {
|
|
11
|
-
if (configPath) {
|
|
12
|
-
const config = require(configPath);
|
|
13
|
-
delete require.cache[configPath];
|
|
14
|
-
return config;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
console.warn(String(err));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.loadConfig = loadConfig;
|
|
22
|
-
//# sourceMappingURL=serverConfig.js.map
|