@volar/language-server 1.10.0 → 1.10.2

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.
Files changed (38) hide show
  1. package/out/browser/index.d.ts +1 -0
  2. package/out/browser/index.js +17 -2
  3. package/out/common/cancellationPipe.d.ts +1 -0
  4. package/out/common/cancellationPipe.js +24 -1
  5. package/out/common/configurationHost.d.ts +1 -0
  6. package/out/common/configurationHost.js +24 -1
  7. package/out/common/documents.d.ts +3 -0
  8. package/out/common/documents.js +24 -1
  9. package/out/common/features/customFeatures.d.ts +1 -0
  10. package/out/common/features/customFeatures.js +23 -25
  11. package/out/common/features/languageFeatures.d.ts +2 -1
  12. package/out/common/features/languageFeatures.js +36 -14
  13. package/out/common/project.d.ts +5 -2
  14. package/out/common/project.js +28 -5
  15. package/out/common/schemaRequestHandlers/http.d.ts +1 -0
  16. package/out/common/server.d.ts +2 -1
  17. package/out/common/server.js +35 -19
  18. package/out/common/utils/inferredCompilerOptions.d.ts +1 -0
  19. package/out/common/utils/isFileInDir.d.ts +1 -0
  20. package/out/common/utils/isFileInDir.js +24 -1
  21. package/out/common/utils/registerFeatures.d.ts +1 -0
  22. package/out/common/utils/registerFeatures.js +24 -1
  23. package/out/common/utils/serverConfig.d.ts +1 -0
  24. package/out/common/utils/uriMap.d.ts +3 -0
  25. package/out/common/utils/uriMap.js +28 -1
  26. package/out/common/workspaces.d.ts +1290 -894
  27. package/out/common/workspaces.js +252 -40
  28. package/out/index.d.ts +1 -0
  29. package/out/node/index.d.ts +1 -0
  30. package/out/node/index.js +18 -3
  31. package/out/protocol.d.ts +1 -0
  32. package/out/protocol.js +24 -1
  33. package/out/types.d.ts +1 -0
  34. package/package.json +6 -6
  35. package/out/common/workspace.d.ts +0 -1159
  36. package/out/common/workspace.js +0 -230
  37. package/out/node/fs.d.ts +0 -0
  38. package/out/node/fs.js +0 -1
@@ -3,3 +3,4 @@ import { LanguageServerPlugin } from '../types';
3
3
  export * from '../index';
4
4
  export declare function createConnection(): vscode.Connection;
5
5
  export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -10,14 +10,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
13
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
27
  };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
16
31
  Object.defineProperty(exports, "__esModule", { value: true });
17
32
  exports.startLanguageServer = exports.createConnection = void 0;
18
- const vscode = require("vscode-languageserver/browser");
33
+ const vscode = __importStar(require("vscode-languageserver/browser"));
19
34
  const server_1 = require("../common/server");
20
- const http_1 = require("../common/schemaRequestHandlers/http");
35
+ const http_1 = __importDefault(require("../common/schemaRequestHandlers/http"));
21
36
  const vscode_uri_1 = require("vscode-uri");
22
37
  const protocol_1 = require("../protocol");
23
38
  const language_service_1 = require("@volar/language-service");
@@ -3,3 +3,4 @@ export type CancellationTokenHost = ReturnType<typeof createCancellationTokenHos
3
3
  export declare function createCancellationTokenHost(_cancellationPipeName: string | undefined): {
4
4
  createCancellationToken(original?: vscode.CancellationToken): vscode.CancellationToken;
5
5
  };
