@volar/language-server 1.0.8 → 1.0.9

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.
@@ -15,6 +15,57 @@ const vscode = require("vscode-languageserver");
15
15
  const protocol_1 = require("../protocol");
16
16
  const language_core_1 = require("@volar/language-core");
17
17
  function register(connection, projects) {
18
+ connection.onNotification(protocol_1.ReportStats.type, () => __awaiter(this, void 0, void 0, function* () {
19
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
20
+ for (const [rootUri, _workspace] of projects.workspaces) {
21
+ console.log('workspace: ' + rootUri);
22
+ const workspace = yield _workspace;
23
+ console.log('documentRegistry stats: ' + workspace.documentRegistry.reportStats());
24
+ console.log('');
25
+ console.log('tsconfig: inferred');
26
+ const _inferredProject = workspace.getInferredProjectDontCreate();
27
+ if (_inferredProject) {
28
+ console.log('loaded: true');
29
+ const inferredProject = yield _inferredProject;
30
+ console.log('largest 10 files:');
31
+ for (const script of [...inferredProject.scripts.values()]
32
+ .sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.snapshot) === null || _c === void 0 ? void 0 : _c.getLength()) !== null && _d !== void 0 ? _d : 0); })
33
+ .slice(0, 10)) {
34
+ console.log(' - ' + script.fileName);
35
+ console.log(` size: ${(_a = script.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()}`);
36
+ }
37
+ console.log('files:');
38
+ for (const script of inferredProject.scripts.values()) {
39
+ console.log(' - ' + script.fileName);
40
+ console.log(` size: ${(_b = script.snapshot) === null || _b === void 0 ? void 0 : _b.getLength()}`);
41
+ console.log(` ref counts: "${(_d = (_c = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _d === void 0 ? void 0 : _d.call(_c, script.fileName, (_f = (_e = inferredProject.languageServiceHost).getScriptKind) === null || _f === void 0 ? void 0 : _f.call(_e, script.fileName))})"`);
42
+ }
43
+ }
44
+ else {
45
+ console.log('loaded: false');
46
+ }
47
+ console.log('');
48
+ for (const _project of workspace.projects.values()) {
49
+ const project = yield _project;
50
+ console.log('tsconfig: ' + project.tsConfig);
51
+ console.log('loaded: ' + !!project.getLanguageServiceDontCreate());
52
+ console.log('largest 10 files:');
53
+ for (const script of [...project.scripts.values()]
54
+ .sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.snapshot) === null || _a === void 0 ? void 0 : _a.getLength()) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.snapshot) === null || _c === void 0 ? void 0 : _c.getLength()) !== null && _d !== void 0 ? _d : 0); })
55
+ .slice(0, 10)) {
56
+ console.log(' - ' + script.fileName);
57
+ console.log(` size: ${(_g = script.snapshot) === null || _g === void 0 ? void 0 : _g.getLength()}`);
58
+ }
59
+ console.log('files:');
60
+ for (const script of project.scripts.values()) {
61
+ console.log(' - ' + script.fileName);
62
+ console.log(` size: ${(_h = script.snapshot) === null || _h === void 0 ? void 0 : _h.getLength()}`);
63
+ console.log(` ref counts: "${(_k = (_j = workspace.documentRegistry).getLanguageServiceRefCounts) === null || _k === void 0 ? void 0 : _k.call(_j, script.fileName, (_m = (_l = project.languageServiceHost).getScriptKind) === null || _m === void 0 ? void 0 : _m.call(_l, script.fileName))})"`);
64
+ }
65
+ }
66
+ console.log('');
67
+ }
68
+ }));
18
69
  connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
19
70
  const project = (yield projects.getProject(params.uri));
20
71
  if (project) {
@@ -24,11 +75,11 @@ function register(connection, projects) {
24
75
  }
25
76
  }));
26
77
  connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
27
- var _a, _b;
78
+ var _o, _p;
28
79
  const project = yield projects.getProject(document.uri);
29
80
  const fileNames = [];
30
81
  if (project) {
31
- const sourceFile = (_b = (_a = project.project) === null || _a === void 0 ? void 0 : _a.getLanguageService().context.core.mapper.get(shared.getPathOfUri(document.uri))) === null || _b === void 0 ? void 0 : _b[0];
82
+ 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];
32
83
  if (sourceFile) {
33
84
  (0, language_core_1.forEachEmbeddeds)(sourceFile.embeddeds, e => {
34
85
  if (e.text && e.kind === 1) {
@@ -40,10 +91,10 @@ function register(connection, projects) {
40
91
  return fileNames;
41
92
  }));
42
93
  connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
43
- var _c, _d;
94
+ var _q, _r;
44
95
  const project = yield projects.getProject(params.sourceFileUri);
45
96
  if (project) {
46
- const embeddedFile = (_d = (_c = project.project) === null || _c === void 0 ? void 0 : _c.getLanguageService().context.core.mapper.fromEmbeddedFileName(params.virtualFileName)) === null || _d === void 0 ? void 0 : _d.embedded;
97
+ const embeddedFile = (_r = (_q = project.project) === null || _q === void 0 ? void 0 : _q.getLanguageService().context.core.mapper.fromEmbeddedFileName(params.virtualFileName)) === null || _r === void 0 ? void 0 : _r.embedded;
47
98
  if (embeddedFile) {
48
99
  return {
49
100
  content: embeddedFile.text,
@@ -56,11 +107,11 @@ function register(connection, projects) {
56
107
  projects.reloadProject();
57
108
  }));
58
109
  connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
59
- var _e;
110
+ var _s;
60
111
  const fs = yield Promise.resolve().then(() => require('fs'));
61
112
  const project = yield projects.getProject(params.uri);
62
113
  if (project) {
63
- const ls = (_e = (yield project.project)) === null || _e === void 0 ? void 0 : _e.getLanguageServiceDontCreate();
114
+ const ls = (_s = (yield project.project)) === null || _s === void 0 ? void 0 : _s.getLanguageServiceDontCreate();
64
115
  if (ls) {
65
116
  const sourceFiles = new Set(ls.context.host.getScriptFileNames());
66
117
  for (const virtualFile of ls.context.core.typescriptLanguageServiceHost.getScriptFileNames()) {
@@ -75,14 +126,14 @@ function register(connection, projects) {
75
126
  }
76
127
  }));
77
128
  connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
78
- var _f;
129
+ var _t;
79
130
  let errors = 0;
80
131
  let warnings = 0;
81
132
  const progress = yield connection.window.createWorkDoneProgress();
82
133
  progress.begin('Verify', 0, '', true);
83
134
  const project = yield projects.getProject(params.uri);
84
135
  if (project) {
85
- const ls = (_f = (yield project.project)) === null || _f === void 0 ? void 0 : _f.getLanguageServiceDontCreate();
136
+ const ls = (_t = (yield project.project)) === null || _t === void 0 ? void 0 : _t.getLanguageServiceDontCreate();
86
137
  if (ls) {
87
138
  const allVueDocuments = ls.context.documents.getAll();
88
139
  let i = 0;
@@ -1,4 +1,4 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
- import { CancellactionTokenHost } from '../utils/cancellationPipe';
2
+ import { CancellationTokenHost } from '../utils/cancellationPipe';
3
3
  import type { Workspaces } from '../utils/workspaces';
4
- export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellactionTokenHost): void;
4
+ export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellationTokenHost): void;
@@ -13,6 +13,7 @@ const embedded = require("@volar/language-service");
13
13
  const vscode = require("vscode-languageserver");
14
14
  const protocol_1 = require("../protocol");
15
15
  const shared = require("@volar/shared");
16
+ const registerFeatures_1 = require("../registerFeatures");
16
17
  function register(connection, projects, initParams, cancelHost) {
17
18
  let lastCompleteUri;
18
19
  let lastCompleteLs;
@@ -180,7 +181,7 @@ function register(connection, projects, initParams, cancelHost) {
180
181
  return buildTokens([]);
181
182
  return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
182
183
  var _k;
183
- const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
184
+ const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, registerFeatures_1.semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
184
185
  return buildTokens(result);
185
186
  }))) !== null && _j !== void 0 ? _j : buildTokens([]);
186
187
  }));
