@volar/language-server 1.11.0 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/browser.d.ts +4 -3
  2. package/browser.js +16 -6
  3. package/index.d.ts +0 -1
  4. package/lib/cancellationToken.d.ts +3 -0
  5. package/lib/{node/cancellationPipe.js → cancellationToken.js} +2 -3
  6. package/lib/config.d.ts +5 -0
  7. package/lib/config.js +32 -0
  8. package/lib/{common/configurationHost.d.ts → configurationHost.d.ts} +1 -2
  9. package/lib/project/inferredCompilerOptions.d.ts +3 -0
  10. package/lib/{common/utils → project}/inferredCompilerOptions.js +3 -3
  11. package/lib/project/simpleProject.d.ts +4 -0
  12. package/lib/project/simpleProject.js +34 -0
  13. package/lib/project/simpleProjectProvider.d.ts +25 -0
  14. package/lib/project/simpleProjectProvider.js +67 -0
  15. package/lib/project/typescriptProject.d.ts +11 -0
  16. package/lib/project/typescriptProject.js +136 -0
  17. package/lib/project/typescriptProjectProvider.d.ts +4 -0
  18. package/lib/project/typescriptProjectProvider.js +232 -0
  19. package/lib/register/registerEditorFeatures.d.ts +3 -0
  20. package/lib/register/registerEditorFeatures.js +157 -0
  21. package/lib/register/registerLanguageFeatures.d.ts +5 -0
  22. package/lib/{common/features/languageFeatures.js → register/registerLanguageFeatures.js} +17 -31
  23. package/lib/{common/schemaRequestHandlers → schemaRequestHandlers}/http.d.ts +0 -1
  24. package/lib/server.d.ts +14 -0
  25. package/lib/server.js +325 -0
  26. package/lib/setupCapabilities.d.ts +4 -0
  27. package/lib/{common/utils/registerFeatures.js → setupCapabilities.js} +6 -9
  28. package/lib/types.d.ts +39 -17
  29. package/lib/{common/utils → utils}/isFileInDir.d.ts +0 -1
  30. package/lib/{common/utils → utils}/uriMap.d.ts +1 -1
  31. package/lib/workspaceFolderManager.d.ts +16 -0
  32. package/lib/workspaceFolderManager.js +39 -0
  33. package/node.d.ts +4 -3
  34. package/node.js +18 -8
  35. package/package.json +7 -7
  36. package/protocol.d.ts +40 -12
  37. package/protocol.js +16 -1
  38. package/lib/common/documents.d.ts +0 -48
  39. package/lib/common/documents.js +0 -216
  40. package/lib/common/features/customFeatures.d.ts +0 -5
  41. package/lib/common/features/customFeatures.js +0 -138
  42. package/lib/common/features/languageFeatures.d.ts +0 -7
  43. package/lib/common/project.d.ts +0 -141
  44. package/lib/common/project.js +0 -202
  45. package/lib/common/server.d.ts +0 -15
  46. package/lib/common/server.js +0 -227
  47. package/lib/common/utils/inferredCompilerOptions.d.ts +0 -4
  48. package/lib/common/utils/registerFeatures.d.ts +0 -5
  49. package/lib/common/utils/serverConfig.d.ts +0 -3
  50. package/lib/common/utils/serverConfig.js +0 -22
  51. package/lib/common/workspaces.d.ts +0 -1824
  52. package/lib/common/workspaces.js +0 -347
  53. package/lib/node/cancellationPipe.d.ts +0 -3
  54. /package/lib/{common/configurationHost.js → configurationHost.js} +0 -0
  55. /package/lib/{common/schemaRequestHandlers → schemaRequestHandlers}/http.js +0 -0
  56. /package/lib/{common/utils → utils}/isFileInDir.js +0 -0
  57. /package/lib/{common/utils → utils}/uriMap.js +0 -0
package/protocol.d.ts CHANGED
@@ -1,7 +1,6 @@
1
+ import type { CodeInformation, Mapping, Stack, VirtualFile } from '@volar/language-core';
2
+ import type { FileStat, FileType, DocumentDropEdit } from '@volar/language-service';
1
3
  import * as vscode from 'vscode-languageserver-protocol';
