Skip to content

Commit 8fbe786

Browse files
committed
Update dependencies
1 parent ca503f1 commit 8fbe786

File tree

3 files changed

+147
-85
lines changed

3 files changed

+147
-85
lines changed

lib/extension.ts

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as Path from "path";
55
import * as FS from "fs";
66
import {window, workspace, ExtensionContext, commands, tasks, Task, TaskExecution, ShellExecution, Uri, TaskDefinition, languages, IndentAction, Progress, ProgressLocation, debug, DebugConfiguration, Range, Position, TextDocument, TextDocumentContentProvider, CancellationToken, ProviderResult, ConfigurationChangeEvent} from 'vscode';
7-
import {LanguageClient, LanguageClientOptions, ServerOptions, NotificationType} from "vscode-languageclient";
7+
import {LanguageClient, LanguageClientOptions, ServerOptions, NotificationType} from "vscode-languageclient/node";
88
import {loadStyles, decoration} from './textMate';
99
import * as AdmZip from 'adm-zip';
1010

@@ -17,7 +17,7 @@ export async function activate(context: ExtensionContext) {
1717

1818
// Teach VSCode to open JAR files
1919
workspace.registerTextDocumentContentProvider('jar', new JarFileSystemProvider());
20-
20+
2121
// Options to control the language client
2222
let clientOptions: LanguageClientOptions = {
2323
// Register the server for java documents
@@ -42,7 +42,7 @@ export async function activate(context: ExtensionContext) {
4242
let launcherRelativePath = platformSpecificLangServer();
4343
let launcherPath = [context.extensionPath].concat(launcherRelativePath);
4444
let launcher = Path.resolve(...launcherPath);
45-
45+
4646
// Start the child java process
4747
let serverOptions: ServerOptions = {
4848
command: launcher,
@@ -58,19 +58,20 @@ export async function activate(context: ExtensionContext) {
5858

5959
// Create the language client and start the client.
6060
let client = new LanguageClient('java', 'Java Language Server', serverOptions, clientOptions);
61-
let disposable = client.start();
6261

63-
// Push the disposable to the context's subscriptions so that the
62+
// Push the client to the context's subscriptions so that the
6463
// client can be deactivated on extension deactivation
65-
context.subscriptions.push(disposable);
64+
context.subscriptions.push(client);
65+
66+
await client.start();
6667

6768
// Register test commands
6869
commands.registerCommand('java.command.test.run', runTest);
6970
commands.registerCommand('java.command.test.debug', debugTest);
7071
commands.registerCommand('java.command.findReferences', runFindReferences);
7172

72-
// When the language client activates, register a progress-listener
73-
client.onReady().then(() => createProgressListeners(client));
73+
// Register a progress-listener
74+
createProgressListeners(client);
7475

7576
// Apply semantic colors using custom notification
7677
function asRange(r: RangeLike) {
@@ -119,12 +120,12 @@ export async function activate(context: ExtensionContext) {
119120
applySemanticColors()
120121
}
121122
}
122-
client.onReady().then(() => {
123-
client.onNotification(new NotificationType('java/colors'), cacheSemanticColors);
124-
context.subscriptions.push(window.onDidChangeVisibleTextEditors(applySemanticColors));
125-
context.subscriptions.push(workspace.onDidCloseTextDocument(forgetSemanticColors));
126-
context.subscriptions.push(workspace.onDidChangeConfiguration(onChangeConfiguration))
127-
});
123+
124+
client.onNotification(new NotificationType('java/colors'), cacheSemanticColors);
125+
context.subscriptions.push(window.onDidChangeVisibleTextEditors(applySemanticColors));
126+
context.subscriptions.push(workspace.onDidCloseTextDocument(forgetSemanticColors));
127+
context.subscriptions.push(workspace.onDidChangeConfiguration(onChangeConfiguration))
128+
128129
await loadStyles();
129130
applySemanticColors();
130131
}
@@ -259,7 +260,7 @@ function templateCommand(command: string[], file: string, className: string, met
259260
}
260261

261262
interface ProgressMessage {
262-
message: string
263+
message: string
263264
increment: number
264265
}
265266

@@ -268,7 +269,7 @@ function createProgressListeners(client: LanguageClient) {
268269
let progressListener = new class {
269270
progress: Progress<{message: string, increment?: number}>
270271
resolve: (nothing: {}) => void
271-
272+
272273
startProgress(message: string) {
273274
if (this.progress != null)
274275
this.endProgress();
@@ -278,11 +279,11 @@ function createProgressListeners(client: LanguageClient) {
278279
this.resolve = resolve;
279280
}));
280281
}
281-
282+
282283
reportProgress(message: string, increment: number) {
283284
if (increment == -1)
284285
this.progress.report({message});
285-
else
286+
else
286287
this.progress.report({message, increment})
287288
}
288289

@@ -340,10 +341,10 @@ function platformSpecificLangServer(): string[] {
340341
// Alternative server options if you want to use visualvm
341342
function visualVmConfig(context: ExtensionContext): ServerOptions {
342343
let javaExecutablePath = findJavaExecutable('java');
343-
344+
344345
if (javaExecutablePath == null) {
345346
window.showErrorMessage("Couldn't locate java in $JAVA_HOME or $PATH");
346-
347+
347348
throw "Gave up";
348349
}
349350
const jars = [
@@ -353,7 +354,7 @@ function visualVmConfig(context: ExtensionContext): ServerOptions {
353354
];
354355
const classpath = jars.map(jar => Path.resolve(context.extensionPath, "dist", "classpath", jar)).join(':');
355356
let args = [
356-
'-cp', classpath,
357+
'-cp', classpath,
357358
'-Xverify:none', // helps VisualVM avoid 'error 62'
358359
'-Xdebug',
359360
// '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005',
@@ -369,9 +370,9 @@ function visualVmConfig(context: ExtensionContext): ServerOptions {
369370
// Opens, needed at runtime for reflection
370371
"--add-opens", "jdk.compiler/com.sun.tools.javac.api=javacs",
371372
];
372-
373+
373374
console.log(javaExecutablePath + ' ' + args.join(' '));
374-
375+
375376
// Start the child java process
376377
return {
377378
command: javaExecutablePath,
@@ -410,7 +411,7 @@ function findJavaExecutable(binname: string) {
410411
// Then search PATH parts
411412
if (process.env['PATH']) {
412413
console.log('Looking for java in PATH');
413-
414+
414415
let pathparts = process.env['PATH'].split(Path.delimiter);
415416
for (let i = 0; i < pathparts.length; i++) {
416417
let binpath = Path.join(pathparts[i], binname);
@@ -419,8 +420,8 @@ function findJavaExecutable(binname: string) {
419420
}
420421
}
421422
}
422-
423-
// Else return the binary name directly (this will likely always fail downstream)
423+
424+
// Else return the binary name directly (this will likely always fail downstream)
424425
return null;
425426
}
426427

@@ -437,7 +438,7 @@ function findJavaExecutableInJavaHome(javaHome: string, binname: string) {
437438
for (let i = 0; i < workspaces.length; i++) {
438439
let binpath = Path.join(workspaces[i], 'bin', binname);
439440

440-
if (FS.existsSync(binpath))
441+
if (FS.existsSync(binpath))
441442
return binpath;
442443
}
443444

0 commit comments

Comments
 (0)