@codingame/monaco-languageclient-wrapper 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cobol.js +31 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -18826
- package/dist/index2.js +17986 -0
- package/dist/java.js +988 -0
- package/dist/tools.js +117 -0
- package/package.json +34 -34
- package/stats.html +1 -1
package/dist/java.js
ADDED
|
@@ -0,0 +1,988 @@
|
|
|
1
|
+
import { EventEmitter, InlayHint, InlayHintKind, workspace, commands, window, TextEditorRevealType, Uri, ViewColumn, languages } from 'vscode';
|
|
2
|
+
import { a as api, m as main } from './index2.js';
|
|
3
|
+
import { E as ExtensionFeature } from './tools.js';
|
|
4
|
+
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
Copyright (c) Microsoft Corporation.
|
|
7
|
+
|
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
+
purpose with or without fee is hereby granted.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
***************************************************************************** */
|
|
19
|
+
|
|
20
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class JavaInlayHintsProvider {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
this.onDidChange = /*#__PURE__*/ new EventEmitter();
|
|
34
|
+
this.onDidChangeInlayHints = this.onDidChange.event;
|
|
35
|
+
this.client.onRequest(InlayHintRefreshRequest.type, () => /*#__PURE__*/ __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
this.onDidChange.fire();
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
provideInlayHints(document, range, token) {
|
|
41
|
+
return (
|
|
42
|
+
/*#__PURE__*/ __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const requestParams = {
|
|
44
|
+
textDocument: this.client.code2ProtocolConverter.asTextDocumentIdentifier(document),
|
|
45
|
+
range: this.client.code2ProtocolConverter.asRange(range)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const values = yield this.client.sendRequest(InlayHintRequest.type, requestParams, token);
|
|
50
|
+
|
|
51
|
+
if (token.isCancellationRequested) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
/*#__PURE__*/ asInlayHints(values, this.client)
|
|
57
|
+
);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return this.client.handleFailedRequest(InlayHintRequest.type, token, error, []);
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
var InlayHintRequest;
|
|
67
|
+
|
|
68
|
+
/*#__PURE__*/ (function(InlayHintRequest) {
|
|
69
|
+
InlayHintRequest.type = /*#__PURE__*/ new api.RequestType('textDocument/inlayHint');
|
|
70
|
+
})(InlayHintRequest || (InlayHintRequest = {}));
|
|
71
|
+
/**
|
|
72
|
+
* @since 3.17.0 - proposed state
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var InlayHintRefreshRequest;
|
|
77
|
+
|
|
78
|
+
/*#__PURE__*/ (function(InlayHintRefreshRequest) {
|
|
79
|
+
InlayHintRefreshRequest.type = /*#__PURE__*/ new api.RequestType('workspace/inlayHint/refresh');
|
|
80
|
+
})(InlayHintRefreshRequest || (InlayHintRefreshRequest = {}));
|
|
81
|
+
|
|
82
|
+
function asInlayHints(values, client) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (!Array.isArray(values)) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return values.map(lsHint => asInlayHint(lsHint, client));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function asInlayHint(value, client) {
|
|
93
|
+
const label = value.label;
|
|
94
|
+
const result = new InlayHint(client.protocol2CodeConverter.asPosition(value.position), label);
|
|
95
|
+
result.paddingRight = true;
|
|
96
|
+
result.kind = InlayHintKind.Parameter;
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Commonly used commands
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
var Commands;
|
|
105
|
+
|
|
106
|
+
/*#__PURE__*/ (function(Commands) {
|
|
107
|
+
/**
|
|
108
|
+
* Open Browser
|
|
109
|
+
*/
|
|
110
|
+
Commands.OPEN_BROWSER = 'vscode.open';
|
|
111
|
+
/**
|
|
112
|
+
* Open Output view
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
Commands.OPEN_OUTPUT = 'java.open.output';
|
|
116
|
+
/**
|
|
117
|
+
* Show Java references
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
Commands.SHOW_JAVA_REFERENCES = 'java.show.references';
|
|
121
|
+
/**
|
|
122
|
+
* Show Java implementations
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
Commands.SHOW_JAVA_IMPLEMENTATIONS = 'java.show.implementations';
|
|
126
|
+
/**
|
|
127
|
+
* Show editor references
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
Commands.SHOW_REFERENCES = 'editor.action.showReferences';
|
|
131
|
+
/**
|
|
132
|
+
* Go to editor location
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
Commands.GOTO_LOCATION = 'editor.action.goToLocations';
|
|
136
|
+
/**
|
|
137
|
+
* Render markdown string to html string
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
Commands.MARKDOWN_API_RENDER = 'markdown.api.render';
|
|
141
|
+
/**
|
|
142
|
+
* Reload project
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
Commands.CONFIGURATION_UPDATE = 'java.projectConfiguration.update';
|
|
146
|
+
/**
|
|
147
|
+
* Ignore "Incomplete Classpath" messages
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
Commands.IGNORE_INCOMPLETE_CLASSPATH = 'java.ignoreIncompleteClasspath';
|
|
151
|
+
/**
|
|
152
|
+
* Open help for "Incomplete Classpath" message
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
Commands.IGNORE_INCOMPLETE_CLASSPATH_HELP = 'java.ignoreIncompleteClasspath.help';
|
|
156
|
+
/**
|
|
157
|
+
* Reload VS Code window
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
Commands.RELOAD_WINDOW = 'workbench.action.reloadWindow';
|
|
161
|
+
/**
|
|
162
|
+
* Set project configuration update mode
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
Commands.PROJECT_CONFIGURATION_STATUS = 'java.projectConfiguration.status';
|
|
166
|
+
/**
|
|
167
|
+
* Apply Workspace Edit
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
Commands.APPLY_WORKSPACE_EDIT = 'java.apply.workspaceEdit';
|
|
171
|
+
/**
|
|
172
|
+
* Execute Workspace Command
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
Commands.EXECUTE_WORKSPACE_COMMAND = 'java.execute.workspaceCommand';
|
|
176
|
+
/**
|
|
177
|
+
* Execute Workspace build (compilation)
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
Commands.COMPILE_WORKSPACE = 'java.workspace.compile';
|
|
181
|
+
/**
|
|
182
|
+
* Execute build for projects
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
Commands.BUILD_PROJECT = 'java.project.build';
|
|
186
|
+
/**
|
|
187
|
+
* Open Java Language Server Log file
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
Commands.OPEN_SERVER_LOG = 'java.open.serverLog';
|
|
191
|
+
/**
|
|
192
|
+
* Open Java Language Service Output Log file
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
Commands.OPEN_SERVER_STDOUT_LOG = 'java.open.serverStdoutLog';
|
|
196
|
+
/**
|
|
197
|
+
* Open Java Language Server Error Log file
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
Commands.OPEN_SERVER_STDERR_LOG = 'java.open.serverStderrLog';
|
|
201
|
+
/**
|
|
202
|
+
* Open Java client Log file
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
Commands.OPEN_CLIENT_LOG = 'java.open.clientLog';
|
|
206
|
+
/**
|
|
207
|
+
* Open Java log files side by side
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
Commands.OPEN_LOGS = 'java.open.logs';
|
|
211
|
+
/**
|
|
212
|
+
* Open Java formatter settings
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
Commands.OPEN_FORMATTER = 'java.open.formatter.settings';
|
|
216
|
+
/**
|
|
217
|
+
* Clean the Java language server workspace
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
Commands.CLEAN_WORKSPACE = 'java.clean.workspace';
|
|
221
|
+
/**
|
|
222
|
+
* Update the source attachment for the selected class file
|
|
223
|
+
* client-side & server-side commands
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
Commands.UPDATE_SOURCE_ATTACHMENT_CMD = 'java.project.updateSourceAttachment.command';
|
|
227
|
+
Commands.UPDATE_SOURCE_ATTACHMENT = 'java.project.updateSourceAttachment';
|
|
228
|
+
/**
|
|
229
|
+
* Resolve the source attachment information for the selected class file
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
Commands.RESOLVE_SOURCE_ATTACHMENT = 'java.project.resolveSourceAttachment';
|
|
233
|
+
/**
|
|
234
|
+
* Mark the folder as the source root of the closest project.
|
|
235
|
+
* client-side & server-side commands
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
Commands.ADD_TO_SOURCEPATH_CMD = 'java.project.addToSourcePath.command';
|
|
239
|
+
Commands.ADD_TO_SOURCEPATH = 'java.project.addToSourcePath';
|
|
240
|
+
/**
|
|
241
|
+
* Unmark the folder as the source root of the project.
|
|
242
|
+
* client-side & server-side commands
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
Commands.REMOVE_FROM_SOURCEPATH_CMD = 'java.project.removeFromSourcePath.command';
|
|
246
|
+
Commands.REMOVE_FROM_SOURCEPATH = 'java.project.removeFromSourcePath';
|
|
247
|
+
/**
|
|
248
|
+
* List all recognized source roots in the workspace.
|
|
249
|
+
* client-side & server-side commands
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
Commands.LIST_SOURCEPATHS_CMD = 'java.project.listSourcePaths.command';
|
|
253
|
+
Commands.LIST_SOURCEPATHS = 'java.project.listSourcePaths';
|
|
254
|
+
/**
|
|
255
|
+
* Import new projects
|
|
256
|
+
* client-side & server-side commands
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
Commands.IMPORT_PROJECTS_CMD = 'java.project.import.command';
|
|
260
|
+
Commands.IMPORT_PROJECTS = 'java.project.import';
|
|
261
|
+
/**
|
|
262
|
+
* Override or implements the methods from the supertypes.
|
|
263
|
+
*/
|
|
264
|
+
|
|
265
|
+
Commands.OVERRIDE_METHODS_PROMPT = 'java.action.overrideMethodsPrompt';
|
|
266
|
+
/**
|
|
267
|
+
* Generate hashCode() and equals().
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
Commands.HASHCODE_EQUALS_PROMPT = 'java.action.hashCodeEqualsPrompt';
|
|
271
|
+
/**
|
|
272
|
+
* Open settings.json
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
Commands.OPEN_JSON_SETTINGS = 'workbench.action.openSettingsJson';
|
|
276
|
+
/**
|
|
277
|
+
* Organize imports.
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
Commands.ORGANIZE_IMPORTS = "java.action.organizeImports";
|
|
281
|
+
/**
|
|
282
|
+
* Organize imports silently.
|
|
283
|
+
*/
|
|
284
|
+
|
|
285
|
+
Commands.ORGANIZE_IMPORTS_SILENTLY = "java.edit.organizeImports";
|
|
286
|
+
/**
|
|
287
|
+
* Custom paste action (triggers auto-import)
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
Commands.CLIPBOARD_ONPASTE = 'java.action.clipboardPasteAction';
|
|
291
|
+
/**
|
|
292
|
+
* Choose type to import.
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
Commands.CHOOSE_IMPORTS = "java.action.organizeImports.chooseImports";
|
|
296
|
+
/**
|
|
297
|
+
* Generate toString().
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
Commands.GENERATE_TOSTRING_PROMPT = 'java.action.generateToStringPrompt';
|
|
301
|
+
/**
|
|
302
|
+
* Generate Getters and Setters.
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
Commands.GENERATE_ACCESSORS_PROMPT = 'java.action.generateAccessorsPrompt';
|
|
306
|
+
/**
|
|
307
|
+
* Generate Constructors.
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
Commands.GENERATE_CONSTRUCTORS_PROMPT = 'java.action.generateConstructorsPrompt';
|
|
311
|
+
/**
|
|
312
|
+
* Generate Delegate Methods.
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
Commands.GENERATE_DELEGATE_METHODS_PROMPT = 'java.action.generateDelegateMethodsPrompt';
|
|
316
|
+
/**
|
|
317
|
+
* Apply Refactoring Command.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
Commands.APPLY_REFACTORING_COMMAND = 'java.action.applyRefactoringCommand';
|
|
321
|
+
/**
|
|
322
|
+
* Rename Command.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
Commands.RENAME_COMMAND = 'java.action.rename';
|
|
326
|
+
/**
|
|
327
|
+
* Navigate To Super Method Command.
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
Commands.NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND = 'java.action.navigateToSuperImplementation';
|
|
331
|
+
/**
|
|
332
|
+
* Open Type Hierarchy of given Selection.
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
Commands.SHOW_TYPE_HIERARCHY = 'java.action.showTypeHierarchy';
|
|
336
|
+
/**
|
|
337
|
+
* Show SuperType Hierarchy of given Selection.
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
Commands.SHOW_SUPERTYPE_HIERARCHY = 'java.action.showSupertypeHierarchy';
|
|
341
|
+
/**
|
|
342
|
+
* Show SubType Hierarchy of given Selection.
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
Commands.SHOW_SUBTYPE_HIERARCHY = 'java.action.showSubtypeHierarchy';
|
|
346
|
+
/**
|
|
347
|
+
* Show Type Hierarchy of given Selection.
|
|
348
|
+
*/
|
|
349
|
+
|
|
350
|
+
Commands.SHOW_CLASS_HIERARCHY = 'java.action.showClassHierarchy';
|
|
351
|
+
/**
|
|
352
|
+
* Change the base type of Type Hierarchy.
|
|
353
|
+
*/
|
|
354
|
+
|
|
355
|
+
Commands.CHANGE_BASE_TYPE = 'java.action.changeBaseType';
|
|
356
|
+
/**
|
|
357
|
+
* Open the given TypeHierarchy Item.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
Commands.OPEN_TYPE_HIERARCHY = 'java.navigate.openTypeHierarchy';
|
|
361
|
+
/**
|
|
362
|
+
* Resolve the given TypeHierarchy Item.
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
Commands.RESOLVE_TYPE_HIERARCHY = 'java.navigate.resolveTypeHierarchy';
|
|
366
|
+
/**
|
|
367
|
+
* Show server task status
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
Commands.SHOW_SERVER_TASK_STATUS = 'java.show.server.task.status';
|
|
371
|
+
/**
|
|
372
|
+
* Get the project settings
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
Commands.GET_PROJECT_SETTINGS = 'java.project.getSettings';
|
|
376
|
+
/**
|
|
377
|
+
* Get the classpaths and modulepaths
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
Commands.GET_CLASSPATHS = 'java.project.getClasspaths';
|
|
381
|
+
/**
|
|
382
|
+
* Check the input file is a test file or not
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
Commands.IS_TEST_FILE = 'java.project.isTestFile';
|
|
386
|
+
/**
|
|
387
|
+
* Get all java projects root path in URI format
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
Commands.GET_ALL_JAVA_PROJECTS = 'java.project.getAll';
|
|
391
|
+
/**
|
|
392
|
+
* Command to switch between standard mode and lightweight mode.
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
Commands.SWITCH_SERVER_MODE = 'java.server.mode.switch';
|
|
396
|
+
Commands.LEARN_MORE_ABOUT_REFACTORING = '_java.learnMoreAboutRefactorings';
|
|
397
|
+
Commands.TEMPLATE_VARIABLES = '_java.templateVariables';
|
|
398
|
+
Commands.NOT_COVERED_EXECUTION = '_java.notCoveredExecution';
|
|
399
|
+
Commands.MEATDATA_FILES_GENERATION = '_java.metadataFilesGeneration';
|
|
400
|
+
Commands.RUNTIME_VALIDATION_OPEN = 'java.runtimeValidation.open';
|
|
401
|
+
Commands.RESOLVE_WORKSPACE_SYMBOL = 'java.project.resolveWorkspaceSymbol';
|
|
402
|
+
Commands.GET_WORKSPACE_PATH = '_java.workspace.path';
|
|
403
|
+
Commands.UPGRADE_GRADLE_WRAPPER = '_java.gradle.upgradeWrapper';
|
|
404
|
+
Commands.LOMBOK_CONFIGURE = "java.lombokConfigure";
|
|
405
|
+
})(Commands || (Commands = {}));
|
|
406
|
+
|
|
407
|
+
var AccessorKind;
|
|
408
|
+
|
|
409
|
+
/*#__PURE__*/ (function(AccessorKind) {
|
|
410
|
+
AccessorKind[AccessorKind["GETTER"] = 0] = "GETTER";
|
|
411
|
+
AccessorKind[AccessorKind["SETTER"] = 1] = "SETTER";
|
|
412
|
+
AccessorKind[AccessorKind["BOTH"] = 2] = "BOTH";
|
|
413
|
+
})(AccessorKind || (AccessorKind = {}));
|
|
414
|
+
|
|
415
|
+
var ClassFileContentsRequest;
|
|
416
|
+
|
|
417
|
+
/*#__PURE__*/ (function(ClassFileContentsRequest) {
|
|
418
|
+
ClassFileContentsRequest.type = /*#__PURE__*/ new main.RequestType('java/classFileContents');
|
|
419
|
+
})(ClassFileContentsRequest || (ClassFileContentsRequest = {}));
|
|
420
|
+
|
|
421
|
+
var ListOverridableMethodsRequest;
|
|
422
|
+
|
|
423
|
+
/*#__PURE__*/ (function(ListOverridableMethodsRequest) {
|
|
424
|
+
ListOverridableMethodsRequest.type = /*#__PURE__*/ new main.RequestType('java/listOverridableMethods');
|
|
425
|
+
})(ListOverridableMethodsRequest || (ListOverridableMethodsRequest = {}));
|
|
426
|
+
|
|
427
|
+
var AddOverridableMethodsRequest;
|
|
428
|
+
|
|
429
|
+
/*#__PURE__*/ (function(AddOverridableMethodsRequest) {
|
|
430
|
+
AddOverridableMethodsRequest.type = /*#__PURE__*/ new main.RequestType('java/addOverridableMethods');
|
|
431
|
+
})(AddOverridableMethodsRequest || (AddOverridableMethodsRequest = {}));
|
|
432
|
+
|
|
433
|
+
var CheckHashCodeEqualsStatusRequest;
|
|
434
|
+
|
|
435
|
+
/*#__PURE__*/ (function(CheckHashCodeEqualsStatusRequest) {
|
|
436
|
+
CheckHashCodeEqualsStatusRequest.type = /*#__PURE__*/ new main.RequestType('java/checkHashCodeEqualsStatus');
|
|
437
|
+
})(
|
|
438
|
+
CheckHashCodeEqualsStatusRequest || (CheckHashCodeEqualsStatusRequest = {})
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
var GenerateHashCodeEqualsRequest;
|
|
442
|
+
|
|
443
|
+
/*#__PURE__*/ (function(GenerateHashCodeEqualsRequest) {
|
|
444
|
+
GenerateHashCodeEqualsRequest.type = /*#__PURE__*/ new main.RequestType('java/generateHashCodeEquals');
|
|
445
|
+
})(GenerateHashCodeEqualsRequest || (GenerateHashCodeEqualsRequest = {}));
|
|
446
|
+
|
|
447
|
+
var OrganizeImportsRequest;
|
|
448
|
+
|
|
449
|
+
/*#__PURE__*/ (function(OrganizeImportsRequest) {
|
|
450
|
+
OrganizeImportsRequest.type = /*#__PURE__*/ new main.RequestType('java/organizeImports');
|
|
451
|
+
})(OrganizeImportsRequest || (OrganizeImportsRequest = {}));
|
|
452
|
+
|
|
453
|
+
var CheckToStringStatusRequest;
|
|
454
|
+
|
|
455
|
+
/*#__PURE__*/ (function(CheckToStringStatusRequest) {
|
|
456
|
+
CheckToStringStatusRequest.type = /*#__PURE__*/ new main.RequestType('java/checkToStringStatus');
|
|
457
|
+
})(CheckToStringStatusRequest || (CheckToStringStatusRequest = {}));
|
|
458
|
+
|
|
459
|
+
var GenerateToStringRequest;
|
|
460
|
+
|
|
461
|
+
/*#__PURE__*/ (function(GenerateToStringRequest) {
|
|
462
|
+
GenerateToStringRequest.type = /*#__PURE__*/ new main.RequestType('java/generateToString');
|
|
463
|
+
})(GenerateToStringRequest || (GenerateToStringRequest = {}));
|
|
464
|
+
|
|
465
|
+
var AccessorCodeActionRequest;
|
|
466
|
+
|
|
467
|
+
/*#__PURE__*/ (function(AccessorCodeActionRequest) {
|
|
468
|
+
AccessorCodeActionRequest.type = /*#__PURE__*/ new main.RequestType('java/resolveUnimplementedAccessors');
|
|
469
|
+
})(AccessorCodeActionRequest || (AccessorCodeActionRequest = {}));
|
|
470
|
+
|
|
471
|
+
var GenerateAccessorsRequest;
|
|
472
|
+
|
|
473
|
+
/*#__PURE__*/ (function(GenerateAccessorsRequest) {
|
|
474
|
+
GenerateAccessorsRequest.type = /*#__PURE__*/ new main.RequestType('java/generateAccessors');
|
|
475
|
+
})(GenerateAccessorsRequest || (GenerateAccessorsRequest = {}));
|
|
476
|
+
|
|
477
|
+
var CheckConstructorStatusRequest;
|
|
478
|
+
|
|
479
|
+
/*#__PURE__*/ (function(CheckConstructorStatusRequest) {
|
|
480
|
+
CheckConstructorStatusRequest.type = /*#__PURE__*/ new main.RequestType('java/checkConstructorsStatus');
|
|
481
|
+
})(CheckConstructorStatusRequest || (CheckConstructorStatusRequest = {}));
|
|
482
|
+
|
|
483
|
+
var GenerateConstructorsRequest;
|
|
484
|
+
|
|
485
|
+
/*#__PURE__*/ (function(GenerateConstructorsRequest) {
|
|
486
|
+
GenerateConstructorsRequest.type = /*#__PURE__*/ new main.RequestType('java/generateConstructors');
|
|
487
|
+
})(GenerateConstructorsRequest || (GenerateConstructorsRequest = {}));
|
|
488
|
+
|
|
489
|
+
var CheckDelegateMethodsStatusRequest;
|
|
490
|
+
|
|
491
|
+
/*#__PURE__*/ (function(CheckDelegateMethodsStatusRequest) {
|
|
492
|
+
CheckDelegateMethodsStatusRequest.type = /*#__PURE__*/ new main.RequestType('java/checkDelegateMethodsStatus');
|
|
493
|
+
})(
|
|
494
|
+
CheckDelegateMethodsStatusRequest || (CheckDelegateMethodsStatusRequest = {})
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
var GenerateDelegateMethodsRequest;
|
|
498
|
+
|
|
499
|
+
/*#__PURE__*/ (function(GenerateDelegateMethodsRequest) {
|
|
500
|
+
GenerateDelegateMethodsRequest.type = /*#__PURE__*/ new main.RequestType('java/generateDelegateMethods');
|
|
501
|
+
})(GenerateDelegateMethodsRequest || (GenerateDelegateMethodsRequest = {}));
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Argument that tells the program where to generate the heap dump that is created when an OutOfMemoryError is raised and `HEAP_DUMP` has been passed
|
|
505
|
+
*/
|
|
506
|
+
|
|
507
|
+
const HEAP_DUMP_LOCATION = '-XX:HeapDumpPath=';
|
|
508
|
+
|
|
509
|
+
/*#__PURE__*/ new RegExp("".concat(HEAP_DUMP_LOCATION, "(?:'([^']+)'|\"([^\"]+)\"|([^\\s]+))"));
|
|
510
|
+
|
|
511
|
+
function applyWorkspaceEdit(obj, languageClient) {
|
|
512
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
513
|
+
const edit = yield languageClient.protocol2CodeConverter.asWorkspaceEdit(obj);
|
|
514
|
+
|
|
515
|
+
if (edit) {
|
|
516
|
+
return workspace.applyEdit(edit);
|
|
517
|
+
} else {
|
|
518
|
+
return Promise.resolve(true);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function registerCommands(languageClient, context) {
|
|
524
|
+
registerOverrideMethodsCommand(languageClient, context);
|
|
525
|
+
registerHashCodeEqualsCommand(languageClient, context);
|
|
526
|
+
registerOrganizeImportsCommand(languageClient, context);
|
|
527
|
+
registerChooseImportCommand(context);
|
|
528
|
+
registerGenerateToStringCommand(languageClient, context);
|
|
529
|
+
registerGenerateAccessorsCommand(languageClient, context);
|
|
530
|
+
registerGenerateConstructorsCommand(languageClient, context);
|
|
531
|
+
registerGenerateDelegateMethodsCommand(languageClient, context);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function registerOverrideMethodsCommand(languageClient, context) {
|
|
535
|
+
context.subscriptions.push(commands.registerCommand(Commands.OVERRIDE_METHODS_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
536
|
+
const result = yield languageClient.sendRequest(ListOverridableMethodsRequest.type, params);
|
|
537
|
+
|
|
538
|
+
if (!result || !result.methods || !result.methods.length) {
|
|
539
|
+
window.showWarningMessage('No overridable methods found in the super type.');
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
result.methods.sort((a, b) => {
|
|
544
|
+
const declaringClass = a.declaringClass.localeCompare(b.declaringClass);
|
|
545
|
+
|
|
546
|
+
if (declaringClass !== 0) {
|
|
547
|
+
return declaringClass;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const methodName = a.name.localeCompare(b.name);
|
|
551
|
+
|
|
552
|
+
if (methodName !== 0) {
|
|
553
|
+
return methodName;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return a.parameters.length - b.parameters.length;
|
|
557
|
+
});
|
|
558
|
+
const quickPickItems = result.methods.map(method => {
|
|
559
|
+
return {
|
|
560
|
+
label: "".concat(method.name, "(").concat(method.parameters.join(','), ")"),
|
|
561
|
+
description: "".concat(method.declaringClassType, ": ").concat(method.declaringClass),
|
|
562
|
+
picked: method.unimplemented,
|
|
563
|
+
originalMethod: method
|
|
564
|
+
};
|
|
565
|
+
});
|
|
566
|
+
const selectedItems = yield window.showQuickPick(quickPickItems, {
|
|
567
|
+
canPickMany: true,
|
|
568
|
+
placeHolder: "Select methods to override or implement in ".concat(result.type)
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
if (!selectedItems || !selectedItems.length) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const workspaceEdit = yield languageClient.sendRequest(AddOverridableMethodsRequest.type, {
|
|
576
|
+
context: params,
|
|
577
|
+
overridableMethods: selectedItems.map(item => item.originalMethod)
|
|
578
|
+
});
|
|
579
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
580
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
581
|
+
})));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function registerHashCodeEqualsCommand(languageClient, context) {
|
|
585
|
+
context.subscriptions.push(commands.registerCommand(Commands.HASHCODE_EQUALS_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
const result = yield languageClient.sendRequest(CheckHashCodeEqualsStatusRequest.type, params);
|
|
587
|
+
|
|
588
|
+
if (!result || !result.fields || !result.fields.length) {
|
|
589
|
+
window.showErrorMessage("The operation is not applicable to the type ".concat(result.type, "."));
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
let regenerate = false;
|
|
594
|
+
|
|
595
|
+
if (result.existingMethods && result.existingMethods.length) {
|
|
596
|
+
const ans = yield window.showInformationMessage("Methods ".concat(result.existingMethods.join(' and '), " already ").concat(result.existingMethods.length === 1 ? 'exists' : 'exist', " in the Class '").concat(result.type, "'. ") + 'Do you want to regenerate the implementation?', 'Regenerate', 'Cancel');
|
|
597
|
+
|
|
598
|
+
if (ans !== 'Regenerate') {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
regenerate = true;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const fieldItems = result.fields.map(field => {
|
|
606
|
+
return {
|
|
607
|
+
label: "".concat(field.name, ": ").concat(field.type),
|
|
608
|
+
picked: true,
|
|
609
|
+
originalField: field
|
|
610
|
+
};
|
|
611
|
+
});
|
|
612
|
+
const selectedFields = yield window.showQuickPick(fieldItems, {
|
|
613
|
+
canPickMany: true,
|
|
614
|
+
placeHolder: 'Select the fields to include in the hashCode() and equals() methods.'
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
if (!selectedFields || !selectedFields.length) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const workspaceEdit = yield languageClient.sendRequest(GenerateHashCodeEqualsRequest.type, {
|
|
622
|
+
context: params,
|
|
623
|
+
fields: selectedFields.map(item => item.originalField),
|
|
624
|
+
regenerate
|
|
625
|
+
});
|
|
626
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
627
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
628
|
+
})));
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function registerOrganizeImportsCommand(languageClient, context) {
|
|
632
|
+
context.subscriptions.push(commands.registerCommand(Commands.ORGANIZE_IMPORTS, params => __awaiter(this, void 0, void 0, function* () {
|
|
633
|
+
const workspaceEdit = yield languageClient.sendRequest(OrganizeImportsRequest.type, params);
|
|
634
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
635
|
+
})));
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function registerChooseImportCommand(context) {
|
|
639
|
+
context.subscriptions.push(commands.registerCommand(Commands.CHOOSE_IMPORTS, (uri, selections) => __awaiter(this, void 0, void 0, function* () {
|
|
640
|
+
const chosen = [];
|
|
641
|
+
const fileUri = Uri.parse(uri);
|
|
642
|
+
|
|
643
|
+
for (let i = 0; i < selections.length; i++) {
|
|
644
|
+
const selection = selections[i]; // Move the cursor to the code line with ambiguous import choices.
|
|
645
|
+
|
|
646
|
+
yield window.showTextDocument(fileUri, {
|
|
647
|
+
preserveFocus: true,
|
|
648
|
+
selection: selection.range,
|
|
649
|
+
viewColumn: ViewColumn.One
|
|
650
|
+
});
|
|
651
|
+
const candidates = selection.candidates;
|
|
652
|
+
const items = candidates.map(item => {
|
|
653
|
+
return {
|
|
654
|
+
label: item.fullyQualifiedName,
|
|
655
|
+
origin: item
|
|
656
|
+
};
|
|
657
|
+
});
|
|
658
|
+
const fullyQualifiedName = candidates[0].fullyQualifiedName;
|
|
659
|
+
const typeName = fullyQualifiedName.substring(fullyQualifiedName.lastIndexOf(".") + 1);
|
|
660
|
+
const disposables = [];
|
|
661
|
+
|
|
662
|
+
try {
|
|
663
|
+
const pick = yield new Promise((resolve, reject) => {
|
|
664
|
+
const input = window.createQuickPick();
|
|
665
|
+
input.title = "Organize Imports";
|
|
666
|
+
input.step = i + 1;
|
|
667
|
+
input.totalSteps = selections.length;
|
|
668
|
+
input.placeholder = "Choose type '".concat(typeName, "' to import");
|
|
669
|
+
input.items = items;
|
|
670
|
+
disposables.push(input.onDidChangeSelection(items => resolve(items[0])), input.onDidHide(() => {
|
|
671
|
+
reject(undefined);
|
|
672
|
+
}), input);
|
|
673
|
+
input.show();
|
|
674
|
+
});
|
|
675
|
+
chosen.push(pick ? pick.origin : null);
|
|
676
|
+
} catch (err) {
|
|
677
|
+
break;
|
|
678
|
+
} finally {
|
|
679
|
+
disposables.forEach(d => d.dispose());
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
return chosen;
|
|
684
|
+
})));
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function registerGenerateToStringCommand(languageClient, context) {
|
|
688
|
+
context.subscriptions.push(commands.registerCommand(Commands.GENERATE_TOSTRING_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
689
|
+
const result = yield languageClient.sendRequest(CheckToStringStatusRequest.type, params);
|
|
690
|
+
|
|
691
|
+
if (!result) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (result.exists) {
|
|
696
|
+
const ans = yield window.showInformationMessage("Method 'toString()' already exists in the Class '".concat(result.type, "'. ") + 'Do you want to replace the implementation?', 'Replace', 'Cancel');
|
|
697
|
+
|
|
698
|
+
if (ans !== 'Replace') {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
let fields = [];
|
|
704
|
+
|
|
705
|
+
if (result.fields && result.fields.length) {
|
|
706
|
+
const fieldItems = result.fields.map(field => {
|
|
707
|
+
return {
|
|
708
|
+
label: "".concat(field.name, ": ").concat(field.type),
|
|
709
|
+
picked: true,
|
|
710
|
+
originalField: field
|
|
711
|
+
};
|
|
712
|
+
});
|
|
713
|
+
const selectedFields = yield window.showQuickPick(fieldItems, {
|
|
714
|
+
canPickMany: true,
|
|
715
|
+
placeHolder: 'Select the fields to include in the toString() method.'
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
if (!selectedFields) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
fields = selectedFields.map(item => item.originalField);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
const workspaceEdit = yield languageClient.sendRequest(GenerateToStringRequest.type, {
|
|
726
|
+
context: params,
|
|
727
|
+
fields
|
|
728
|
+
});
|
|
729
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
730
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
731
|
+
})));
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function registerGenerateAccessorsCommand(languageClient, context) {
|
|
735
|
+
context.subscriptions.push(commands.registerCommand(Commands.GENERATE_ACCESSORS_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
736
|
+
yield generateAccessors(languageClient, params);
|
|
737
|
+
})));
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
function generateAccessors(languageClient, params) {
|
|
741
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
742
|
+
const accessors = yield languageClient.sendRequest(AccessorCodeActionRequest.type, params);
|
|
743
|
+
|
|
744
|
+
if (!accessors || !accessors.length) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
const accessorItems = accessors.map(accessor => {
|
|
749
|
+
const description = [];
|
|
750
|
+
|
|
751
|
+
if (accessor.generateGetter) {
|
|
752
|
+
description.push('getter');
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
if (accessor.generateSetter) {
|
|
756
|
+
description.push('setter');
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
return {
|
|
760
|
+
label: "".concat(accessor.fieldName, ": ").concat(accessor.typeName),
|
|
761
|
+
description: (accessor.isStatic ? 'static ' : '') + description.join(', '),
|
|
762
|
+
originalField: accessor
|
|
763
|
+
};
|
|
764
|
+
});
|
|
765
|
+
let accessorsKind;
|
|
766
|
+
|
|
767
|
+
switch (params.kind) {
|
|
768
|
+
case AccessorKind.BOTH:
|
|
769
|
+
accessorsKind = "getters and setters";
|
|
770
|
+
break;
|
|
771
|
+
|
|
772
|
+
case AccessorKind.GETTER:
|
|
773
|
+
accessorsKind = "getters";
|
|
774
|
+
break;
|
|
775
|
+
|
|
776
|
+
case AccessorKind.SETTER:
|
|
777
|
+
accessorsKind = "setters";
|
|
778
|
+
break;
|
|
779
|
+
|
|
780
|
+
default:
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
const selectedAccessors = yield window.showQuickPick(accessorItems, {
|
|
785
|
+
canPickMany: true,
|
|
786
|
+
placeHolder: "Select the fields to generate ".concat(accessorsKind)
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
if (!selectedAccessors || !selectedAccessors.length) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
const workspaceEdit = yield languageClient.sendRequest(GenerateAccessorsRequest.type, {
|
|
794
|
+
context: params,
|
|
795
|
+
accessors: selectedAccessors.map(item => item.originalField)
|
|
796
|
+
});
|
|
797
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
798
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function registerGenerateConstructorsCommand(languageClient, context) {
|
|
803
|
+
context.subscriptions.push(commands.registerCommand(Commands.GENERATE_CONSTRUCTORS_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
804
|
+
const status = yield languageClient.sendRequest(CheckConstructorStatusRequest.type, params);
|
|
805
|
+
|
|
806
|
+
if (!status || !status.constructors || !status.constructors.length) {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
let selectedConstructors = status.constructors;
|
|
811
|
+
let selectedFields = [];
|
|
812
|
+
|
|
813
|
+
if (status.constructors.length > 1) {
|
|
814
|
+
const constructorItems = status.constructors.map(constructor => {
|
|
815
|
+
return {
|
|
816
|
+
label: "".concat(constructor.name, "(").concat(constructor.parameters.join(','), ")"),
|
|
817
|
+
originalConstructor: constructor
|
|
818
|
+
};
|
|
819
|
+
});
|
|
820
|
+
const selectedConstructorItems = yield window.showQuickPick(constructorItems, {
|
|
821
|
+
canPickMany: true,
|
|
822
|
+
placeHolder: 'Select super class constructor(s).'
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
if (!selectedConstructorItems || !selectedConstructorItems.length) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
selectedConstructors = selectedConstructorItems.map(item => item.originalConstructor);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (status.fields.length) {
|
|
833
|
+
const fieldItems = status.fields.map(field => {
|
|
834
|
+
return {
|
|
835
|
+
label: "".concat(field.name, ": ").concat(field.type),
|
|
836
|
+
originalField: field,
|
|
837
|
+
picked: field.isSelected
|
|
838
|
+
};
|
|
839
|
+
});
|
|
840
|
+
const selectedFieldItems = yield window.showQuickPick(fieldItems, {
|
|
841
|
+
canPickMany: true,
|
|
842
|
+
placeHolder: 'Select fields to initialize by constructor(s).'
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
if (!selectedFieldItems) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
selectedFields = selectedFieldItems.map(item => item.originalField);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const workspaceEdit = yield languageClient.sendRequest(GenerateConstructorsRequest.type, {
|
|
853
|
+
context: params,
|
|
854
|
+
constructors: selectedConstructors,
|
|
855
|
+
fields: selectedFields
|
|
856
|
+
});
|
|
857
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
858
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
859
|
+
})));
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
function registerGenerateDelegateMethodsCommand(languageClient, context) {
|
|
863
|
+
context.subscriptions.push(commands.registerCommand(Commands.GENERATE_DELEGATE_METHODS_PROMPT, params => __awaiter(this, void 0, void 0, function* () {
|
|
864
|
+
const status = yield languageClient.sendRequest(CheckDelegateMethodsStatusRequest.type, params);
|
|
865
|
+
|
|
866
|
+
if (!status || !status.delegateFields || !status.delegateFields.length) {
|
|
867
|
+
window.showWarningMessage("All delegatable methods are already implemented.");
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
let selectedDelegateField = status.delegateFields[0];
|
|
872
|
+
|
|
873
|
+
if (status.delegateFields.length > 1) {
|
|
874
|
+
const fieldItems = status.delegateFields.map(delegateField => {
|
|
875
|
+
return {
|
|
876
|
+
label: "".concat(delegateField.field.name, ": ").concat(delegateField.field.type),
|
|
877
|
+
originalField: delegateField
|
|
878
|
+
};
|
|
879
|
+
});
|
|
880
|
+
const selectedFieldItem = yield window.showQuickPick(fieldItems, {
|
|
881
|
+
placeHolder: 'Select target to generate delegates for.'
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
if (!selectedFieldItem) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
selectedDelegateField = selectedFieldItem.originalField;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
const delegateEntryItems = selectedDelegateField.delegateMethods.map(delegateMethod => {
|
|
892
|
+
return {
|
|
893
|
+
label: "".concat(selectedDelegateField.field.name, ".").concat(delegateMethod.name, "(").concat(delegateMethod.parameters.join(','), ")"),
|
|
894
|
+
originalField: selectedDelegateField.field,
|
|
895
|
+
originalMethod: delegateMethod
|
|
896
|
+
};
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
if (!delegateEntryItems.length) {
|
|
900
|
+
window.showWarningMessage("All delegatable methods are already implemented.");
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const selectedDelegateEntryItems = yield window.showQuickPick(delegateEntryItems, {
|
|
905
|
+
canPickMany: true,
|
|
906
|
+
placeHolder: 'Select methods to generate delegates for.'
|
|
907
|
+
});
|
|
908
|
+
|
|
909
|
+
if (!selectedDelegateEntryItems || !selectedDelegateEntryItems.length) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
const delegateEntries = selectedDelegateEntryItems.map(item => {
|
|
914
|
+
return {
|
|
915
|
+
field: item.originalField,
|
|
916
|
+
delegateMethod: item.originalMethod
|
|
917
|
+
};
|
|
918
|
+
});
|
|
919
|
+
const workspaceEdit = yield languageClient.sendRequest(GenerateDelegateMethodsRequest.type, {
|
|
920
|
+
context: params,
|
|
921
|
+
delegateEntries
|
|
922
|
+
});
|
|
923
|
+
yield applyWorkspaceEdit(workspaceEdit, languageClient);
|
|
924
|
+
yield revealWorkspaceEdit(workspaceEdit, languageClient);
|
|
925
|
+
})));
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function revealWorkspaceEdit(workspaceEdit, languageClient) {
|
|
929
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
930
|
+
const codeWorkspaceEdit = yield languageClient.protocol2CodeConverter.asWorkspaceEdit(workspaceEdit);
|
|
931
|
+
|
|
932
|
+
if (!codeWorkspaceEdit) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
for (const entry of codeWorkspaceEdit.entries()) {
|
|
937
|
+
yield workspace.openTextDocument(entry[0]);
|
|
938
|
+
|
|
939
|
+
if (entry[1].length > 0) {
|
|
940
|
+
// reveal first available change of the workspace edit
|
|
941
|
+
window.activeTextEditor.revealRange(entry[1][0].range, TextEditorRevealType.InCenter);
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
class JavaExtensionFeature extends ExtensionFeature {
|
|
949
|
+
constructor(languageClient) {
|
|
950
|
+
super();
|
|
951
|
+
this.languageClient = languageClient;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
activate(context) {
|
|
955
|
+
/**
|
|
956
|
+
* The next 3 commands come from https://github.com/redhat-developer/vscode-java/blob/4810edd542cecb654ac1152985b4a9da0f921c08/src/standardLanguageClient.ts#L328
|
|
957
|
+
* They can't be imported because they are in the middle of a complex function
|
|
958
|
+
* Only those 3 are important to us
|
|
959
|
+
*/
|
|
960
|
+
context.subscriptions.push(commands.registerCommand(Commands.SHOW_JAVA_REFERENCES, (uri, position, locations) => {
|
|
961
|
+
void commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
|
|
962
|
+
}));
|
|
963
|
+
context.subscriptions.push(commands.registerCommand(Commands.SHOW_JAVA_IMPLEMENTATIONS, (uri, position, locations) => {
|
|
964
|
+
void commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
|
|
965
|
+
}));
|
|
966
|
+
context.subscriptions.push(commands.registerCommand(Commands.APPLY_WORKSPACE_EDIT, obj => {
|
|
967
|
+
void applyWorkspaceEdit(obj, this.languageClient);
|
|
968
|
+
}));
|
|
969
|
+
context.subscriptions.push(languages.registerInlayHintsProvider(this.languageClient.clientOptions.documentSelector, new JavaInlayHintsProvider(this.languageClient)));
|
|
970
|
+
registerCommands(this.languageClient, context);
|
|
971
|
+
/**
|
|
972
|
+
* It comes from https://github.com/redhat-developer/vscode-java/blob/cf8b8bcce9b4bf1691fa3dd89bcd40db0ca093bd/src/providerDispatcher.ts#L30
|
|
973
|
+
*/
|
|
974
|
+
|
|
975
|
+
context.subscriptions.push(workspace.registerTextDocumentContentProvider('jdt', {
|
|
976
|
+
provideTextDocumentContent: async (uri, token) => {
|
|
977
|
+
return this.languageClient.sendRequest(ClassFileContentsRequest.type, {
|
|
978
|
+
uri: uri.toString()
|
|
979
|
+
}, token).then(v => {
|
|
980
|
+
return v !== null && v !== void 0 ? v : '';
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}));
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export { JavaExtensionFeature };
|