6
+ //# sourceMappingURL=cancellationPipe.d.ts.map
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.createCancellationTokenHost = void 0;
4
- const vscode = require("vscode-languageserver");
27
+ const vscode = __importStar(require("vscode-languageserver"));
5
28
  function createCancellationTokenHost(_cancellationPipeName) {
6
29
  if (_cancellationPipeName === undefined) {
7
30
  return {
@@ -3,3 +3,4 @@ import * as vscode from 'vscode-languageserver';
3
3
  export declare function createConfigurationHost(params: vscode.InitializeParams, connection: vscode.Connection): Pick<ServiceEnvironment, 'getConfiguration' | 'onDidChangeConfiguration'> & {
4
4
  ready(): void;
5
5
  };
6
+ //# sourceMappingURL=configurationHost.d.ts.map
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.createConfigurationHost = void 0;
4
- const vscode = require("vscode-languageserver");
27
+ const vscode = __importStar(require("vscode-languageserver"));
5
28
  function createConfigurationHost(params, connection) {
6
29
  const callbacks = new Set();
7
30
  const cache = new Map();
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { TextDocument } from 'vscode-languageserver-textdocument';
2
3
  import * as vscode from 'vscode-languageserver';
3
4
  import type * as ts from 'typescript/lib/tsserverlibrary';
@@ -30,6 +31,7 @@ export declare function createDocuments(env: RuntimeEnvironment, connection: vsc
30
31
  data: {
31
32
  clear: () => void;
32
33
  values: () => IterableIterator<IncrementalScriptSnapshot>;
34
+ uriKeys: () => IterableIterator<string>;
33
35
  uriDelete: (_uri: string) => boolean;
34
36
  uriGet: (_uri: string) => IncrementalScriptSnapshot | undefined;
35
37
  uriHas: (_uri: string) => boolean;
@@ -43,3 +45,4 @@ export declare function createDocuments(env: RuntimeEnvironment, connection: vsc
43
45
  onDidClose: (cb: (params: vscode.DidCloseTextDocumentParams) => void) => vscode.Disposable;
44
46
  };
45
47
  export {};
48
+ //# sourceMappingURL=documents.d.ts.map
@@ -1,8 +1,31 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
4
27
  const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
5
- const vscode = require("vscode-languageserver");
28
+ const vscode = __importStar(require("vscode-languageserver"));
6
29
  const uriMap_1 = require("./utils/uriMap");
7
30
  class IncrementalScriptSnapshot {
8
31
  constructor(uri, languageId, version, text) {
@@ -2,3 +2,4 @@ import * as vscode from 'vscode-languageserver';
2
2
  import { RuntimeEnvironment } from '../../types';
3
3
  import type { Workspaces } from '../workspaces';
4
4
  export declare function register(connection: vscode.Connection, workspaces: Workspaces, env: RuntimeEnvironment): void;
5
+ //# sourceMappingURL=customFeatures.d.ts.map
@@ -54,10 +54,10 @@ function register(connection, workspaces, env) {
54
54
  }
55
55
  });
56
56
  connection.onNotification(protocol_1.ReloadProjectNotification.type, () => {
57
- workspaces.reloadProject();
57
+ workspaces.reloadProjects();
58
58
  });
59
59
  connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
60
- const fs = await Promise.resolve().then(() => require('fs'));
60
+ const fs = await import('fs');
61
61
  const project = await workspaces.getProject(params.uri);
62
62
  if (project) {
63
63
  const ls = (await project.project)?.getLanguageServiceDontCreate();
@@ -87,31 +87,29 @@ function register(connection, workspaces, env) {
87
87
  });
88
88
  connection.onRequest(protocol_1.LoadedTSFilesMetaRequest.type, async () => {
89
89
  const sourceFilesData = new Map();
90
- for (const workspace of workspaces.workspaces.values()) {
91
- for (const _project of (await workspace).projects.values()) {
92
- const project = await _project;
93
- const service = project.getLanguageServiceDontCreate();
94
- const languageService = service?.context.inject('typescript/languageService');
95
- const program = languageService?.getProgram();
96
- if (program) {
97
- const projectName = typeof project.tsConfig === 'string' ? project.tsConfig : (project.languageHost.workspacePath + '(inferred)');
98
- const sourceFiles = program?.getSourceFiles() ?? [];
99
- for (const sourceFile of sourceFiles) {
100
- if (!sourceFilesData.has(sourceFile)) {
101
- let nodes = 0;
102
- sourceFile.forEachChild(function walk(node) {
103
- nodes++;
104
- node.forEachChild(walk);
105
- });
106
- sourceFilesData.set(sourceFile, {
107
- projectNames: [],
108
- size: nodes * 128,
109
- });
110
- }
111
- sourceFilesData.get(sourceFile).projectNames.push(projectName);
90
+ for (const _project of [...workspaces.configProjects.values(), ...workspaces.inferredProjects.values()]) {
91
+ const project = await _project;
92
+ const service = project.getLanguageServiceDontCreate();
93
+ const languageService = service?.context.inject('typescript/languageService');
94
+ const program = languageService?.getProgram();
95
+ if (program) {
96
+ const projectName = typeof project.tsConfig === 'string' ? project.tsConfig : (project.languageHost.workspacePath + '(inferred)');
97
+ const sourceFiles = program?.getSourceFiles() ?? [];
98
+ for (const sourceFile of sourceFiles) {
99
+ if (!sourceFilesData.has(sourceFile)) {
100
+ let nodes = 0;
101
+ sourceFile.forEachChild(function walk(node) {
102
+ nodes++;
103
+ node.forEachChild(walk);
104
+ });
105
+ sourceFilesData.set(sourceFile, {
106
+ projectNames: [],
107
+ size: nodes * 128,
108
+ });
112
109
  }
113
- ;
110
+ sourceFilesData.get(sourceFile).projectNames.push(projectName);
114
111
  }
112
+ ;
115
113
  }
116
114
  }
117
115
  const result = {
@@ -3,5 +3,6 @@ import { CancellationTokenHost } from '../cancellationPipe';
3
3
  import type { Workspaces } from '../workspaces';
4
4
  import { RuntimeEnvironment, InitializationOptions } from '../../types';
5
5
  import { createDocuments } from '../documents';
6
- export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, initOptions: InitializationOptions, cancelHost: CancellationTokenHost, semanticTokensLegend: vscode.SemanticTokensLegend, runtime: RuntimeEnvironment, documents: ReturnType<typeof createDocuments>): void;
6
+ export declare function register(connection: vscode.Connection, workspaces: Workspaces, initParams: vscode.InitializeParams, initOptions: InitializationOptions, cancelHost: CancellationTokenHost, semanticTokensLegend: vscode.SemanticTokensLegend, runtime: RuntimeEnvironment, documents: ReturnType<typeof createDocuments>): void;
7
7
  export declare function sleep(ms: number): Promise<unknown>;
8
+ //# sourceMappingURL=languageFeatures.d.ts.map
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.sleep = exports.register = void 0;
4
- const embedded = require("@volar/language-service");
5
- const vscode = require("vscode-languageserver");
27
+ const embedded = __importStar(require("@volar/language-service"));
28
+ const vscode = __importStar(require("vscode-languageserver"));
6
29
  const protocol_1 = require("../../protocol");
7
30
  const types_1 = require("../../types");
8
- function register(connection, projects, initParams, initOptions, cancelHost, semanticTokensLegend, runtime, documents) {
31
+ function register(connection, workspaces, initParams, initOptions, cancelHost, semanticTokensLegend, runtime, documents) {
9
32
  let lastCompleteUri;
10
33
  let lastCompleteLs;
11
34
  let lastCodeLensLs;
@@ -195,16 +218,15 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
195
218
  });
196
219
  connection.onWorkspaceSymbol(async (params, token) => {
197
220
  let results = [];
198
- for (const _workspace of projects.workspaces.values()) {
199
- const workspace = await _workspace;
200
- let projects = [...workspace.projects.values()];
201
- projects = projects.length ? projects : [workspace.getInferredProject()];
202
- for (const project of projects) {
203
- if (token.isCancellationRequested)
204
- return;
205
- const service = (await project).getLanguageService();
206
- results = results.concat(await service.findWorkspaceSymbols(params.query, token));
207
- }
221
+ let projects = [...workspaces.configProjects.values()];
222
+ if (!projects.length) {
223
+ projects = [...workspaces.inferredProjects.values()];
224
+ }
225
+ for (const project of projects) {
226
+ if (token.isCancellationRequested)
227
+ return;
228
+ const service = (await project).getLanguageService();
229
+ results = results.concat(await service.findWorkspaceSymbols(params.query, token));
208
230
  }
209
231
  return results;
210
232
  });
@@ -312,7 +334,7 @@ function register(connection, projects, initParams, initOptions, cancelHost, sem
312
334
  });
313
335
  }
314
336
  async function getProject(uri) {
315
- return (await projects.getProject(uri))?.project;
337
+ return (await workspaces.getProject(uri))?.project;
316
338
  }
317
339
  function fixTextEdit(item) {
318
340
  const insertReplaceSupport = initParams.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
@@ -3,9 +3,10 @@ import * as path from 'typesafe-path/posix';
3
3
  import type * as ts from 'typescript/lib/tsserverlibrary';
4
4
  import * as vscode from 'vscode-languageserver';
5
5
  import { URI } from 'vscode-uri';
6
- import { WorkspaceContext } from './workspace';
7
- export interface ProjectContext extends WorkspaceContext {
6
+ import { WorkspacesContext } from './workspaces';
7
+ export interface ProjectContext extends WorkspacesContext {
8
8
  project: {
9
+ workspaceUri: URI;
9
10
  rootUri: URI;
10
11
  tsConfig: path.PosixPath | ts.CompilerOptions;
11
12
  };
@@ -126,6 +127,7 @@ export declare function createProject(context: ProjectContext): Promise<{
126
127
  askedFiles: {
127
128
  clear: () => void;
128
129
  values: () => IterableIterator<boolean>;
130
+ uriKeys: () => IterableIterator<string>;
129
131
  uriDelete: (_uri: string) => boolean;
130
132
  uriGet: (_uri: string) => boolean | undefined;
131
133
  uriHas: (_uri: string) => boolean;
@@ -137,3 +139,4 @@ export declare function createProject(context: ProjectContext): Promise<{
137
139
  };
138
140
  dispose: () => void;
139
141
  }>;
142
+ //# sourceMappingURL=project.d.ts.map
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.createProject = void 0;
4
27
  const language_service_1 = require("@volar/language-service");
5
- const path = require("typesafe-path/posix");
6
- const vscode = require("vscode-languageserver");
28
+ const path = __importStar(require("typesafe-path/posix"));
29
+ const vscode = __importStar(require("vscode-languageserver"));
7
30
  const serverConfig_1 = require("./utils/serverConfig");
8
31
  const uriMap_1 = require("./utils/uriMap");
9
32
  const typescript_1 = require("@volar/typescript");
@@ -25,7 +48,7 @@ async function createProject(context) {
25
48
  fs,
26
49
  console: context.server.runtimeEnv.console,
27
50
  locale: context.workspaces.initParams.locale,
28
- workspaceUri: context.workspace.rootUri,
51
+ workspaceUri: context.project.workspaceUri,
29
52
  rootUri: context.project.rootUri,
30
53
  clientCapabilities: context.workspaces.initParams.capabilities,
31
54
  getConfiguration: context.server.configurationHost?.getConfiguration,
@@ -37,7 +60,7 @@ async function createProject(context) {
37
60
  }
38
61
  const askedFiles = (0, uriMap_1.createUriMap)(fileNameToUri);
39
62
  const languageHost = {
40
- workspacePath: uriToFileName(context.workspace.rootUri.toString()),
63
+ workspacePath: uriToFileName(context.project.workspaceUri.toString()),
41
64
  rootPath: uriToFileName(context.project.rootUri.toString()),
42
65
  getProjectVersion: () => projectVersion.toString(),
43
66
  getScriptFileNames: () => parsedCommandLine.fileNames,
@@ -72,7 +95,7 @@ async function createProject(context) {
72
95
  }
73
96
  }
74
97
  let parsedCommandLine = await createParsedCommandLine(context.workspaces.ts, env, uriToFileName(context.project.rootUri.toString()), context.project.tsConfig, context.workspaces.plugins, existingOptions);
75
- let config = (context.workspace.rootUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.server.runtimeEnv.console, context.server.runtimeEnv.uriToFileName(context.workspace.rootUri.toString()), context.workspaces.initOptions.configFilePath) : {}) ?? {};
98
+ 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
99
  for (const plugin of context.workspaces.plugins) {
77
100
  if (plugin.resolveConfig) {
78
101
  config = await plugin.resolveConfig(config, {
@@ -1 +1,2 @@
1
1
  export default function handler(uri: string): Promise<string | undefined>;
2
+ //# sourceMappingURL=http.d.ts.map
@@ -11,4 +11,5 @@ export interface ServerContext {
11
11
  configurationHost: ReturnType<typeof createConfigurationHost> | undefined;
12
12
  };
13
13
  }
14
- export declare function startCommonLanguageServer(connection: vscode.Connection, _plugins: LanguageServerPlugin[], getRuntimeEnv: (params: vscode.InitializeParams, options: InitializationOptions) => RuntimeEnvironment): Promise<void>;
14
+ export declare function startCommonLanguageServer(connection: vscode.Connection, _plugins: LanguageServerPlugin[], getRuntimeEnv: (params: vscode.InitializeParams, options: InitializationOptions) => RuntimeEnvironment): void;
15
+ //# sourceMappingURL=server.d.ts.map
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.startCommonLanguageServer = void 0;
4
27
  const language_service_1 = require("@volar/language-service");
5
- const l10n = require("@vscode/l10n");
6
- const vscode = require("vscode-languageserver");
28
+ const l10n = __importStar(require("@vscode/l10n"));
29
+ const vscode = __importStar(require("vscode-languageserver"));
7
30
  const vscode_uri_1 = require("vscode-uri");
8
31
  const types_1 = require("../types");
9
32
  const cancellationPipe_1 = require("./cancellationPipe");
@@ -13,11 +36,11 @@ const registerFeatures_1 = require("./utils/registerFeatures");
13
36
  const serverConfig_1 = require("./utils/serverConfig");
14
37
  const workspaces_1 = require("./workspaces");
15
38
  const request_light_1 = require("request-light");
16
- async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
39
+ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
17
40
  let initParams;
18
41
  let options;
19
42
  let roots = [];
20
- let projects;
43
+ let workspaces;
21
44
  let plugins;
22
45
  let documents;
23
46
  let context;
@@ -109,10 +132,10 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
109
132
  if (initParams.capabilities.workspace?.workspaceFolders) {
110
133
  connection.workspace.onDidChangeWorkspaceFolders(e => {
111
134
  for (const folder of e.added) {
112
- projects?.add(vscode_uri_1.URI.parse(folder.uri));
135
+ workspaces?.add(vscode_uri_1.URI.parse(folder.uri));
113
136
  }
114
137
  for (const folder of e.removed) {
115
- projects?.remove(vscode_uri_1.URI.parse(folder.uri));
138
+ workspaces?.remove(vscode_uri_1.URI.parse(folder.uri));
116
139
  }
117
140
  });
118
141
  }
@@ -140,11 +163,7 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
140
163
  }
141
164
  });
142
165
  connection.onShutdown(async () => {
143
- if (projects) {
144
- for (const workspace of projects.workspaces) {
145
- (await workspace[1]).dispose();
146
- }
147
- }
166
+ workspaces?.reloadProjects();
148
167
  });
149
168
  connection.listen();
150
169
  function createFsWithCache(fs) {
@@ -196,7 +215,7 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
196
215
  const ts = options.typescript ? context.server.runtimeEnv.loadTypescript(options.typescript.tsdk) : undefined;
197
216
  const tsLocalized = options.typescript && initParams.locale ? await context.server.runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, initParams.locale) : undefined;
198
217
  const cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
199
- projects = (0, workspaces_1.createWorkspaces)({
218
+ workspaces = (0, workspaces_1.createWorkspaces)({
200
219
  ...context,
201
220
  workspaces: {
202
221
  ts,
@@ -207,17 +226,14 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
207
226
  cancelTokenHost,
208
227
  plugins,
209
228
  },
210
- });
211
- for (const root of roots) {
212
- projects.add(root);
213
- }
214
- (await Promise.resolve().then(() => require('./features/customFeatures'))).register(connection, projects, context.server.runtimeEnv);
215
- (await Promise.resolve().then(() => require('./features/languageFeatures'))).register(connection, projects, initParams, options, cancelTokenHost, getSemanticTokensLegend(), context.server.runtimeEnv, documents);
229
+ }, roots);
230
+ (await import('./features/customFeatures.js')).register(connection, workspaces, context.server.runtimeEnv);
231
+ (await import('./features/languageFeatures.js')).register(connection, workspaces, initParams, options, cancelTokenHost, getSemanticTokensLegend(), context.server.runtimeEnv, documents);
216
232
  for (const plugin of plugins) {
217
233
  plugin.onInitialized?.(getLanguageService, context.server.runtimeEnv);
218
234
  }
219
235
  async function getLanguageService(uri) {
220
- const project = (await projects.getProject(uri))?.project;
236
+ const project = (await workspaces.getProject(uri))?.project;
221
237
  return project?.getLanguageService();
222
238
  }
223
239
  }
@@ -1,3 +1,4 @@
1
1
  import { ServiceEnvironment } from '@volar/language-service';
2
2
  import type * as ts from 'typescript/lib/tsserverlibrary';
3
3
  export declare function getInferredCompilerOptions(ctx: Pick<ServiceEnvironment, 'getConfiguration' | 'onDidChangeConfiguration'> | undefined): Promise<ts.CompilerOptions>;
4
+ //# sourceMappingURL=inferredCompilerOptions.d.ts.map
@@ -1,2 +1,3 @@
1
1
  import * as path from 'typesafe-path';
2
2
  export declare function isFileInDir(fileName: path.OsPath | path.PosixPath, dir: path.OsPath | path.PosixPath): boolean;
3
+ //# sourceMappingURL=isFileInDir.d.ts.map
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.isFileInDir = void 0;
4
- const path = require("typesafe-path");
27
+ const path = __importStar(require("typesafe-path"));
5
28
  function isFileInDir(fileName, dir) {
6
29
  const relative = path.relative(dir, fileName);
7
30
  return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
@@ -2,3 +2,4 @@ import { LanguageServerPlugin, InitializationOptions } from '../../types';
2
2
  import * as vscode from 'vscode-languageserver';
3
3
  import { Config } from '@volar/language-service';
4
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,8 +1,31 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.setupCapabilities = void 0;
4
27
  const types_1 = require("../../types");
5
- const vscode = require("vscode-languageserver");
28
+ const vscode = __importStar(require("vscode-languageserver"));
6
29
  function setupCapabilities(server, initOptions, plugins, semanticTokensLegend, services) {
7
30
  const serviceInstances = Object.values(services)
8
31
  .map(service => typeof service === 'function' ? service(undefined, undefined) : service)
@@ -1,2 +1,3 @@
1
1
  import type { Config, Console } from '@volar/language-service';
2
2
  export declare function loadConfig(console: Console, dir: string, configFile: string | undefined): Config | undefined;
3
+ //# sourceMappingURL=serverConfig.d.ts.map
@@ -6,10 +6,12 @@ interface Options<T> {
6
6
  set(key: string, value: T): void;
7
7
  clear(): void;
8
8
  values(): IterableIterator<T>;
9
+ keys(): IterableIterator<string>;
9
10
  }
10
11
  export declare function createUriMap<T>(fileNameToUri: (fileName: string) => string, map?: Options<T>): {
11
12
  clear: () => void;
12
13
  values: () => IterableIterator<T>;
14
+ uriKeys: () => IterableIterator<string>;
13
15
  uriDelete: (_uri: string) => boolean;
14
16
  uriGet: (_uri: string) => T | undefined;
15
17
  uriHas: (_uri: string) => boolean;
@@ -19,3 +21,4 @@ export declare function createUriMap<T>(fileNameToUri: (fileName: string) => str
19
21
  pathHas: (path: string) => T | undefined;
20
22
  pathSet: (path: string, item: T) => void;
21
23
  };
24
+ //# sourceMappingURL=uriMap.d.ts.map