Skip to content

Commit a411ed3

Browse files
committed
use language client 8.0.0-next.4 and vscode 1.61
Signed-off-by: Shi Chen <[email protected]>
1 parent 7ed0798 commit a411ed3

File tree

7 files changed

+65
-59
lines changed

7 files changed

+65
-59
lines changed

package-lock.json

Lines changed: 31 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@
11411141
"@types/mocha": "^5.2.5",
11421142
"@types/node": "^8.10.51",
11431143
"@types/semver": "^7.3.8",
1144-
"@types/vscode": "^1.53.0",
1144+
"@types/vscode": "1.61.0",
11451145
"@types/winreg": "^1.2.30",
11461146
"@types/winston": "^2.4.4",
11471147
"gulp": "^4.0.2",
@@ -1168,7 +1168,7 @@
11681168
"glob": "^7.1.3",
11691169
"jdk-utils": "^0.4.3",
11701170
"semver": "^7.3.5",
1171-
"vscode-languageclient": "7.1.0-next.5",
1171+
"vscode-languageclient": "8.0.0-next.4",
11721172
"winreg-utf8": "^0.1.1",
11731173
"winston": "^3.2.1",
11741174
"winston-daily-rotate-file": "^3.10.0"

src/extension.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from 'path';
44
import * as os from 'os';
55
import * as fs from 'fs';
66
import * as fse from 'fs-extra';
7-
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind, CodeActionContext, Diagnostic } from 'vscode';
7+
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind, CodeActionContext, Diagnostic, CodeActionTriggerKind } from 'vscode';
88
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn, ErrorHandler, Message, ErrorAction, CloseAction, DidChangeConfigurationNotification, CancellationToken, CodeActionRequest, CodeActionParams, Command } from 'vscode-languageclient';
99
import { LanguageClient } from 'vscode-languageclient/node';
1010
import { collectJavaExtensions, isContributedPartUpdated } from './plugin';
@@ -134,6 +134,12 @@ export class OutputInfoCollector implements OutputChannel {
134134
this.channel.appendLine(value);
135135
}
136136