2
- import type { VirtualFile, FileRangeCapabilities } from '@volar/language-core';
3
- import type { Mapping, Stack } from '@volar/source-map';
4
- import type { FileStat, FileType } from '@volar/language-service';
5
4
  /**
6
5
  * Server request client
7
6
  */
@@ -35,13 +34,9 @@ export declare namespace GetMatchTsConfigRequest {
35
34
  }
36
35
  export declare namespace AutoInsertRequest {
37
36
  type ParamsType = vscode.TextDocumentPositionParams & {
38
- options: {
39
- lastChange: {
40
- range: vscode.Range;
41
- rangeOffset: number;
42
- rangeLength: number;
43
- text: string;
44
- };
37
+ lastChange: {
38
+ range: vscode.Range;
39
+ text: string;
45
40
  };
46
41
  };
47
42
  type ResponseType = string | vscode.TextEdit | null | undefined;
@@ -70,10 +65,43 @@ export declare namespace GetVirtualFileRequest {
70
65
  };
71
66
  type ResponseType = {
72
67
  content: string;
73
- mappings: Record<string, Mapping<FileRangeCapabilities>[]>;
68
+ mappings: Record<string, Mapping<CodeInformation>[]>;
74
69
  codegenStacks: Stack[];
75
70
  };
76
71
  type ErrorType = never;
77
72
  const type: vscode.RequestType<ParamsType, ResponseType, never>;
78
73
  }
79
- //# sourceMappingURL=protocol.d.ts.map
74
+ /**
75
+ * Document Drop
76
+ */
77
+ export declare namespace DocumentDropRequest {
78
+ type ParamsType = vscode.TextDocumentPositionParams & {
79
+ dataTransfer: {
80
+ mimeType: string;
81
+ value: any;
82
+ file?: {
83
+ name: string;
84
+ uri?: string;
85
+ };
86
+ }[];
87
+ };
88
+ type ResponseType = DocumentDropEdit | null | undefined;
89
+ type ErrorType = never;
90
+ const type: vscode.RequestType<ParamsType, ResponseType, never>;
91
+ }
92
+ export declare namespace DocumentDrop_DataTransferItemAsStringRequest {
93
+ type ParamsType = {
94
+ mimeType: string;
95
+ };
96
+ type ResponseType = string;
97
+ type ErrorType = never;
98
+ const type: vscode.RequestType<ParamsType, string, never>;
99
+ }
100
+ export declare namespace DocumentDrop_DataTransferItemFileDataRequest {
101
+ type ParamsType = {
102
+ mimeType: string;
103
+ };
104
+ type ResponseType = Uint8Array;
105
+ type ErrorType = never;
106
+ const type: vscode.RequestType<ParamsType, Uint8Array, never>;
107
+ }
package/protocol.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetVirtualFileRequest = exports.GetVirtualFilesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.LoadedTSFilesMetaRequest = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsStatRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
3
+ exports.DocumentDrop_DataTransferItemFileDataRequest = exports.DocumentDrop_DataTransferItemAsStringRequest = exports.DocumentDropRequest = exports.GetVirtualFileRequest = exports.GetVirtualFilesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.LoadedTSFilesMetaRequest = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsStatRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
4
4
  const vscode = require("vscode-languageserver-protocol");
5
5
  /**
6
6
  * Server request client
@@ -52,4 +52,19 @@ var GetVirtualFileRequest;
52
52
  (function (GetVirtualFileRequest) {
53
53
  GetVirtualFileRequest.type = new vscode.RequestType('volar/client/virtualFile');
54
54
  })(GetVirtualFileRequest || (exports.GetVirtualFileRequest = GetVirtualFileRequest = {}));
55
+ /**
56
+ * Document Drop
57
+ */
58
+ var DocumentDropRequest;
59
+ (function (DocumentDropRequest) {
60
+ DocumentDropRequest.type = new vscode.RequestType('volar/client/documentDrop');
61
+ })(DocumentDropRequest || (exports.DocumentDropRequest = DocumentDropRequest = {}));
62
+ var DocumentDrop_DataTransferItemAsStringRequest;
63
+ (function (DocumentDrop_DataTransferItemAsStringRequest) {
64
+ DocumentDrop_DataTransferItemAsStringRequest.type = new vscode.RequestType('volar/client/documentDrop/asString');
65
+ })(DocumentDrop_DataTransferItemAsStringRequest || (exports.DocumentDrop_DataTransferItemAsStringRequest = DocumentDrop_DataTransferItemAsStringRequest = {}));
66
+ var DocumentDrop_DataTransferItemFileDataRequest;
67
+ (function (DocumentDrop_DataTransferItemFileDataRequest) {
68
+ DocumentDrop_DataTransferItemFileDataRequest.type = new vscode.RequestType('volar/client/documentDrop/fileData');
69
+ })(DocumentDrop_DataTransferItemFileDataRequest || (exports.DocumentDrop_DataTransferItemFileDataRequest = DocumentDrop_DataTransferItemFileDataRequest = {}));
55
70
  //# sourceMappingURL=protocol.js.map
@@ -1,48 +0,0 @@
1
- /// <reference types="node" />
2
- import { TextDocument } from 'vscode-languageserver-textdocument';
3
- import * as vscode from 'vscode-languageserver';
4
- import type * as ts from 'typescript/lib/tsserverlibrary';
5
- import { RuntimeEnvironment } from '../types';
6
- interface IncrementalScriptSnapshotChange {
7
- applied: boolean;
8
- changeRange: ts.TextChangeRange | undefined;
9
- version: number;
10
- contentChange: {
11
- range: vscode.Range;
12
- text: string;
13
- } | undefined;
14
- snapshot: WeakRef<ts.IScriptSnapshot> | undefined;
15
- }
16
- declare class IncrementalScriptSnapshot {
17
- private document;
18
- uri: string;
19
- changes: IncrementalScriptSnapshotChange[];
20
- constructor(uri: string, languageId: string, version: number, text: string);
21
- get version(): number;
22
- get languageId(): string;
23
- update(params: vscode.DidChangeTextDocumentParams): void;
24
- getSnapshot(): ts.IScriptSnapshot;
25
- getDocument(): TextDocument;
26
- clearUnReferenceVersions(): void;
27
- applyVersionChanges(version: number, removeBeforeVersions: boolean): void;
28
- }
29
- export declare function combineContinuousChangeRanges(...changeRanges: ts.TextChangeRange[]): ts.TextChangeRange;
30
- export declare function createDocuments(env: RuntimeEnvironment, connection: vscode.Connection): {
31
- data: {
32
- clear: () => void;
33
- values: () => IterableIterator<IncrementalScriptSnapshot>;
34
- uriKeys: () => IterableIterator<string>;
35
- uriDelete: (_uri: string) => boolean;
36
- uriGet: (_uri: string) => IncrementalScriptSnapshot | undefined;
37
- uriHas: (_uri: string) => boolean;
38
- uriSet: (_uri: string, item: IncrementalScriptSnapshot) => void;
39
- pathDelete: (path: string) => boolean;
40
- pathGet: (path: string) => IncrementalScriptSnapshot | undefined;
41
- pathHas: (path: string) => IncrementalScriptSnapshot | undefined;
42
- pathSet: (path: string, item: IncrementalScriptSnapshot) => void;
43
- };
44
- onDidChangeContent: (cb: (params: vscode.DidChangeTextDocumentParams) => void) => vscode.Disposable;
45
- onDidClose: (cb: (params: vscode.DidCloseTextDocumentParams) => void) => vscode.Disposable;
46
- };
47
- export {};
48
- //# sourceMappingURL=documents.d.ts.map
@@ -1,216 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
4
- const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
5
- const vscode = require("vscode-languageserver");
6
- const uriMap_1 = require("./utils/uriMap");
7
- class IncrementalScriptSnapshot {
8
- constructor(uri, languageId, version, text) {
9
- this.uri = uri;
10
- this.document = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, version, text);
11
- this.changes = [
12
- {
13
- applied: true,
14
- changeRange: undefined,
15
- version,
16
- contentChange: undefined,
17
- snapshot: undefined,
18
- }
19
- ];
20
- }
21
- get version() {
22
- return this.changes[this.changes.length - 1].version;
23
- }
24
- get languageId() {
25
- return this.document.languageId;
26
- }
27
- update(params) {
28
- vscode_languageserver_textdocument_1.TextDocument.update(this.document, params.contentChanges, params.textDocument.version);
29
- this.changes = [
30
- {
31
- applied: true,
32
- changeRange: undefined,
33
- version: params.textDocument.version,
34
- contentChange: undefined,
35
- snapshot: undefined,
36
- }
37
- ];
38
- }
39
- getSnapshot() {
40
- this.clearUnReferenceVersions();
41
- const lastChange = this.changes[this.changes.length - 1];
42
- if (!lastChange.snapshot) {
43
- this.applyVersionChanges(lastChange.version, false);
44
- const text = this.document.getText();
45
- const cache = new WeakMap();
46
- const snapshot = {
47
- getText: (start, end) => text.substring(start, end),
48
- getLength: () => text.length,
49
- getChangeRange: (oldSnapshot) => {
50
- if (!cache.has(oldSnapshot)) {
51
- const oldIndex = this.changes.findIndex(change => change.snapshot?.deref() === oldSnapshot);
52
- if (oldIndex >= 0) {
53
- const start = oldIndex + 1;
54
- const end = this.changes.indexOf(lastChange) + 1;
55
- const changeRanges = this.changes.slice(start, end).map(change => change.changeRange);
56
- const result = combineContinuousChangeRanges.apply(null, changeRanges);
57
- cache.set(oldSnapshot, result);
58
- }
59
- else {
60
- cache.set(oldSnapshot, undefined);
61
- }
62
- }
63
- return cache.get(oldSnapshot);
64
- },
65
- };
66
- lastChange.snapshot = new WeakRef(snapshot);
67
- }
68
- return lastChange.snapshot.deref();
69
- }
70
- getDocument() {
71
- this.clearUnReferenceVersions();
72
- const lastChange = this.changes[this.changes.length - 1];
73
- if (!lastChange.applied) {
74
- this.applyVersionChanges(lastChange.version, false);
75
- }
76
- return this.document;
77
- }
78
- clearUnReferenceVersions() {
79
- let versionToApply;
80
- for (let i = 0; i <= this.changes.length - 2; i++) {
81
- const change = this.changes[i];
82
- const nextChange = this.changes[i + 1];
83
- if (!change.snapshot?.deref()) {
84
- if (change.version !== nextChange.version) {
85
- versionToApply = change.version;
86
- }
87
- }
88
- else {
89
- break;
90
- }
91
- }
92
- if (versionToApply !== undefined) {
93
- this.applyVersionChanges(versionToApply, true);
94
- }
95
- }
96
- applyVersionChanges(version, removeBeforeVersions) {
97
- let removeEnd = -1;
98
- for (let i = 0; i < this.changes.length; i++) {
99
- const change = this.changes[i];
100
- if (change.version > version) {
101
- break;
102
- }
103
- if (!change.applied) {
104
- if (change.contentChange) {
105
- change.changeRange = {
106
- span: {
107
- start: this.document.offsetAt(change.contentChange.range.start),
108
- length: this.document.offsetAt(change.contentChange.range.end) - this.document.offsetAt(change.contentChange.range.start),
109
- },
110
- newLength: change.contentChange.text.length,
111
- };
112
- vscode_languageserver_textdocument_1.TextDocument.update(this.document, [change.contentChange], change.version);
113
- }
114
- change.applied = true;
115
- }
116
- removeEnd = i + 1;
117
- }
118
- if (removeBeforeVersions && removeEnd >= 1) {
119
- this.changes.splice(0, removeEnd);
120
- }
121
- }
122
- }
123
- function combineContinuousChangeRanges(...changeRanges) {
124
- if (changeRanges.length === 1) {
125
- return changeRanges[0];
126
- }
127
- let changeRange = changeRanges[0];
128
- for (let i = 1; i < changeRanges.length; i++) {
129
- const nextChangeRange = changeRanges[i];
130
- changeRange = _combineContinuousChangeRanges(changeRange, nextChangeRange);
131
- }
132
- return changeRange;
133
- }
134
- exports.combineContinuousChangeRanges = combineContinuousChangeRanges;
135
- // https://tsplay.dev/w6Paym - @browsnet
136
- function _combineContinuousChangeRanges(a, b) {
137
- const aStart = a.span.start;
138
- const aEnd = a.span.start + a.span.length;
139
- const aDiff = a.newLength - a.span.length;
140
- const changeBegin = aStart + Math.min(a.span.length, a.newLength);
141
- const rollback = (start) => start > changeBegin ? start - aDiff : start;
142
- const bStart = rollback(b.span.start);
143
- const bEnd = rollback(b.span.start + b.span.length);
144
- const bDiff = b.newLength - b.span.length;
145
- const start = Math.min(aStart, bStart);
146
- const end = Math.max(aEnd, bEnd);
147
- const length = end - start;
148
- const newLength = aDiff + bDiff + length;
149
- return { span: { start, length }, newLength };
150
- }
151
- function createDocuments(env, connection) {
152
- const snapshots = (0, uriMap_1.createUriMap)(env.fileNameToUri);
153
- const onDidChangeContents = new Set();
154
- const onDidCloses = new Set();
155
- connection.onDidOpenTextDocument(params => {
156
- if (params.textDocument.uri.startsWith('git:/'))
157
- return;
158
- snapshots.uriSet(params.textDocument.uri, new IncrementalScriptSnapshot(params.textDocument.uri, params.textDocument.languageId, params.textDocument.version, params.textDocument.text));
159
- for (const cb of onDidChangeContents) {
160
- cb({ textDocument: params.textDocument, contentChanges: [{ text: params.textDocument.text }] });
161
- }
162
- });
163
- connection.onDidChangeTextDocument(params => {
164
- if (params.textDocument.uri.startsWith('git:/'))
165
- return;
166
- const incrementalSnapshot = snapshots.uriGet(params.textDocument.uri);
167
- if (incrementalSnapshot) {
168
- if (params.contentChanges.every(vscode.TextDocumentContentChangeEvent.isIncremental)) {
169
- for (const contentChange of params.contentChanges) {
170
- incrementalSnapshot.changes.push({
171
- applied: false,
172
- changeRange: undefined,
173
- contentChange,
174
- version: params.textDocument.version,
175
- snapshot: undefined,
176
- });
177
- }
178
- }
179
- else {
180
- incrementalSnapshot.update(params);
181
- }
182
- }
183
- for (const cb of onDidChangeContents) {
184
- cb(params);
185
- }
186
- });
187
- connection.onDidCloseTextDocument(params => {
188
- if (params.textDocument.uri.startsWith('git:/'))
189
- return;
190
- snapshots.uriDelete(params.textDocument.uri);
191
- for (const cb of onDidCloses) {
192
- cb(params);
193
- }
194
- });
195
- return {
196
- data: snapshots,
197
- onDidChangeContent: (cb) => {
198
- onDidChangeContents.add(cb);
199
- return {
200
- dispose() {
201
- onDidChangeContents.delete(cb);
202
- },
203
- };
204
- },
205
- onDidClose: (cb) => {
206
- onDidCloses.add(cb);
207
- return {
208
- dispose() {
209
- onDidCloses.delete(cb);
210
- },
211
- };
212
- },
213
- };
214
- }
215
- exports.createDocuments = createDocuments;
216
- //# sourceMappingURL=documents.js.map
@@ -1,5 +0,0 @@
1
- import * as vscode from 'vscode-languageserver';
2
- import { RuntimeEnvironment } from '../../types';
3
- import type { Workspaces } from '../workspaces';
4
- export declare function register(connection: vscode.Connection, workspaces: Workspaces, env: RuntimeEnvironment): void;
5
- //# sourceMappingURL=customFeatures.d.ts.map
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const language_core_1 = require("@volar/language-core");
5
- const protocol_1 = require("../../../protocol");
6
- function register(connection, workspaces, env) {
7
- const scriptVersions = new Map();
8
- const scriptVersionSnapshots = new WeakSet();
9
- connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, async (params) => {
10
- const project = (await workspaces.getProject(params.uri));
11
- if (project?.tsconfig) {
12
- return { uri: env.fileNameToUri(project.tsconfig) };
13
- }
14
- });
15
- connection.onRequest(protocol_1.GetVirtualFilesRequest.type, async (document) => {
16
- const project = await workspaces.getProject(document.uri);
17
- if (project) {
18
- const file = project.project?.getLanguageService()?.context.virtualFiles.getSource(env.uriToFileName(document.uri))?.root;
19
- return file ? prune(file) : undefined;
20
- function prune(file) {
21
- let version = scriptVersions.get(file.fileName) ?? 0;
22
- if (!scriptVersionSnapshots.has(file.snapshot)) {
23
- version++;
24
- scriptVersions.set(file.fileName, version);
25
- scriptVersionSnapshots.add(file.snapshot);
26
- }
27
- return {
28
- fileName: file.fileName,
29
- kind: file.kind,
30
- capabilities: file.capabilities,
31
- embeddedFiles: file.embeddedFiles.map(prune),
32
- version,
33
- };
34
- }
35
- }
36
- });
37
- connection.onRequest(protocol_1.GetVirtualFileRequest.type, async (params) => {
38
- const project = await workspaces.getProject(params.sourceFileUri);
39
- const service = project?.project?.getLanguageService();
40
- if (service) {
41
- let content = '';
42
- let codegenStacks = [];
43
- const mappings = {};
44
- for (const [file, map] of service.context.documents.getMapsByVirtualFileName(params.virtualFileName)) {
45
- content = map.virtualFileDocument.getText();
46
- codegenStacks = file.codegenStacks;
47
- mappings[map.sourceFileDocument.uri] = map.map.mappings;
48
- }
49
- return {
50
- content,
51
- mappings,
52
- codegenStacks,
53
- };
54
- }
55
- });
56
- connection.onNotification(protocol_1.ReloadProjectNotification.type, () => {
57
- workspaces.reloadProjects();
58
- });
59
- connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, async (params) => {
60
- const fsModeName = 'fs'; // avoid bundle
61
- const fs = await import(fsModeName);
62
- const project = await workspaces.getProject(params.uri);
63
- if (project) {
64
- const ls = (await project.project)?.getLanguageServiceDontCreate();
65
- if (ls) {
66
- const rootPath = ls.context.env.uriToFileName(ls.context.env.rootUri.toString());
67
- for (const { root } of ls.context.virtualFiles.allSources()) {
68
- (0, language_core_1.forEachEmbeddedFile)(root, virtualFile => {
69
- if (virtualFile.kind === language_core_1.FileKind.TypeScriptHostFile) {
70
- if (virtualFile.fileName.startsWith(rootPath)) {
71
- const snapshot = virtualFile.snapshot;
72
- fs.writeFile(virtualFile.fileName, snapshot.getText(0, snapshot.getLength()), () => { });
73
- }
74
- }
75
- });
76
- }
77
- // global virtual files
78
- for (const fileName of ls.context.host.getScriptFileNames()) {
79
- if (!fs.existsSync(fileName)) {
80
- const snapshot = ls.context.host.getScriptSnapshot(fileName);
81
- if (snapshot) {
82
- fs.writeFile(fileName, snapshot.getText(0, snapshot.getLength()), () => { });
83
- }
84
- }
85
- }
86
- }
87
- }
88
- });
89
- connection.onRequest(protocol_1.LoadedTSFilesMetaRequest.type, async () => {
90
- const sourceFilesData = new Map();
91
- for (const _project of [...workspaces.configProjects.values(), ...workspaces.inferredProjects.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);
112
- }
113
- ;
114
- }
115
- }
116
- const result = {
117
- inputs: {},
118
- outputs: {},
119
- };
120
- for (const [sourceFile, fileData] of sourceFilesData) {
121
- let key = fileData.projectNames.sort().join(', ');
122
- if (fileData.projectNames.length >= 2) {
123
- key = `Shared in ${fileData.projectNames.length} projects (${key})`;
124
- }
125
- result.outputs[key] ??= {
126
- imports: [],
127
- exports: [],
128
- entryPoint: '',
129
- inputs: {},
130
- bytes: 0,
131
- };
132
- result.outputs[key].inputs[sourceFile.fileName] = { bytesInOutput: fileData.size };
133
- }
134
- return result;
135
- });
136
- }
137
- exports.register = register;
138
- //# sourceMappingURL=customFeatures.js.map
@@ -1,7 +0,0 @@
1
- import * as vscode from 'vscode-languageserver';
2
- import type { Workspaces } from '../workspaces';
3
- import { RuntimeEnvironment, InitializationOptions } from '../../types';
4
- import { createDocuments } from '../documents';
5
- export declare function register(connection: vscode.Connection, workspaces: Workspaces, initParams: vscode.InitializeParams, initOptions: InitializationOptions, semanticTokensLegend: vscode.SemanticTokensLegend, runtime: RuntimeEnvironment, documents: ReturnType<typeof createDocuments>): void;
6
- export declare function sleep(ms: number): Promise<unknown>;
7
- //# sourceMappingURL=languageFeatures.d.ts.map
@@ -1,141 +0,0 @@
1
- import { TypeScriptLanguageHost } from '@volar/language-service';
2
- import type * as ts from 'typescript/lib/tsserverlibrary';
3
- import * as vscode from 'vscode-languageserver';
4
- import { URI } from 'vscode-uri';
5
- import { WorkspacesContext } from './workspaces';
6
- export interface ProjectContext extends WorkspacesContext {
7
- project: {
8
- workspaceUri: URI;
9
- rootUri: URI;
10
- tsConfig: string | ts.CompilerOptions;
11
- };
12
- }
13
- export type Project = ReturnType<typeof createProject>;
14
- export declare function createProject(context: ProjectContext): Promise<{
15
- context: ProjectContext;
16
- tsConfig: string | ts.CompilerOptions;
17
- languageHost: TypeScriptLanguageHost;
18
- getLanguageService: () => {
19
- getTriggerCharacters: () => string[];
20
- getAutoFormatTriggerCharacters: () => string[];
21
- getSignatureHelpTriggerCharacters: () => string[];
22
- getSignatureHelpRetriggerCharacters: () => string[];
23
- format: (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
24
- ch: string;
25
- position: vscode.Position;
26
- } | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.TextEdit[] | undefined>;
27
- getFoldingRanges: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.FoldingRange[] | undefined>;
28
- getSelectionRanges: (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken | undefined) => Promise<vscode.SelectionRange[] | undefined>;
29
- findLinkedEditingRanges: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LinkedEditingRanges | undefined>;
30
- findDocumentSymbols: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentSymbol[] | undefined>;
31
- findDocumentColors: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.ColorInformation[] | undefined>;
32
- getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken | undefined) => Promise<vscode.ColorPresentation[] | undefined>;
33
- doValidation: (uri: string, mode: "all" | "semantic" | "syntactic", token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
34
- findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.Location[] | undefined>;
35
- findFileReferences: (uri: string, token?: vscode.CancellationToken | undefined) => import("@volar/language-service").NullableResult<vscode.Location[]>;
36
- findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
37
- findTypeDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
38
- findImplementations: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
39
- prepareRename: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<NonNullable<vscode.Range | {
40
- range: vscode.Range;
41
- placeholder: string;
42
- } | {
43
- message: string;
44
- } | null | undefined> | undefined>;
45
- doRename: (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceEdit | undefined>;
46
- getEditsForFileRename: (oldUri: string, newUri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceEdit | undefined>;
47
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken | undefined, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
48
- doHover: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.Hover | undefined>;
49
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.CompletionList>;
50
- doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeAction[] | undefined>;
51
- doCodeActionResolve: (item: vscode.CodeAction, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeAction>;
52
- doCompletionResolve: (item: vscode.CompletionItem, token?: vscode.CancellationToken | undefined) => Promise<vscode.CompletionItem>;
53
- getSignatureHelp: (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.SignatureHelp | undefined>;
54
- doCodeLens: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeLens[]>;
55
- doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeLens>;
56
- findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentHighlight[] | undefined>;
57
- findDocumentLinks: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentLink[]>;
58
- doDocumentLinkResolve: (item: vscode.DocumentLink, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentLink>;
59
- findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceSymbol[]>;
60
- doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("@volar/language-service").AutoInsertionContext, token?: vscode.CancellationToken | undefined) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
61
- getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken | undefined) => Promise<vscode.InlayHint[] | undefined>;
62
- doInlayHintResolve: (item: vscode.InlayHint, token?: vscode.CancellationToken | undefined) => Promise<vscode.InlayHint>;
63
- callHierarchy: {
64
- doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined): Promise<vscode.CallHierarchyItem[] | undefined>;
65
- getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
66
- getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
67
- };
68
- dispose: () => void;
69
- context: import("@volar/language-service").ServiceContext<any>;
70
- };
71
- getLanguageServiceDontCreate: () => {
72
- getTriggerCharacters: () => string[];
73
- getAutoFormatTriggerCharacters: () => string[];
74
- getSignatureHelpTriggerCharacters: () => string[];
75
- getSignatureHelpRetriggerCharacters: () => string[];
76
- format: (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
77
- ch: string;
78
- position: vscode.Position;
79
- } | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.TextEdit[] | undefined>;
80
- getFoldingRanges: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.FoldingRange[] | undefined>;
81
- getSelectionRanges: (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken | undefined) => Promise<vscode.SelectionRange[] | undefined>;
82
- findLinkedEditingRanges: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LinkedEditingRanges | undefined>;
83
- findDocumentSymbols: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentSymbol[] | undefined>;
84
- findDocumentColors: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.ColorInformation[] | undefined>;
85
- getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken | undefined) => Promise<vscode.ColorPresentation[] | undefined>;
86
- doValidation: (uri: string, mode: "all" | "semantic" | "syntactic", token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
87
- findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.Location[] | undefined>;
88
- findFileReferences: (uri: string, token?: vscode.CancellationToken | undefined) => import("@volar/language-service").NullableResult<vscode.Location[]>;
89
- findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
90
- findTypeDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
91
- findImplementations: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.LocationLink[] | undefined>;
92
- prepareRename: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<NonNullable<vscode.Range | {
93
- range: vscode.Range;
94
- placeholder: string;
95
- } | {
96
- message: string;
97
- } | null | undefined> | undefined>;
98
- doRename: (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceEdit | undefined>;
99
- getEditsForFileRename: (oldUri: string, newUri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceEdit | undefined>;
100
- getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken | undefined, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
101
- doHover: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.Hover | undefined>;
102
- doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.CompletionList>;
103
- doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeAction[] | undefined>;
104
- doCodeActionResolve: (item: vscode.CodeAction, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeAction>;
105
- doCompletionResolve: (item: vscode.CompletionItem, token?: vscode.CancellationToken | undefined) => Promise<vscode.CompletionItem>;
106
- getSignatureHelp: (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext | undefined, token?: vscode.CancellationToken | undefined) => Promise<vscode.SignatureHelp | undefined>;
107
- doCodeLens: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeLens[]>;
108
- doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken | undefined) => Promise<vscode.CodeLens>;
109
- findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentHighlight[] | undefined>;
110
- findDocumentLinks: (uri: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentLink[]>;
111
- doDocumentLinkResolve: (item: vscode.DocumentLink, token?: vscode.CancellationToken | undefined) => Promise<vscode.DocumentLink>;
112
- findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken | undefined) => Promise<vscode.WorkspaceSymbol[]>;
113
- doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("@volar/language-service").AutoInsertionContext, token?: vscode.CancellationToken | undefined) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
114
- getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken | undefined) => Promise<vscode.InlayHint[] | undefined>;
115
- doInlayHintResolve: (item: vscode.InlayHint, token?: vscode.CancellationToken | undefined) => Promise<vscode.InlayHint>;
116
- callHierarchy: {
117
- doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken | undefined): Promise<vscode.CallHierarchyItem[] | undefined>;
118
- getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
119
- getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
120
- };
121
- dispose: () => void;
122
- context: import("@volar/language-service").ServiceContext<any>;
123
- } | undefined;
124
- getParsedCommandLine: () => ts.ParsedCommandLine;
125
- tryAddFile: (fileName: string) => void;
126
- askedFiles: {
127
- clear: () => void;
128
- values: () => IterableIterator<boolean>;
129
- uriKeys: () => IterableIterator<string>;
130
- uriDelete: (_uri: string) => boolean;
131
- uriGet: (_uri: string) => boolean | undefined;
132
- uriHas: (_uri: string) => boolean;
133
- uriSet: (_uri: string, item: boolean) => void;
134
- pathDelete: (path: string) => boolean;
135
- pathGet: (path: string) => boolean | undefined;
136
- pathHas: (path: string) => boolean | undefined;
137
- pathSet: (path: string, item: boolean) => void;
138
- };
139
- dispose: () => void;
140
- }>;
141
- //# sourceMappingURL=project.d.ts.map