@@ -191,12 +192,12 @@ function register(connection, projects, initParams, cancelHost) {
191
192
  return buildTokens([]);
192
193
  return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
193
194
  var _m;
194
- const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
195
+ const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, registerFeatures_1.semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
195
196
  return buildTokens(result);
196
197
  }))) !== null && _l !== void 0 ? _l : buildTokens([]);
197
198
  }));
198
199
  connection.languages.diagnostics.on((params, token, workDoneProgressReporter, resultProgressReporter) => __awaiter(this, void 0, void 0, function* () {
199
- token = cancelHost.createCancellactionToken(token);
200
+ token = cancelHost.createCancellationToken(token);
200
201
  const result = yield worker(params.textDocument.uri, vueLs => {
201
202
  return vueLs.doValidation(params.textDocument.uri, token, errors => {
202
203
  // resultProgressReporter is undefined in vscode
package/out/protocol.d.ts CHANGED
@@ -74,6 +74,9 @@ export declare namespace GetVirtualFileRequest {
74
74
  type ErrorType = never;
75
75
  const type: vscode.RequestType<ParamsType, ResponseType, never>;
76
76
  }
77
+ export declare namespace ReportStats {
78
+ const type: vscode.NotificationType0;
79
+ }
77
80
  /**
78
81
  * FS request for browser
79
82
  */
package/out/protocol.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.ShowReferencesNotification = void 0;
2
+ exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.ShowReferencesNotification = void 0;
3
3
  const vscode = require("vscode-languageserver-protocol");
4
4
  /**
5
5
  * Server request client
@@ -43,6 +43,10 @@ var GetVirtualFileRequest;
43
43
  (function (GetVirtualFileRequest) {
44
44
  GetVirtualFileRequest.type = new vscode.RequestType('vue/virtualFile');
45
45
  })(GetVirtualFileRequest = exports.GetVirtualFileRequest || (exports.GetVirtualFileRequest = {}));
46
+ var ReportStats;
47
+ (function (ReportStats) {
48
+ ReportStats.type = new vscode.NotificationType0('vue/stats');
49
+ })(ReportStats = exports.ReportStats || (exports.ReportStats = {}));
46
50
  /**
47
51
  * FS request for browser
48
52
  */
@@ -1,5 +1,6 @@
1
1
  import { LanguageServerPlugin, LanguageServerInitializationOptions } from './types';
2
2
  import * as vscode from 'vscode-languageserver';
3
3
  import { ClientCapabilities } from 'vscode-languageserver';
4
+ export declare const semanticTokensLegend: vscode.SemanticTokensLegend;
4
5
  export declare function setupSyntacticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities): void;
5
6
  export declare function setupSemanticCapabilities(params: ClientCapabilities, server: vscode.ServerCapabilities, options: LanguageServerInitializationOptions, plugins: ReturnType<LanguageServerPlugin>[]): void;
@@ -1,8 +1,48 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.setupSemanticCapabilities = exports.setupSyntacticCapabilities = void 0;
2
+ exports.setupSemanticCapabilities = exports.setupSyntacticCapabilities = exports.semanticTokensLegend = void 0;
3
3
  const embedded = require("@volar/language-service");
4
4
  const types_1 = require("./types");
5
5
  const vscode = require("vscode-languageserver");
6
+ // https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
7
+ exports.semanticTokensLegend = {
8
+ tokenTypes: [
9
+ 'namespace',
10
+ 'class',
11
+ 'enum',
12
+ 'interface',
13
+ 'struct',
14
+ 'typeParameter',
15
+ 'type',
16
+ 'parameter',
17
+ 'variable',
18
+ 'property',
19
+ 'enumMember',
20
+ 'decorator',
21
+ 'event',
22
+ 'function',
23
+ 'method',
24
+ 'macro',
25
+ 'label',
26
+ 'comment',
27
+ 'string',
28
+ 'keyword',
29
+ 'number',
30
+ 'regexp',
31
+ 'operator',
32
+ ],
33
+ tokenModifiers: [
34
+ 'declaration',
35
+ 'definition',
36
+ 'readonly',
37
+ 'static',
38
+ 'deprecated',
39
+ 'abstract',
40
+ 'async',
41
+ 'modification',
42
+ 'documentation',
43
+ 'defaultLibrary',
44
+ ],
45
+ };
6
46
  function setupSyntacticCapabilities(params, server) {
7
47
  var _a, _b, _c, _d, _e, _f, _g, _h;
8
48
  if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.selectionRange) {
@@ -36,7 +76,7 @@ function setupSyntacticCapabilities(params, server) {
36
76
  }
37
77
  exports.setupSyntacticCapabilities = setupSyntacticCapabilities;
38
78
  function setupSemanticCapabilities(params, server, options, plugins) {
39
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
40
80
  if ((_a = params.textDocument) === null || _a === void 0 ? void 0 : _a.references) {
41
81
  server.referencesProvider = true;
42
82
  }
@@ -67,7 +107,11 @@ function setupSemanticCapabilities(params, server, options, plugins) {
67
107
  filters: [
68
108
  ...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: { glob: `**/*.${ext.extension}` } }))).flat(),
69
109
  { pattern: { glob: '**/*.js' } },
110
+ { pattern: { glob: '**/*.cjs' } },
111
+ { pattern: { glob: '**/*.mjs' } },
70
112
  { pattern: { glob: '**/*.ts' } },
113
+ { pattern: { glob: '**/*.cts' } },
114
+ { pattern: { glob: '**/*.mts' } },
71
115
  { pattern: { glob: '**/*.jsx' } },
72
116
  { pattern: { glob: '**/*.tsx' } },
73
117
  { pattern: { glob: '**/*.json' } },
@@ -128,19 +172,10 @@ function setupSemanticCapabilities(params, server, options, plugins) {
128
172
  server.semanticTokensProvider = {
129
173
  range: true,
130
174
  full: false,
131
- legend: {
132
- tokenModifiers: [],
133
- tokenTypes: [],
134
- },
175
+ legend: exports.semanticTokensLegend,
135
176
  };
136
- for (const plugin of plugins) {
137
- if ((_u = plugin.semanticService) === null || _u === void 0 ? void 0 : _u.semanticTokenLegend) {
138
- server.semanticTokensProvider.legend.tokenModifiers = server.semanticTokensProvider.legend.tokenModifiers.concat(plugin.semanticService.semanticTokenLegend.tokenModifiers);
139
- server.semanticTokensProvider.legend.tokenTypes = server.semanticTokensProvider.legend.tokenTypes.concat(plugin.semanticService.semanticTokenLegend.tokenTypes);
140
- }
141
- }
142
177
  }
143
- if ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.codeAction) {
178
+ if ((_u = params.textDocument) === null || _u === void 0 ? void 0 : _u.codeAction) {
144
179
  server.codeActionProvider = {
145
180
  codeActionKinds: [
146
181
  vscode.CodeActionKind.Empty,
@@ -156,10 +191,10 @@ function setupSemanticCapabilities(params, server, options, plugins) {
156
191
  resolveProvider: true,
157
192
  };
158
193
  }
159
- if ((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.inlayHint) {
194
+ if ((_v = params.textDocument) === null || _v === void 0 ? void 0 : _v.inlayHint) {
160
195
  server.inlayHintProvider = true;
161
196
  }
162
- if (((_x = params.textDocument) === null || _x === void 0 ? void 0 : _x.diagnostic) && ((_y = options.diagnosticModel) !== null && _y !== void 0 ? _y : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
197
+ if (((_w = params.textDocument) === null || _w === void 0 ? void 0 : _w.diagnostic) && ((_x = options.diagnosticModel) !== null && _x !== void 0 ? _x : types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
163
198
  server.diagnosticProvider = {
164
199
  documentSelector: [
165
200
  ...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ pattern: `**/*.${ext.extension}` }))).flat(),
package/out/server.js CHANGED
@@ -50,7 +50,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
50
50
  configHost = ((_c = params.capabilities.workspace) === null || _c === void 0 ? void 0 : _c.configuration) ? (0, configurationHost_1.createConfigurationHost)(params, connection) : undefined;
51
51
  const serverMode = (_d = options.serverMode) !== null && _d !== void 0 ? _d : types_1.ServerMode.Semantic;
52
52
  (0, registerFeatures_1.setupSyntacticCapabilities)(params.capabilities, result.capabilities);
53
- yield createDocumenntServiceHost();
53
+ yield _createDocumentServiceHost();
54
54
  if (serverMode === types_1.ServerMode.Semantic) {
55
55
  (0, registerFeatures_1.setupSemanticCapabilities)(params.capabilities, result.capabilities, options, plugins);
56
56
  yield createLanguageServiceHost();
@@ -67,7 +67,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
67
67
  return result;
68
68
  }));
69
69
  connection.onInitialized(() => __awaiter(this, void 0, void 0, function* () {
70
- var _f;
70
+ var _f, _g, _h;
71
71
  fsHost === null || fsHost === void 0 ? void 0 : fsHost.ready(connection);
72
72
  configHost === null || configHost === void 0 ? void 0 : configHost.ready();
73
73
  if ((_f = params.capabilities.workspace) === null || _f === void 0 ? void 0 : _f.workspaceFolders) {
@@ -82,9 +82,25 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
82
82
  }
83
83
  });
84
84
  }
85
+ if ((_h = (_g = params.capabilities.workspace) === null || _g === void 0 ? void 0 : _g.didChangeWatchedFiles) === null || _h === void 0 ? void 0 : _h.dynamicRegistration) {
86
+ connection.client.register(vscode.DidChangeWatchedFilesNotification.type, {
87
+ watchers: [
88
+ ...plugins.map(plugin => plugin.extraFileExtensions.map(ext => ({ globPattern: `**/*.${ext.extension}` }))).flat(),
89
+ { globPattern: '**/*.js' },
90
+ { globPattern: '**/*.cjs' },
91
+ { globPattern: '**/*.mjs' },
92
+ { globPattern: '**/*.ts' },
93
+ { globPattern: '**/*.cts' },
94
+ { globPattern: '**/*.mts' },
95
+ { globPattern: '**/*.jsx' },
96
+ { globPattern: '**/*.tsx' },
97
+ { globPattern: '**/*.json' },
98
+ ]
99
+ });
100
+ }
85
101
  }));
86
102
  connection.listen();
87
- function createDocumenntServiceHost() {
103
+ function _createDocumentServiceHost() {
88
104
  var _a, _b;
89
105
  return __awaiter(this, void 0, void 0, function* () {
90
106
  const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
@@ -104,7 +120,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
104
120
  const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
105
121
  fsHost = runtimeEnv.createFileSystemHost(ts, params.capabilities);
106
122
  const tsLocalized = params.locale ? runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
107
- const cancelTokenHost = (0, cancellationPipe_1.createCancellactionTokenHost)(options.cancellationPipeName);
123
+ const cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
108
124
  const _projects = (0, workspaces_1.createWorkspaces)(runtimeEnv, plugins, fsHost, configHost, ts, tsLocalized, params.capabilities, options, documents, connection, cancelTokenHost);
109
125
  projects = _projects;
110
126
  for (const root of roots) {
package/out/types.d.ts CHANGED
@@ -27,11 +27,10 @@ export interface RuntimeEnvironment {
27
27
  export type LanguageServerPlugin<A extends LanguageServerInitializationOptions = LanguageServerInitializationOptions, B extends embedded.LanguageServiceHost = embedded.LanguageServiceHost, C = embeddedLS.LanguageService> = (initOptions: A) => {
28
28
  extraFileExtensions: ts.FileExtensionInfo[];
29
29
  semanticService?: {
30
- semanticTokenLegend?: vscode.SemanticTokensLegend;
31
30
  resolveLanguageServiceHost?(ts: typeof import('typescript/lib/tsserverlibrary'), sys: FileSystem, tsConfig: string | ts.CompilerOptions, host: embedded.LanguageServiceHost): B;
32
31
  getLanguageModules?(host: B): embedded.LanguageModule[];
33
32
  getServicePlugins?(host: B, service: embeddedLS.LanguageService): embeddedLS.LanguageServicePlugin[];
34
- onInitialize?(connection: vscode.Connection, getLangaugeService: (uri: string) => Promise<C>): void;
33
+ onInitialize?(connection: vscode.Connection, getLanguageService: (uri: string) => Promise<C>): void;
35
34
  };
36
35
  syntacticService?: {
37
36
  getLanguageModules?(ts: typeof import('typescript/lib/tsserverlibrary'), env: embeddedLS.LanguageServicePluginContext['env']): embedded.LanguageModule[];
@@ -1,6 +1,6 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
- export type CancellactionTokenHost = ReturnType<typeof createCancellactionTokenHost>;
3
- export declare function createCancellactionTokenHost(_cancellationPipeName: string | undefined): {
4
- createCancellactionToken(original: vscode.CancellationToken): vscode.CancellationToken;
2
+ export type CancellationTokenHost = ReturnType<typeof createCancellationTokenHost>;
3
+ export declare function createCancellationTokenHost(_cancellationPipeName: string | undefined): {
4
+ createCancellationToken(original: vscode.CancellationToken): vscode.CancellationToken;
5
5
  getMtime(): number;
6
6
  };
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.createCancellactionTokenHost = void 0;
2
+ exports.createCancellationTokenHost = void 0;
3
3
  const vscode = require("vscode-languageserver");
4
- function createCancellactionTokenHost(_cancellationPipeName) {
4
+ function createCancellationTokenHost(_cancellationPipeName) {
5
5
  if (_cancellationPipeName === undefined) {
6
6
  return {
7
- createCancellactionToken(original) {
7
+ createCancellationToken(original) {
8
8
  return original;
9
9
  },
10
10
  getMtime() {
@@ -15,10 +15,10 @@ function createCancellactionTokenHost(_cancellationPipeName) {
15
15
  const cancellationPipeName = _cancellationPipeName;
16
16
  const fs = require('fs');
17
17
  return {
18
- createCancellactionToken,
18
+ createCancellationToken,
19
19
  getMtime,
20
20
  };
21
- function createCancellactionToken(original) {
21
+ function createCancellationToken(original) {
22
22
  const mtime = getMtime();
23
23
  const token = {
24
24
  get isCancellationRequested() {
@@ -40,5 +40,5 @@ function createCancellactionTokenHost(_cancellationPipeName) {
40
40
  }
41
41
  }
42
42
  }
43
- exports.createCancellactionTokenHost = createCancellactionTokenHost;
43
+ exports.createCancellationTokenHost = createCancellationTokenHost;
44
44
  //# sourceMappingURL=cancellationPipe.js.map
@@ -2,16 +2,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.loadCustomPlugins = void 0;
3
3
  function loadCustomPlugins(dir) {
4
4
  var _a;
5
+ let configPath;
5
6
  try {
6
- const configPath = require.resolve('./volar.config.js', { paths: [dir] });
7
- const config = require(configPath);
8
- // console.warn('Found', configPath, 'and loaded', config.plugins?.length, 'plugins.');
9
- return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
7
+ configPath = require.resolve('./volar.config.js', { paths: [dir] });
8
+ }
9
+ catch (_b) { }
10
+ try {
11
+ if (configPath) {
12
+ const config = require(configPath);
13
+ return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
14
+ }
10
15
  }
11
16
  catch (err) {
12
- // console.warn('No volar.config.js found in', dir);
13
- return [];
17
+ console.log(err);
14
18
  }
19
+ return [];
15
20
  }
16
21
  exports.loadCustomPlugins = loadCustomPlugins;
17
22
  //# sourceMappingURL=config.js.map
@@ -1,3 +1,4 @@
1
+ import * as shared from '@volar/shared';
1
2
  import * as embeddedLS from '@volar/language-service';
2
3
  import type * as ts from 'typescript/lib/tsserverlibrary';
3
4
  import * as vscode from 'vscode-languageserver';
@@ -6,10 +7,54 @@ import { FileSystemHost, LanguageServerInitializationOptions, LanguageServerPlug
6
7
  import { createSnapshots } from './snapshots';
7
8
  import { ConfigurationHost } from '@volar/language-service';
8
9
  import * as path from 'typesafe-path';
9
- import { CancellactionTokenHost } from './cancellationPipe';
10
+ import { CancellationTokenHost } from './cancellationPipe';
10
11
  export interface Project extends ReturnType<typeof createProject> {
11
12
  }
12
- 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: CancellactionTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
13
+ 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: ts.CompilerOptions | path.PosixPath;
15
+ scripts: {
16
+ clear: () => void;
17
+ values: () => IterableIterator<{
18
+ version: number;
19
+ fileName: string;
20
+ snapshot: ts.IScriptSnapshot | undefined;
21
+ snapshotVersion: number | undefined;
22
+ }>;
23
+ uriDelete: (_uri: string) => boolean;
24
+ uriGet: (_uri: string) => {
25
+ version: number;
26
+ fileName: string;
27
+ snapshot: ts.IScriptSnapshot | undefined;
28
+ snapshotVersion: number | undefined;
29
+ } | undefined;
30
+ uriHas: (_uri: string) => boolean;
31
+ uriSet: (_uri: string, item: {
32
+ version: number;
33
+ fileName: string;
34
+ snapshot: ts.IScriptSnapshot | undefined;
35
+ snapshotVersion: number | undefined;
36
+ }) => void;
37
+ pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
38
+ pathGet: (rootUri: shared._2.URI, path: string) => {
39
+ version: number;
40
+ fileName: string;
41
+ snapshot: ts.IScriptSnapshot | undefined;
42
+ snapshotVersion: number | undefined;
43
+ } | undefined;
44
+ pathHas: (rootUri: shared._2.URI, path: string) => {
45
+ version: number;
46
+ fileName: string;
47
+ snapshot: ts.IScriptSnapshot | undefined;
48
+ snapshotVersion: number | undefined;
49
+ } | undefined;
50
+ pathSet: (rootUri: shared._2.URI, path: string, item: {
51
+ version: number;
52
+ fileName: string;
53
+ snapshot: ts.IScriptSnapshot | undefined;
54
+ snapshotVersion: number | undefined;
55
+ }) => void;
56
+ };
57
+ languageServiceHost: embeddedLS.LanguageServiceHost;
13
58
  getLanguageService: () => {
14
59
  doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
15
60
  findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
@@ -20,12 +65,9 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
20
65
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
21
66
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
22
67
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
23
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
68
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
24
69
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
25
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
26
- isIncomplete: boolean;
27
- items: vscode.CompletionItem[];
28
- }>;
70
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
29
71
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
30
72
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
31
73
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -63,12 +105,9 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
63
105
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
64
106
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
65
107
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
66
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
108
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
67
109
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
68
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
69
- isIncomplete: boolean;
70
- items: vscode.CompletionItem[];
71
- }>;
110
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
72
111
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
73
112
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
74
113
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -97,5 +136,6 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
97
136
  context: embeddedLS.LanguageServiceRuntimeContext;
98
137
  } | undefined;
99
138
  getParsedCommandLine: () => ts.ParsedCommandLine;
139
+ tryAddFile: (fileName: string) => void;
100
140
  dispose: () => void;
101
141
  }>;
@@ -34,9 +34,18 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
34
34
  projectVersionUpdateTime = cancelTokenHost.getMtime();
35
35
  });
36
36
  return {
37
+ tsConfig,
38
+ scripts,
39
+ languageServiceHost,
37
40
  getLanguageService,
38
41
  getLanguageServiceDontCreate: () => vueLs,
39
42
  getParsedCommandLine: () => parsedCommandLine,
43
+ tryAddFile: (fileName) => {
44
+ if (!parsedCommandLine.fileNames.includes(fileName)) {
45
+ parsedCommandLine.fileNames.push(fileName);
46
+ projectVersion++;
47
+ }
48
+ },
40
49
  dispose,
41
50
  };
42
51
  function getLanguageService() {
@@ -95,6 +104,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
95
104
  const deletes = changes.filter(change => change.type === vscode.FileChangeType.Deleted);
96
105
  if (creates.length || deletes.length) {
97
106
  parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
107
+ projectVersion++;
98
108
  typeRootVersion++;
99
109
  }
100
110
  });
@@ -207,7 +217,7 @@ function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
207
217
  content = ts.parseJsonSourceFileConfigFileContent(config, sys, path.dirname(tsConfig), {}, tsConfig, undefined, extraFileExtensions);
208
218
  }
209
219
  else {
210
- content = ts.parseJsonConfigFileContent({}, sys, rootPath, tsConfig, path.join(rootPath, 'jsconfig.json'), undefined, extraFileExtensions);
220
+ content = ts.parseJsonConfigFileContent({ files: [] }, sys, rootPath, tsConfig, path.join(rootPath, 'jsconfig.json'), undefined, extraFileExtensions);
211
221
  }
212
222
  // fix https://github.com/johnsoncodehk/volar/issues/1786
213
223
  // https://github.com/microsoft/TypeScript/issues/30457
@@ -3,7 +3,7 @@ import * as vscode from 'vscode-languageserver';
3
3
  import * as shared from '@volar/shared';
4
4
  import type * as ts from 'typescript/lib/tsserverlibrary';
5
5
  interface IncrementalScriptSnapshotChange {
6
- applyed: boolean;
6
+ applied: boolean;
7
7
  changeRange: ts.TextChangeRange | undefined;
8
8
  version: number;
9
9
  contentChange: {
@@ -9,7 +9,7 @@ class IncrementalScriptSnapshot {
9
9
  this.document = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, version, text);
10
10
  this.changes = [
11
11
  {
12
- applyed: true,
12
+ applied: true,
13
13
  changeRange: undefined,
14
14
  version,
15
15
  contentChange: undefined,
@@ -24,7 +24,7 @@ class IncrementalScriptSnapshot {
24
24
  vscode_languageserver_textdocument_1.TextDocument.update(this.document, params.contentChanges, params.textDocument.version);
25
25
  this.changes = [
26
26
  {
27
- applyed: true,
27
+ applied: true,
28
28
  changeRange: undefined,
29
29
  version: params.textDocument.version,
30
30
  contentChange: undefined,
@@ -65,7 +65,7 @@ class IncrementalScriptSnapshot {
65
65
  getDocument() {
66
66
  this.clearUnReferenceVersions();
67
67
  const lastChange = this.changes[this.changes.length - 1];
68
- if (!lastChange.applyed) {
68
+ if (!lastChange.applied) {
69
69
  this.applyVersionToRootDocument(lastChange.version, false);
70
70
  }
71
71
  return this.document;
@@ -94,7 +94,7 @@ class IncrementalScriptSnapshot {
94
94
  if (change.version > version) {
95
95
  break;
96
96
  }
97
- if (!change.applyed) {
97
+ if (!change.applied) {
98
98
  if (change.contentChange) {
99
99
  change.changeRange = {
100
100
  span: {
@@ -105,7 +105,7 @@ class IncrementalScriptSnapshot {
105
105
  };
106
106
  vscode_languageserver_textdocument_1.TextDocument.update(this.document, [change.contentChange], change.version);
107
107
  }
108
- change.applyed = true;
108
+ change.applied = true;
109
109
  }
110
110
  removeEnd = i + 1;
111
111
  }
@@ -158,7 +158,7 @@ function createSnapshots(connection) {
158
158
  if (params.contentChanges.every(vscode.TextDocumentContentChangeEvent.isIncremental)) {
159
159
  for (const contentChange of params.contentChanges) {
160
160
  incrementalSnapshot.changes.push({
161
- applyed: false,
161
+ applied: false,
162
162
  changeRange: undefined,
163
163
  contentChange,
164
164
  version: params.textDocument.version,
@@ -7,9 +7,9 @@ import { LanguageServerPlugin, RuntimeEnvironment, FileSystemHost, LanguageServe
7
7
  import { createSnapshots } from './snapshots';
8
8
  import { URI } from 'vscode-uri';
9
9
  import { ConfigurationHost } from '@volar/language-service';
10
- import { CancellactionTokenHost } from './cancellationPipe';
10
+ import { CancellationTokenHost } from './cancellationPipe';
11
11
  export declare const rootTsConfigNames: string[];
12
- export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, cancelTokenHost: CancellactionTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
12
+ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, cancelTokenHost: CancellationTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
13
13
  projects: {
14
14
  clear: () => void;
15
15
  values: () => IterableIterator<Project>;
@@ -22,9 +22,54 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
22
22
  pathHas: (rootUri: shared._2.URI, path: string) => Project | undefined;
23
23
  pathSet: (rootUri: shared._2.URI, path: string, item: Project) => void;
24
24
  };
25
+ documentRegistry: ts.DocumentRegistry;
25
26
  getProjectAndTsConfig: (uri: string) => Promise<{
26
27
  tsconfig: string;
27
28
  project: {
29
+ tsConfig: ts.CompilerOptions | path.PosixPath;
30
+ scripts: {
31
+ clear: () => void;
32
+ values: () => IterableIterator<{
33
+ version: number;
34
+ fileName: string;
35
+ snapshot: ts.IScriptSnapshot | undefined;
36
+ snapshotVersion: number | undefined;
37
+ }>;
38
+ uriDelete: (_uri: string) => boolean;
39
+ uriGet: (_uri: string) => {
40
+ version: number;
41
+ fileName: string;
42
+ snapshot: ts.IScriptSnapshot | undefined;
43
+ snapshotVersion: number | undefined;
44
+ } | undefined;
45
+ uriHas: (_uri: string) => boolean;
46
+ uriSet: (_uri: string, item: {
47
+ version: number;
48
+ fileName: string;
49
+ snapshot: ts.IScriptSnapshot | undefined;
50
+ snapshotVersion: number | undefined;
51
+ }) => void;
52
+ pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
53
+ pathGet: (rootUri: shared._2.URI, path: string) => {
54
+ version: number;
55
+ fileName: string;
56
+ snapshot: ts.IScriptSnapshot | undefined;
57
+ snapshotVersion: number | undefined;
58
+ } | undefined;
59
+ pathHas: (rootUri: shared._2.URI, path: string) => {
60
+ version: number;
61
+ fileName: string;
62
+ snapshot: ts.IScriptSnapshot | undefined;
63
+ snapshotVersion: number | undefined;
64
+ } | undefined;
65
+ pathSet: (rootUri: shared._2.URI, path: string, item: {
66
+ version: number;
67
+ fileName: string;
68
+ snapshot: ts.IScriptSnapshot | undefined;
69
+ snapshotVersion: number | undefined;
70
+ }) => void;
71
+ };
72
+ languageServiceHost: import("@volar/language-service").LanguageServiceHost;
28
73
  getLanguageService: () => {
29
74
  doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
30
75
  findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
@@ -35,12 +80,9 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
35
80
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
36
81
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
37
82
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
38
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
83
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
39
84
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
40
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
41
- isIncomplete: boolean;
42
- items: vscode.CompletionItem[];
43
- }>;
85
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
44
86
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
45
87
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
46
88
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -78,12 +120,9 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
78
120
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
79
121
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
80
122
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
81
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
123
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
82
124
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
83
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
84
- isIncomplete: boolean;
85
- items: vscode.CompletionItem[];
86
- }>;
125
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
87
126
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
88
127
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
89
128
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -112,10 +151,12 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
112
151
  context: import("@volar/language-service").LanguageServiceRuntimeContext;
113
152
  } | undefined;
114
153
  getParsedCommandLine: () => ts.ParsedCommandLine;
154
+ tryAddFile: (fileName: string) => void;
115
155
  dispose: () => void;
116
156
  };
117
157
  } | undefined>;
118
158
  getInferredProject: () => Project;
159
+ getInferredProjectDontCreate: () => Project | undefined;
119
160
  reload: () => void;
120
161
  dispose(): void;
121
162
  }>;
@@ -52,8 +52,10 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
52
52
  }));
53
53
  return {
54
54
  projects,
55
+ documentRegistry,
55
56
  getProjectAndTsConfig,
56
57
  getInferredProject,
58
+ getInferredProjectDontCreate: () => inferredProject,
57
59
  reload: clearProjects,
58
60
  dispose() {
59
61
  clearProjects();
@@ -5,10 +5,11 @@ import * as vscode from 'vscode-languageserver';
5
5
  import { URI } from 'vscode-uri';
6
6
  import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment, LanguageServerInitializationOptions } from '../types';
7
7
  import { createSnapshots } from './snapshots';
8
- import { CancellactionTokenHost } from './cancellationPipe';
8
+ import * as path from 'typesafe-path';
9
+ import { CancellationTokenHost } from './cancellationPipe';
9
10
  export interface Workspaces extends ReturnType<typeof createWorkspaces> {
10
11
  }
11
- export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, configurationHost: ConfigurationHost | undefined, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, client: vscode.ClientCapabilities, options: LanguageServerInitializationOptions, documents: ReturnType<typeof createSnapshots>, connection: vscode.Connection, cancelTokenHost: CancellactionTokenHost): {
12
+ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, configurationHost: ConfigurationHost | undefined, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, client: vscode.ClientCapabilities, options: LanguageServerInitializationOptions, documents: ReturnType<typeof createSnapshots>, connection: vscode.Connection, cancelTokenHost: CancellationTokenHost): {
12
13
  workspaces: Map<string, Promise<{
13
14
  projects: {
14
15
  clear: () => void;
@@ -22,9 +23,54 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
22
23
  pathHas: (rootUri: shared._2.URI, path: string) => import("./project").Project | undefined;
23
24
  pathSet: (rootUri: shared._2.URI, path: string, item: import("./project").Project) => void;
24
25
  };
26
+ documentRegistry: ts.DocumentRegistry;
25
27
  getProjectAndTsConfig: (uri: string) => Promise<{
26
28
  tsconfig: string;
27
29
  project: {
30
+ tsConfig: ts.CompilerOptions | path.PosixPath;
31
+ scripts: {
32
+ clear: () => void;
33
+ values: () => IterableIterator<{
34
+ version: number;
35
+ fileName: string;
36
+ snapshot: ts.IScriptSnapshot | undefined;
37
+ snapshotVersion: number | undefined;
38
+ }>;
39
+ uriDelete: (_uri: string) => boolean;
40
+ uriGet: (_uri: string) => {
41
+ version: number;
42
+ fileName: string;
43
+ snapshot: ts.IScriptSnapshot | undefined;
44
+ snapshotVersion: number | undefined;
45
+ } | undefined;
46
+ uriHas: (_uri: string) => boolean;
47
+ uriSet: (_uri: string, item: {
48
+ version: number;
49
+ fileName: string;
50
+ snapshot: ts.IScriptSnapshot | undefined;
51
+ snapshotVersion: number | undefined;
52
+ }) => void;
53
+ pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
54
+ pathGet: (rootUri: shared._2.URI, path: string) => {
55
+ version: number;
56
+ fileName: string;
57
+ snapshot: ts.IScriptSnapshot | undefined;
58
+ snapshotVersion: number | undefined;
59
+ } | undefined;
60
+ pathHas: (rootUri: shared._2.URI, path: string) => {
61
+ version: number;
62
+ fileName: string;
63
+ snapshot: ts.IScriptSnapshot | undefined;
64
+ snapshotVersion: number | undefined;
65
+ } | undefined;
66
+ pathSet: (rootUri: shared._2.URI, path: string, item: {
67
+ version: number;
68
+ fileName: string;
69
+ snapshot: ts.IScriptSnapshot | undefined;
70
+ snapshotVersion: number | undefined;
71
+ }) => void;
72
+ };
73
+ languageServiceHost: import("@volar/language-service").LanguageServiceHost;
28
74
  getLanguageService: () => {
29
75
  doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
30
76
  findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
@@ -35,12 +81,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
35
81
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
36
82
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
37
83
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
38
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
84
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
39
85
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
40
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
41
- isIncomplete: boolean;
42
- items: vscode.CompletionItem[];
43
- }>;
86
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
44
87
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
45
88
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
46
89
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -78,12 +121,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
78
121
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
79
122
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
80
123
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
81
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
124
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
82
125
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
83
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
84
- isIncomplete: boolean;
85
- items: vscode.CompletionItem[];
86
- }>;
126
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
87
127
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
88
128
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
89
129
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -112,16 +152,62 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
112
152
  context: import("@volar/language-service").LanguageServiceRuntimeContext;
113
153
  } | undefined;
114
154
  getParsedCommandLine: () => ts.ParsedCommandLine;
155
+ tryAddFile: (fileName: string) => void;
115
156
  dispose: () => void;
116
157
  };
117
158
  } | undefined>;
118
159
  getInferredProject: () => import("./project").Project;
160
+ getInferredProjectDontCreate: () => import("./project").Project | undefined;
119
161
  reload: () => void;
120
162
  dispose(): void;
121
163
  }>>;
122
164
  getProject: (uri: string) => Promise<{
123
165
  tsconfig: string;
124
166
  project: {
167
+ tsConfig: ts.CompilerOptions | path.PosixPath;
168
+ scripts: {
169
+ clear: () => void;
170
+ values: () => IterableIterator<{
171
+ version: number;
172
+ fileName: string;
173
+ snapshot: ts.IScriptSnapshot | undefined;
174
+ snapshotVersion: number | undefined;
175
+ }>;
176
+ uriDelete: (_uri: string) => boolean;
177
+ uriGet: (_uri: string) => {
178
+ version: number;
179
+ fileName: string;
180
+ snapshot: ts.IScriptSnapshot | undefined;
181
+ snapshotVersion: number | undefined;
182
+ } | undefined;
183
+ uriHas: (_uri: string) => boolean;
184
+ uriSet: (_uri: string, item: {
185
+ version: number;
186
+ fileName: string;
187
+ snapshot: ts.IScriptSnapshot | undefined;
188
+ snapshotVersion: number | undefined;
189
+ }) => void;
190
+ pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
191
+ pathGet: (rootUri: shared._2.URI, path: string) => {
192
+ version: number;
193
+ fileName: string;
194
+ snapshot: ts.IScriptSnapshot | undefined;
195
+ snapshotVersion: number | undefined;
196
+ } | undefined;
197
+ pathHas: (rootUri: shared._2.URI, path: string) => {
198
+ version: number;
199
+ fileName: string;
200
+ snapshot: ts.IScriptSnapshot | undefined;
201
+ snapshotVersion: number | undefined;
202
+ } | undefined;
203
+ pathSet: (rootUri: shared._2.URI, path: string, item: {
204
+ version: number;
205
+ fileName: string;
206
+ snapshot: ts.IScriptSnapshot | undefined;
207
+ snapshotVersion: number | undefined;
208
+ }) => void;
209
+ };
210
+ languageServiceHost: import("@volar/language-service").LanguageServiceHost;
125
211
  getLanguageService: () => {
126
212
  doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
127
213
  findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
@@ -132,12 +218,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
132
218
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
133
219
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
134
220
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
135
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
221
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
136
222
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
137
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
138
- isIncomplete: boolean;
139
- items: vscode.CompletionItem[];
140
- }>;
223
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
141
224
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
142
225
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
143
226
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -175,12 +258,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
175
258
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
176
259
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
177
260
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
178
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
261
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
179
262
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
180
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
181
- isIncomplete: boolean;
182
- items: vscode.CompletionItem[];
183
- }>;
263
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
184
264
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
185
265
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
186
266
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -209,11 +289,56 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
209
289
  context: import("@volar/language-service").LanguageServiceRuntimeContext;
210
290
  } | undefined;
211
291
  getParsedCommandLine: () => ts.ParsedCommandLine;
292
+ tryAddFile: (fileName: string) => void;
212
293
  dispose: () => void;
213
294
  };
214
295
  } | {
215
296
  tsconfig: undefined;
216
297
  project: {
298
+ tsConfig: ts.CompilerOptions | path.PosixPath;
299
+ scripts: {
300
+ clear: () => void;
301
+ values: () => IterableIterator<{
302
+ version: number;
303
+ fileName: string;
304
+ snapshot: ts.IScriptSnapshot | undefined;
305
+ snapshotVersion: number | undefined;
306
+ }>;
307
+ uriDelete: (_uri: string) => boolean;
308
+ uriGet: (_uri: string) => {
309
+ version: number;
310
+ fileName: string;
311
+ snapshot: ts.IScriptSnapshot | undefined;
312
+ snapshotVersion: number | undefined;
313
+ } | undefined;
314
+ uriHas: (_uri: string) => boolean;
315
+ uriSet: (_uri: string, item: {
316
+ version: number;
317
+ fileName: string;
318
+ snapshot: ts.IScriptSnapshot | undefined;
319
+ snapshotVersion: number | undefined;
320
+ }) => void;
321
+ pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
322
+ pathGet: (rootUri: shared._2.URI, path: string) => {
323
+ version: number;
324
+ fileName: string;
325
+ snapshot: ts.IScriptSnapshot | undefined;
326
+ snapshotVersion: number | undefined;
327
+ } | undefined;
328
+ pathHas: (rootUri: shared._2.URI, path: string) => {
329
+ version: number;
330
+ fileName: string;
331
+ snapshot: ts.IScriptSnapshot | undefined;
332
+ snapshotVersion: number | undefined;
333
+ } | undefined;
334
+ pathSet: (rootUri: shared._2.URI, path: string, item: {
335
+ version: number;
336
+ fileName: string;
337
+ snapshot: ts.IScriptSnapshot | undefined;
338
+ snapshotVersion: number | undefined;
339
+ }) => void;
340
+ };
341
+ languageServiceHost: import("@volar/language-service").LanguageServiceHost;
217
342
  getLanguageService: () => {
218
343
  doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
219
344
  findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
@@ -224,12 +349,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
224
349
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
225
350
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
226
351
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
227
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
352
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
228
353
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
229
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
230
- isIncomplete: boolean;
231
- items: vscode.CompletionItem[];
232
- }>;
354
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
233
355
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
234
356
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
235
357
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -267,12 +389,9 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
267
389
  prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
268
390
  doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
269
391
  getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
270
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
392
+ getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
271
393
  doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
272
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<{
273
- isIncomplete: boolean;
274
- items: vscode.CompletionItem[];
275
- }>;
394
+ doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
276
395
  doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
277
396
  doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
278
397
  doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
@@ -301,6 +420,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
301
420
  context: import("@volar/language-service").LanguageServiceRuntimeContext;
302
421
  } | undefined;
303
422
  getParsedCommandLine: () => ts.ParsedCommandLine;
423
+ tryAddFile: (fileName: string) => void;
304
424
  dispose: () => void;
305
425
  } | undefined;
306
426
  } | undefined>;
@@ -30,6 +30,9 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
30
30
  if (tsConfigChanges.length) {
31
31
  reloadDiagnostics();
32
32
  }
33
+ else {
34
+ onDriveFileUpdated();
35
+ }
33
36
  });
34
37
  (_a = runtimeEnv.onDidChangeConfiguration) === null || _a === void 0 ? void 0 : _a.call(runtimeEnv, () => __awaiter(this, void 0, void 0, function* () {
35
38
  onDriveFileUpdated();
@@ -39,7 +42,9 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
39
42
  getProject,
40
43
  reloadProject,
41
44
  add: (rootUri) => {
42
- workspaces.set(rootUri.toString(), (0, workspaceProjects_1.createWorkspaceProjects)(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configurationHost, cancelTokenHost, options));
45
+ if (!workspaces.has(rootUri.toString())) {
46
+ workspaces.set(rootUri.toString(), (0, workspaceProjects_1.createWorkspaceProjects)(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configurationHost, cancelTokenHost, options));
47
+ }
43
48
  },
44
49
  remove: (rootUri) => {
45
50
  const _workspace = workspaces.get(rootUri.toString());
@@ -87,7 +92,7 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
87
92
  return;
88
93
  const req = ++documentUpdatedReq;
89
94
  const delay = (_b = yield (configurationHost === null || configurationHost === void 0 ? void 0 : configurationHost.getConfiguration('volar.diagnostics.delay'))) !== null && _b !== void 0 ? _b : 200;
90
- const cancel = cancelTokenHost.createCancellactionToken({
95
+ const cancel = cancelTokenHost.createCancellationToken({
91
96
  get isCancellationRequested() {
92
97
  return req !== documentUpdatedReq;
93
98
  },
@@ -109,6 +114,8 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
109
114
  function sendDocumentDiagnostics(uri, version, cancel) {
110
115
  var _a;
111
116
  return __awaiter(this, void 0, void 0, function* () {
117
+ if (cancel.isCancellationRequested)
118
+ return;
112
119
  const project = (_a = (yield getProject(uri))) === null || _a === void 0 ? void 0 : _a.project;
113
120
  if (!project)
114
121
  return;
@@ -145,9 +152,11 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
145
152
  }
146
153
  }
147
154
  if (rootUris.length) {
155
+ const project = yield ((_a = (yield workspaces.get(rootUris[0]))) === null || _a === void 0 ? void 0 : _a.getInferredProject());
156
+ project === null || project === void 0 ? void 0 : project.tryAddFile(shared.getPathOfUri(uri));
148
157
  return {
149
158
  tsconfig: undefined,
150
- project: yield ((_a = (yield workspaces.get(rootUris[0]))) === null || _a === void 0 ? void 0 : _a.getInferredProject()),
159
+ project,
151
160
  };
152
161
  }
153
162
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "directory": "packages/language-server"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "1.0.8",
21
- "@volar/language-service": "1.0.8",
22
- "@volar/shared": "1.0.8",
20
+ "@volar/language-core": "1.0.9",
21
+ "@volar/language-service": "1.0.9",
22
+ "@volar/shared": "1.0.9",
23
23
  "request-light": "^0.5.8",
24
24
  "typesafe-path": "^0.2.2",
25
25
  "vscode-html-languageservice": "^5.0.2",
@@ -28,5 +28,5 @@
28
28
  "vscode-languageserver-textdocument": "^1.0.7",
29
29
  "vscode-uri": "^3.0.6"
30
30
  },
31
- "gitHead": "10d1a6a8b4011adee0a7c309da25caae7fb4fea9"
31
+ "gitHead": "be2081f56ce4608324795b8a0ae83c288a3a784d"
32
32
  }