137+
replace(value: string): void {
138+
logger.info(value);
139+
this.clear();
140+
this.channel.append(value);
141+
}
142+
137143
clear(): void {
138144
this.channel.clear();
139145
}
@@ -245,8 +251,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
245251
},
246252
middleware: {
247253
workspace: {
248-
didChangeConfiguration: () => {
249-
standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, {
254+
didChangeConfiguration: async () => {
255+
await standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, {
250256
settings: {
251257
java: getJavaConfig(requirements.java_home),
252258
}
@@ -256,7 +262,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
256262
// https://github.com/redhat-developer/vscode-java/issues/2130
257263
// include all diagnostics for the current line in the CodeActionContext params for the performance reason
258264
provideCodeActions: (document, range, context, token, next) => {
259-
const client: any = standardClient.getClient();
265+
const client: LanguageClient = standardClient.getClient();
260266
const params: CodeActionParams = {
261267
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
262268
range: client.code2ProtocolConverter.asRange(range),
@@ -278,6 +284,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
278284
}
279285
const codeActionContext: CodeActionContext = {
280286
diagnostics: allDiagnostics,
287+
triggerKind: CodeActionTriggerKind?.Automatic,
281288
only: context.only,
282289
};
283290
params.context = client.code2ProtocolConverter.asCodeActionContext(codeActionContext);
@@ -298,7 +305,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
298305
}
299306
return result;
300307
}, (error) => {
301-
client.logFailedRequest(CodeActionRequest.type, error);
302308
return Promise.resolve([]);
303309
});
304310
}

src/hoverAction.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,20 @@ class JavaHoverProvider implements HoverProvider {
7575

7676
const contributed = new MarkdownString(contributedCommands.map((command) => this.convertCommandToMarkdown(command)).join(' | '));
7777
contributed.isTrusted = true;
78-
let contents: MarkedString[] = [ contributed ];
78+
let contents: MarkdownString[] = [ contributed ];
7979
let range;
8080
if (serverHover && serverHover.contents) {
81-
contents = contents.concat(serverHover.contents);
81+
const serverHoverContentsMarkdown = [];
82+
serverHover.contents.forEach(element => {
83+
if (element instanceof MarkdownString) {
84+
serverHoverContentsMarkdown.push(element);
85+
} else if (typeof element === "string") {
86+
serverHoverContentsMarkdown.push(new MarkdownString(element));
87+
} else if (element.value) {
88+
serverHoverContentsMarkdown.push(new MarkdownString(element.value));
89+
}
90+
});
91+
contents = contents.concat(serverHoverContentsMarkdown);
8292
range = serverHover.range;
8393
}
8494
return new Hover(contents, range);

src/refactorAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async function applyRefactorEdit(languageClient: LanguageClient, refactorEdit: R
214214
}
215215

216216
if (refactorEdit.edit) {
217-
const edit = languageClient.protocol2CodeConverter.asWorkspaceEdit(refactorEdit.edit);
217+
const edit = await languageClient.protocol2CodeConverter.asWorkspaceEdit(refactorEdit.edit);
218218
if (edit) {
219219
await workspace.applyEdit(edit);
220220
}

src/standardLanguageClient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,15 @@ export class StandardLanguageClient {
311311
commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
312312
}));
313313

314-
context.subscriptions.push(commands.registerCommand(Commands.CONFIGURATION_UPDATE, uri => projectConfigurationUpdate(this.languageClient, uri)));
314+
context.subscriptions.push(commands.registerCommand(Commands.CONFIGURATION_UPDATE, async (uri) => projectConfigurationUpdate(this.languageClient, uri)));
315315

316316
context.subscriptions.push(commands.registerCommand(Commands.IGNORE_INCOMPLETE_CLASSPATH, () => setIncompleteClasspathSeverity('ignore')));
317317

318318
context.subscriptions.push(commands.registerCommand(Commands.IGNORE_INCOMPLETE_CLASSPATH_HELP, () => {
319319
commands.executeCommand(Commands.OPEN_BROWSER, Uri.parse('https://github.com/redhat-developer/vscode-java/wiki/%22Classpath-is-incomplete%22-warning'));
320320
}));
321321

322-
context.subscriptions.push(commands.registerCommand(Commands.PROJECT_CONFIGURATION_STATUS, (uri, status) => setProjectConfigurationUpdate(this.languageClient, uri, status)));
322+
context.subscriptions.push(commands.registerCommand(Commands.PROJECT_CONFIGURATION_STATUS, async (uri, status) => setProjectConfigurationUpdate(this.languageClient, uri, status)));
323323

324324
context.subscriptions.push(commands.registerCommand(Commands.APPLY_WORKSPACE_EDIT, (obj) => {
325325
applyWorkspaceEdit(obj, this.languageClient);
@@ -570,7 +570,7 @@ function setIncompleteClasspathSeverity(severity: string) {
570570
);
571571
}
572572

573-
function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
573+
async function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
574574
let resource = uri;
575575
if (!(resource instanceof Uri)) {
576576
if (window.activeTextEditor) {
@@ -581,7 +581,7 @@ function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
581581
return window.showWarningMessage('No Java project to update!').then(() => false);
582582
}
583583
if (isJavaConfigFile(resource.path)) {
584-
languageClient.sendNotification(ProjectConfigurationUpdateRequest.type, {
584+
await languageClient.sendNotification(ProjectConfigurationUpdateRequest.type, {
585585
uri: resource.toString()
586586
});
587587
}
@@ -593,7 +593,7 @@ function isJavaConfigFile(filePath: string) {
593593
return regEx.test(fileName);
594594
}
595595

596-
function setProjectConfigurationUpdate(languageClient: LanguageClient, uri: Uri, status: FeatureStatus) {
596+
async function setProjectConfigurationUpdate(languageClient: LanguageClient, uri: Uri, status: FeatureStatus) {
597597
const config = getJavaConfiguration();
598598
const section = 'configuration.updateBuildConfiguration';
599599

@@ -603,7 +603,7 @@ function setProjectConfigurationUpdate(languageClient: LanguageClient, uri: Uri,
603603
(error) => logger.error(error)
604604
);
605605
if (status !== FeatureStatus.disabled) {
606-
projectConfigurationUpdate(languageClient, uri);
606+
await projectConfigurationUpdate(languageClient, uri);
607607
}
608608
}
609609

src/syntaxLanguageClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export class SyntaxLanguageClient {
2020
const newClientOptions: LanguageClientOptions = Object.assign({}, clientOptions, {
2121
middleware: {
2222
workspace: {
23-
didChangeConfiguration: () => {
24-
this.languageClient.sendNotification(DidChangeConfigurationNotification.type, {
23+
didChangeConfiguration: async () => {
24+
await this.languageClient.sendNotification(DidChangeConfigurationNotification.type, {
2525
settings: {
2626
java: getJavaConfig(requirements.java_home),
2727
}

0 commit comments

Comments
 (0)