Skip to content

Commit

Permalink
use language client 8.0.0-next.4 and vscode 1.61
Browse files Browse the repository at this point in the history
Signed-off-by: Shi Chen <[email protected]>
  • Loading branch information
CsCherrYY committed Mar 22, 2022
1 parent 7ed0798 commit a411ed3
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 59 deletions.
72 changes: 31 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@
"@types/mocha": "^5.2.5",
"@types/node": "^8.10.51",
"@types/semver": "^7.3.8",
"@types/vscode": "^1.53.0",
"@types/vscode": "1.61.0",
"@types/winreg": "^1.2.30",
"@types/winston": "^2.4.4",
"gulp": "^4.0.2",
Expand All @@ -1168,7 +1168,7 @@
"glob": "^7.1.3",
"jdk-utils": "^0.4.3",
"semver": "^7.3.5",
"vscode-languageclient": "7.1.0-next.5",
"vscode-languageclient": "8.0.0-next.4",
"winreg-utf8": "^0.1.1",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^3.10.0"
Expand Down
16 changes: 11 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import * as fse from 'fs-extra';
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind, CodeActionContext, Diagnostic } from 'vscode';
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind, CodeActionContext, Diagnostic, CodeActionTriggerKind } from 'vscode';
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn, ErrorHandler, Message, ErrorAction, CloseAction, DidChangeConfigurationNotification, CancellationToken, CodeActionRequest, CodeActionParams, Command } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
import { collectJavaExtensions, isContributedPartUpdated } from './plugin';
Expand Down Expand Up @@ -134,6 +134,12 @@ export class OutputInfoCollector implements OutputChannel {
this.channel.appendLine(value);
}

replace(value: string): void {
logger.info(value);
this.clear();
this.channel.append(value);
}

clear(): void {
this.channel.clear();
}
Expand Down Expand Up @@ -245,8 +251,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
},
middleware: {
workspace: {
didChangeConfiguration: () => {
standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, {
didChangeConfiguration: async () => {
await standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, {
settings: {
java: getJavaConfig(requirements.java_home),
}
Expand All @@ -256,7 +262,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
// https://github.com/redhat-developer/vscode-java/issues/2130
// include all diagnostics for the current line in the CodeActionContext params for the performance reason
provideCodeActions: (document, range, context, token, next) => {
const client: any = standardClient.getClient();
const client: LanguageClient = standardClient.getClient();
const params: CodeActionParams = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
range: client.code2ProtocolConverter.asRange(range),
Expand All @@ -278,6 +284,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
}
const codeActionContext: CodeActionContext = {
diagnostics: allDiagnostics,
triggerKind: CodeActionTriggerKind?.Automatic,
only: context.only,
};
params.context = client.code2ProtocolConverter.asCodeActionContext(codeActionContext);
Expand All @@ -298,7 +305,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
}
return result;
}, (error) => {
client.logFailedRequest(CodeActionRequest.type, error);
return Promise.resolve([]);
});
}
Expand Down
14 changes: 12 additions & 2 deletions src/hoverAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,20 @@ class JavaHoverProvider implements HoverProvider {

const contributed = new MarkdownString(contributedCommands.map((command) => this.convertCommandToMarkdown(command)).join(' | '));
contributed.isTrusted = true;
let contents: MarkedString[] = [ contributed ];
let contents: MarkdownString[] = [ contributed ];
let range;
if (serverHover && serverHover.contents) {
contents = contents.concat(serverHover.contents);
const serverHoverContentsMarkdown = [];
serverHover.contents.forEach(element => {
if (element instanceof MarkdownString) {
serverHoverContentsMarkdown.push(element);
} else if (typeof element === "string") {
serverHoverContentsMarkdown.push(new MarkdownString(element));
} else if (element.value) {
serverHoverContentsMarkdown.push(new MarkdownString(element.value));
}
});
contents = contents.concat(serverHoverContentsMarkdown);
range = serverHover.range;
}
return new Hover(contents, range);
Expand Down
2 changes: 1 addition & 1 deletion src/refactorAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async function applyRefactorEdit(languageClient: LanguageClient, refactorEdit: R
}

if (refactorEdit.edit) {
const edit = languageClient.protocol2CodeConverter.asWorkspaceEdit(refactorEdit.edit);
const edit = await languageClient.protocol2CodeConverter.asWorkspaceEdit(refactorEdit.edit);
if (edit) {
await workspace.applyEdit(edit);
}
Expand Down
12 changes: 6 additions & 6 deletions src/standardLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ export class StandardLanguageClient {
commands.executeCommand(Commands.SHOW_REFERENCES, Uri.parse(uri), this.languageClient.protocol2CodeConverter.asPosition(position), locations.map(this.languageClient.protocol2CodeConverter.asLocation));
}));

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

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

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

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

context.subscriptions.push(commands.registerCommand(Commands.APPLY_WORKSPACE_EDIT, (obj) => {
applyWorkspaceEdit(obj, this.languageClient);
Expand Down Expand Up @@ -570,7 +570,7 @@ function setIncompleteClasspathSeverity(severity: string) {
);
}

function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
async function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
let resource = uri;
if (!(resource instanceof Uri)) {
if (window.activeTextEditor) {
Expand All @@ -581,7 +581,7 @@ function projectConfigurationUpdate(languageClient: LanguageClient, uri?: Uri) {
return window.showWarningMessage('No Java project to update!').then(() => false);
}
if (isJavaConfigFile(resource.path)) {
languageClient.sendNotification(ProjectConfigurationUpdateRequest.type, {
await languageClient.sendNotification(ProjectConfigurationUpdateRequest.type, {
uri: resource.toString()
});
}
Expand All @@ -593,7 +593,7 @@ function isJavaConfigFile(filePath: string) {
return regEx.test(fileName);
}

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

Expand All @@ -603,7 +603,7 @@ function setProjectConfigurationUpdate(languageClient: LanguageClient, uri: Uri,
(error) => logger.error(error)
);
if (status !== FeatureStatus.disabled) {
projectConfigurationUpdate(languageClient, uri);
await projectConfigurationUpdate(languageClient, uri);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/syntaxLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class SyntaxLanguageClient {
const newClientOptions: LanguageClientOptions = Object.assign({}, clientOptions, {
middleware: {
workspace: {
didChangeConfiguration: () => {
this.languageClient.sendNotification(DidChangeConfigurationNotification.type, {
didChangeConfiguration: async () => {
await this.languageClient.sendNotification(DidChangeConfigurationNotification.type, {
settings: {
java: getJavaConfig(requirements.java_home),
}
Expand Down

0 comments on commit a411ed3

Please sign in to comment.