@depup/vscode-languageserver 10.1.1-depup.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 (60) hide show
  1. package/License.txt +11 -0
  2. package/README.md +25 -0
  3. package/bin/installServerIntoExtension +73 -0
  4. package/changes.json +5 -0
  5. package/eslint.config.js +10 -0
  6. package/lib/browser/main.d.ts +20 -0
  7. package/lib/browser/main.js +61 -0
  8. package/lib/common/api.d.ts +15 -0
  9. package/lib/common/api.js +35 -0
  10. package/lib/common/callHierarchy.d.ts +15 -0
  11. package/lib/common/callHierarchy.js +34 -0
  12. package/lib/common/configuration.d.ts +9 -0
  13. package/lib/common/configuration.js +71 -0
  14. package/lib/common/diagnostic.d.ts +29 -0
  15. package/lib/common/diagnostic.js +30 -0
  16. package/lib/common/fileOperations.d.ts +16 -0
  17. package/lib/common/fileOperations.js +43 -0
  18. package/lib/common/foldingRange.d.ts +22 -0
  19. package/lib/common/foldingRange.js +26 -0
  20. package/lib/common/inlayHint.d.ts +28 -0
  21. package/lib/common/inlayHint.js +30 -0
  22. package/lib/common/inlineCompletion.d.ts +18 -0
  23. package/lib/common/inlineCompletion.js +22 -0
  24. package/lib/common/inlineValue.d.ts +22 -0
  25. package/lib/common/inlineValue.js +25 -0
  26. package/lib/common/linkedEditingRange.d.ts +16 -0
  27. package/lib/common/linkedEditingRange.js +18 -0
  28. package/lib/common/moniker.d.ts +13 -0
  29. package/lib/common/moniker.js +23 -0
  30. package/lib/common/notebook.d.ts +99 -0
  31. package/lib/common/notebook.js +262 -0
  32. package/lib/common/progress.d.ts +25 -0
  33. package/lib/common/progress.js +172 -0
  34. package/lib/common/semanticTokens.d.ts +43 -0
  35. package/lib/common/semanticTokens.js +251 -0
  36. package/lib/common/server.d.ts +812 -0
  37. package/lib/common/server.js +798 -0
  38. package/lib/common/showDocument.d.ts +6 -0
  39. package/lib/common/showDocument.js +16 -0
  40. package/lib/common/textDocumentContent.d.ts +14 -0
  41. package/lib/common/textDocumentContent.js +25 -0
  42. package/lib/common/textDocuments.d.ts +133 -0
  43. package/lib/common/textDocuments.js +180 -0
  44. package/lib/common/typeHierarchy.d.ts +15 -0
  45. package/lib/common/typeHierarchy.js +34 -0
  46. package/lib/common/utils/is.d.ts +9 -0
  47. package/lib/common/utils/is.js +42 -0
  48. package/lib/common/utils/uuid.d.ts +22 -0
  49. package/lib/common/utils/uuid.js +98 -0
  50. package/lib/common/workspaceFolder.d.ts +7 -0
  51. package/lib/common/workspaceFolder.js +47 -0
  52. package/lib/node/files.d.ts +19 -0
  53. package/lib/node/files.js +295 -0
  54. package/lib/node/main.d.ts +60 -0
  55. package/lib/node/main.js +295 -0
  56. package/lib/node/resolve.d.ts +1 -0
  57. package/lib/node/resolve.js +20 -0
  58. package/package.json +65 -0
  59. package/thirdpartynotices.txt +84 -0
  60. package/typings/thenable.d.ts +5 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ /* --------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ * ------------------------------------------------------------------------------------------ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ProgressFeature = void 0;
8
+ exports.attachWorkDone = attachWorkDone;
9
+ exports.attachPartialResult = attachPartialResult;
10
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
11
+ const uuid_1 = require("./utils/uuid");
12
+ class WorkDoneProgressReporterImpl {
13
+ _connection;
14
+ _token;
15
+ static Instances = new Map();
16
+ constructor(_connection, _token) {
17
+ this._connection = _connection;
18
+ this._token = _token;
19
+ WorkDoneProgressReporterImpl.Instances.set(this._token, this);
20
+ }
21
+ begin(title, percentage, message, cancellable) {
22
+ const param = {
23
+ kind: 'begin',
24
+ title,
25
+ message,
26
+ cancellable
27
+ };
28
+ if (typeof percentage === 'number') {
29
+ // Round to the nearest integer, because the percentage
30
+ // is a uinteger according to the specification
31
+ param.percentage = Math.round(percentage);
32
+ }
33
+ this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
34
+ }
35
+ report(arg0, arg1) {
36
+ const param = {
37
+ kind: 'report'
38
+ };
39
+ if (typeof arg0 === 'number') {
40
+ // Round to the nearest integer, because the percentage
41
+ // is a uinteger according to the specification
42
+ param.percentage = Math.round(arg0);
43
+ if (arg1 !== undefined) {
44
+ param.message = arg1;
45
+ }
46
+ }
47
+ else {
48
+ param.message = arg0;
49
+ }
50
+ this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, param);
51
+ }
52
+ done() {
53
+ WorkDoneProgressReporterImpl.Instances.delete(this._token);
54
+ this._connection.sendProgress(vscode_languageserver_protocol_1.WorkDoneProgress.type, this._token, { kind: 'end' });
55
+ }
56
+ }
57
+ class WorkDoneProgressServerReporterImpl extends WorkDoneProgressReporterImpl {
58
+ _source;
59
+ constructor(connection, token) {
60
+ super(connection, token);
61
+ this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
62
+ }
63
+ get token() {
64
+ return this._source.token;
65
+ }
66
+ done() {
67
+ this._source.dispose();
68
+ super.done();
69
+ }
70
+ cancel() {
71
+ this._source.cancel();
72
+ }
73
+ }
74
+ class NullProgressReporter {
75
+ constructor() {
76
+ }
77
+ begin() {
78
+ }
79
+ report() {
80
+ }
81
+ done() {
82
+ }
83
+ }
84
+ class NullProgressServerReporter extends NullProgressReporter {
85
+ _source;
86
+ constructor() {
87
+ super();
88
+ this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();
89
+ }
90
+ get token() {
91
+ return this._source.token;
92
+ }
93
+ done() {
94
+ this._source.dispose();
95
+ }
96
+ cancel() {
97
+ this._source.cancel();
98
+ }
99
+ }
100
+ function attachWorkDone(connection, params) {
101
+ if (params === undefined || params.workDoneToken === undefined) {
102
+ return new NullProgressReporter();
103
+ }
104
+ const token = params.workDoneToken;
105
+ delete params.workDoneToken;
106
+ return new WorkDoneProgressReporterImpl(connection, token);
107
+ }
108
+ const ProgressFeature = (Base) => {
109
+ return class extends Base {
110
+ _progressSupported;
111
+ constructor() {
112
+ super();
113
+ this._progressSupported = false;
114
+ }
115
+ initialize(capabilities) {
116
+ super.initialize(capabilities);
117
+ if (capabilities?.window?.workDoneProgress === true) {
118
+ this._progressSupported = true;
119
+ this.connection.onNotification(vscode_languageserver_protocol_1.WorkDoneProgressCancelNotification.type, (params) => {
120
+ const progress = WorkDoneProgressReporterImpl.Instances.get(params.token);
121
+ if (progress instanceof WorkDoneProgressServerReporterImpl || progress instanceof NullProgressServerReporter) {
122
+ progress.cancel();
123
+ }
124
+ });
125
+ }
126
+ }
127
+ attachWorkDoneProgress(token) {
128
+ if (token === undefined) {
129
+ return new NullProgressReporter();
130
+ }
131
+ else {
132
+ return new WorkDoneProgressReporterImpl(this.connection, token);
133
+ }
134
+ }
135
+ createWorkDoneProgress() {
136
+ if (this._progressSupported) {
137
+ const token = (0, uuid_1.generateUuid)();
138
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkDoneProgressCreateRequest.type, { token }).then(() => {
139
+ const result = new WorkDoneProgressServerReporterImpl(this.connection, token);
140
+ return result;
141
+ });
142
+ }
143
+ else {
144
+ return Promise.resolve(new NullProgressServerReporter());
145
+ }
146
+ }
147
+ };
148
+ };
149
+ exports.ProgressFeature = ProgressFeature;
150
+ var ResultProgress;
151
+ (function (ResultProgress) {
152
+ ResultProgress.type = new vscode_languageserver_protocol_1.ProgressType();
153
+ })(ResultProgress || (ResultProgress = {}));
154
+ class ResultProgressReporterImpl {
155
+ _connection;
156
+ _token;
157
+ constructor(_connection, _token) {
158
+ this._connection = _connection;
159
+ this._token = _token;
160
+ }
161
+ report(data) {
162
+ this._connection.sendProgress(ResultProgress.type, this._token, data);
163
+ }
164
+ }
165
+ function attachPartialResult(connection, params) {
166
+ if (params === undefined || params.partialResultToken === undefined) {
167
+ return undefined;
168
+ }
169
+ const token = params.partialResultToken;
170
+ delete params.partialResultToken;
171
+ return new ResultProgressReporterImpl(connection, token);
172
+ }
@@ -0,0 +1,43 @@
1
+ import { SemanticTokens, SemanticTokensPartialResult, SemanticTokensDelta, SemanticTokensDeltaPartialResult, SemanticTokensParams, SemanticTokensDeltaParams, SemanticTokensRangeParams, SemanticTokensEdit, Disposable } from 'vscode-languageserver-protocol';
2
+ import type { Feature, _Languages, ServerRequestHandler } from './server';
3
+ /**
4
+ * Shape of the semantic token feature
5
+ *
6
+ * @since 3.16.0
7
+ */
8
+ export interface SemanticTokensFeatureShape {
9
+ semanticTokens: {
10
+ refresh(): Promise<void>;
11
+ on(handler: ServerRequestHandler<SemanticTokensParams, SemanticTokens | undefined | null, SemanticTokensPartialResult, void>): Disposable;
12
+ onDelta(handler: ServerRequestHandler<SemanticTokensDeltaParams, SemanticTokensDelta | SemanticTokens | undefined | null, SemanticTokensDeltaPartialResult | SemanticTokensPartialResult, void>): Disposable;
13
+ onRange(handler: ServerRequestHandler<SemanticTokensRangeParams, SemanticTokens | undefined | null, SemanticTokensPartialResult, void>): Disposable;
14
+ };
15
+ }
16
+ export declare const SemanticTokensFeature: Feature<_Languages, SemanticTokensFeatureShape>;
17
+ export declare class SemanticTokensDiff {
18
+ private readonly originalSequence;
19
+ private readonly modifiedSequence;
20
+ constructor(originalSequence: number[], modifiedSequence: number[]);
21
+ computeDiff(): SemanticTokensEdit[];
22
+ }
23
+ export declare class SemanticTokensBuilder {
24
+ private _id;
25
+ private _prevLine;
26
+ private _prevChar;
27
+ private _dataIsSortedAndDeltaEncoded;
28
+ private _data;
29
+ private _dataNonDelta;
30
+ private _dataLen;
31
+ private _prevData;
32
+ constructor();
33
+ private initialize;
34
+ push(line: number, char: number, length: number, tokenType: number, tokenModifiers: number): void;
35
+ get id(): string;
36
+ private static _deltaDecode;
37
+ private static _sortAndDeltaEncode;
38
+ private getFinalDataDelta;
39
+ previousResult(id: string): void;
40
+ build(): SemanticTokens;
41
+ canBuildEdits(): boolean;
42
+ buildEdits(): SemanticTokens | SemanticTokensDelta;
43
+ }
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ /* --------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ * ------------------------------------------------------------------------------------------ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SemanticTokensBuilder = exports.SemanticTokensDiff = exports.SemanticTokensFeature = void 0;
8
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
9
+ const SemanticTokensFeature = (Base) => {
10
+ return class extends Base {
11
+ get semanticTokens() {
12
+ return {
13
+ refresh: () => {
14
+ return this.connection.sendRequest(vscode_languageserver_protocol_1.SemanticTokensRefreshRequest.type);
15
+ },
16
+ on: (handler) => {
17
+ const type = vscode_languageserver_protocol_1.SemanticTokensRequest.type;
18
+ return this.connection.onRequest(type, (params, cancel) => {
19
+ return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
20
+ });
21
+ },
22
+ onDelta: (handler) => {
23
+ const type = vscode_languageserver_protocol_1.SemanticTokensDeltaRequest.type;
24
+ return this.connection.onRequest(type, (params, cancel) => {
25
+ return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
26
+ });
27
+ },
28
+ onRange: (handler) => {
29
+ const type = vscode_languageserver_protocol_1.SemanticTokensRangeRequest.type;
30
+ return this.connection.onRequest(type, (params, cancel) => {
31
+ return handler(params, cancel, this.attachWorkDoneProgress(params), this.attachPartialResultProgress(type, params));
32
+ });
33
+ }
34
+ };
35
+ }
36
+ };
37
+ };
38
+ exports.SemanticTokensFeature = SemanticTokensFeature;
39
+ class SemanticTokensDiff {
40
+ originalSequence;
41
+ modifiedSequence;
42
+ constructor(originalSequence, modifiedSequence) {
43
+ this.originalSequence = originalSequence;
44
+ this.modifiedSequence = modifiedSequence;
45
+ }
46
+ computeDiff() {
47
+ const originalLength = this.originalSequence.length;
48
+ const modifiedLength = this.modifiedSequence.length;
49
+ let startIndex = 0;
50
+ while (startIndex < modifiedLength && startIndex < originalLength && this.originalSequence[startIndex] === this.modifiedSequence[startIndex]) {
51
+ startIndex++;
52
+ }
53
+ if (startIndex < modifiedLength && startIndex < originalLength) {
54
+ let originalEndIndex = originalLength - 1;
55
+ let modifiedEndIndex = modifiedLength - 1;
56
+ while (originalEndIndex >= startIndex && modifiedEndIndex >= startIndex && this.originalSequence[originalEndIndex] === this.modifiedSequence[modifiedEndIndex]) {
57
+ originalEndIndex--;
58
+ modifiedEndIndex--;
59
+ }
60
+ // if one moved behind the start index move them forward again
61
+ if (originalEndIndex < startIndex || modifiedEndIndex < startIndex) {
62
+ originalEndIndex++;
63
+ modifiedEndIndex++;
64
+ }
65
+ const deleteCount = originalEndIndex - startIndex + 1;
66
+ const newData = this.modifiedSequence.slice(startIndex, modifiedEndIndex + 1);
67
+ // If we moved behind the start index we could have missed a simple delete.
68
+ if (newData.length === 1 && newData[0] === this.originalSequence[originalEndIndex]) {
69
+ return [
70
+ { start: startIndex, deleteCount: deleteCount - 1 }
71
+ ];
72
+ }
73
+ else {
74
+ return [
75
+ { start: startIndex, deleteCount, data: newData }
76
+ ];
77
+ }
78
+ }
79
+ else if (startIndex < modifiedLength) {
80
+ return [
81
+ { start: startIndex, deleteCount: 0, data: this.modifiedSequence.slice(startIndex) }
82
+ ];
83
+ }
84
+ else if (startIndex < originalLength) {
85
+ return [
86
+ { start: startIndex, deleteCount: originalLength - startIndex }
87
+ ];
88
+ }
89
+ else {
90
+ // The two arrays are the same.
91
+ return [];
92
+ }
93
+ }
94
+ }
95
+ exports.SemanticTokensDiff = SemanticTokensDiff;
96
+ class SemanticTokensBuilder {
97
+ _id;
98
+ _prevLine;
99
+ _prevChar;
100
+ _dataIsSortedAndDeltaEncoded;
101
+ _data;
102
+ _dataNonDelta;
103
+ _dataLen;
104
+ _prevData;
105
+ constructor() {
106
+ this._prevData = undefined;
107
+ this.initialize();
108
+ }
109
+ initialize() {
110
+ this._id = Date.now();
111
+ this._prevLine = 0;
112
+ this._prevChar = 0;
113
+ this._data = [];
114
+ this._dataNonDelta = [];
115
+ this._dataLen = 0;
116
+ this._dataIsSortedAndDeltaEncoded = true;
117
+ }
118
+ push(line, char, length, tokenType, tokenModifiers) {
119
+ if (this._dataIsSortedAndDeltaEncoded && (line < this._prevLine || (line === this._prevLine && char < this._prevChar))) {
120
+ // push calls were ordered and are no longer ordered
121
+ this._dataIsSortedAndDeltaEncoded = false;
122
+ this._dataNonDelta = SemanticTokensBuilder._deltaDecode(this._data);
123
+ }
124
+ let pushLine = line;
125
+ let pushChar = char;
126
+ if (this._dataIsSortedAndDeltaEncoded && this._dataLen > 0) {
127
+ pushLine -= this._prevLine;
128
+ if (pushLine === 0) {
129
+ pushChar -= this._prevChar;
130
+ }
131
+ }
132
+ const dataSource = this._dataIsSortedAndDeltaEncoded ? this._data : this._dataNonDelta;
133
+ dataSource[this._dataLen++] = pushLine;
134
+ dataSource[this._dataLen++] = pushChar;
135
+ dataSource[this._dataLen++] = length;
136
+ dataSource[this._dataLen++] = tokenType;
137
+ dataSource[this._dataLen++] = tokenModifiers;
138
+ this._prevLine = line;
139
+ this._prevChar = char;
140
+ }
141
+ get id() {
142
+ return this._id.toString();
143
+ }
144
+ static _deltaDecode(data) {
145
+ // Remove delta encoding from data
146
+ const tokenCount = (data.length / 5) | 0;
147
+ let prevLine = 0;
148
+ let prevChar = 0;
149
+ const result = [];
150
+ for (let i = 0; i < tokenCount; i++) {
151
+ const dstOffset = 5 * i;
152
+ let line = data[dstOffset];
153
+ let char = data[dstOffset + 1];
154
+ if (line === 0) {
155
+ // on the same line as previous token
156
+ line = prevLine;
157
+ char += prevChar;
158
+ }
159
+ else {
160
+ // on a different line than previous token
161
+ line += prevLine;
162
+ }
163
+ const length = data[dstOffset + 2];
164
+ const tokenType = data[dstOffset + 3];
165
+ const tokenModifiers = data[dstOffset + 4];
166
+ result[dstOffset + 0] = line;
167
+ result[dstOffset + 1] = char;
168
+ result[dstOffset + 2] = length;
169
+ result[dstOffset + 3] = tokenType;
170
+ result[dstOffset + 4] = tokenModifiers;
171
+ prevLine = line;
172
+ prevChar = char;
173
+ }
174
+ return result;
175
+ }
176
+ static _sortAndDeltaEncode(data) {
177
+ const pos = [];
178
+ const tokenCount = (data.length / 5) | 0;
179
+ for (let i = 0; i < tokenCount; i++) {
180
+ pos[i] = i;
181
+ }
182
+ pos.sort((a, b) => {
183
+ const aLine = data[5 * a];
184
+ const bLine = data[5 * b];
185
+ if (aLine === bLine) {
186
+ const aChar = data[5 * a + 1];
187
+ const bChar = data[5 * b + 1];
188
+ return aChar - bChar;
189
+ }
190
+ return aLine - bLine;
191
+ });
192
+ const result = [];
193
+ let prevLine = 0;
194
+ let prevChar = 0;
195
+ for (let i = 0; i < tokenCount; i++) {
196
+ const srcOffset = 5 * pos[i];
197
+ const line = data[srcOffset + 0];
198
+ const char = data[srcOffset + 1];
199
+ const length = data[srcOffset + 2];
200
+ const tokenType = data[srcOffset + 3];
201
+ const tokenModifiers = data[srcOffset + 4];
202
+ const pushLine = line - prevLine;
203
+ const pushChar = (pushLine === 0 ? char - prevChar : char);
204
+ const dstOffset = 5 * i;
205
+ result[dstOffset + 0] = pushLine;
206
+ result[dstOffset + 1] = pushChar;
207
+ result[dstOffset + 2] = length;
208
+ result[dstOffset + 3] = tokenType;
209
+ result[dstOffset + 4] = tokenModifiers;
210
+ prevLine = line;
211
+ prevChar = char;
212
+ }
213
+ return result;
214
+ }
215
+ getFinalDataDelta() {
216
+ if (this._dataIsSortedAndDeltaEncoded) {
217
+ return this._data;
218
+ }
219
+ else {
220
+ return SemanticTokensBuilder._sortAndDeltaEncode(this._dataNonDelta);
221
+ }
222
+ }
223
+ previousResult(id) {
224
+ if (this.id === id) {
225
+ this._prevData = this.getFinalDataDelta();
226
+ }
227
+ this.initialize();
228
+ }
229
+ build() {
230
+ this._prevData = undefined;
231
+ return {
232
+ resultId: this.id,
233
+ data: this.getFinalDataDelta()
234
+ };
235
+ }
236
+ canBuildEdits() {
237
+ return this._prevData !== undefined;
238
+ }
239
+ buildEdits() {
240
+ if (this._prevData !== undefined) {
241
+ return {
242
+ resultId: this.id,
243
+ edits: (new SemanticTokensDiff(this._prevData, this.getFinalDataDelta())).computeDiff()
244
+ };
245
+ }
246
+ else {
247
+ return this.build();
248
+ }
249
+ }
250
+ }
251
+ exports.SemanticTokensBuilder = SemanticTokensBuilder;