diff --git a/package-lock.json b/package-lock.json index 8171aa46c4..758583f072 100644 --- a/package-lock.json +++ b/package-lock.json @@ -101,9 +101,9 @@ "dev": true }, "@types/vscode": { - "version": "1.53.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.53.0.tgz", - "integrity": "sha512-XjFWbSPOM0EKIT2XhhYm3D3cx3nn3lshMUcWNy1eqefk+oqRuBq8unVb6BYIZqXy9lQZyeUl7eaBCOZWv+LcXQ==", + "version": "1.61.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.61.0.tgz", + "integrity": "sha512-9k5Nwq45hkRwdfCFY+eKXeQQSbPoA114mF7U/4uJXRBJeGIO7MuJdhF1PnaDN+lllL9iKGQtd6FFXShBXMNaFg==", "dev": true }, "@types/winreg": { @@ -1318,7 +1318,7 @@ "decompress-tar": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz", - "integrity": "sha1-cYy9P8sWIJcW5womuE57pFkuWvE=", + "integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==", "dev": true, "requires": { "file-type": "^5.2.0", @@ -1337,7 +1337,7 @@ "decompress-tarbz2": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz", - "integrity": "sha1-MIKluIDqQEOBY0nzeLVsUWvho5s=", + "integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==", "dev": true, "requires": { "decompress-tar": "^4.1.0", @@ -1350,7 +1350,7 @@ "file-type": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz", - "integrity": "sha1-5QzXXTVv/tTjBtxPW89Sp5kDqRk=", + "integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==", "dev": true } } @@ -1358,7 +1358,7 @@ "decompress-targz": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz", - "integrity": "sha1-wJvDXE0R894J8tLaU+neI+fOHu4=", + "integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==", "dev": true, "requires": { "decompress-tar": "^4.1.1", @@ -1512,7 +1512,7 @@ }, "readable-stream": { "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { @@ -2593,9 +2593,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true } } @@ -3671,9 +3671,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "mixin-deep": { @@ -5246,7 +5246,7 @@ "strip-dirs": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.1.0.tgz", - "integrity": "sha1-SYdzYmT8NEzyD2w0rKnRPR1O1sU=", + "integrity": "sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g==", "dev": true, "requires": { "is-natural-number": "^4.0.1" @@ -5961,23 +5961,13 @@ "dev": true }, "vscode-languageclient": { - "version": "7.1.0-next.5", - "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-7.1.0-next.5.tgz", - "integrity": "sha512-TpzpAhpdCNJHaLzptFRs54xsU6xTmaiVPCse0W0rRB5jJBPjOBKilrFPMMm/sJA0y8Yxa9sOvZaNu6WPg3dYAw==", + "version": "8.0.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.0-next.4.tgz", + "integrity": "sha512-G8lDUJYZZsq3xN2kSi7FXg2+YRRAx5npganZYZHJyOUEXvpDRalOmPWGVrYGJ3+tDmZqvy2tOaplWn0Bba78Hg==", "requires": { "minimatch": "^3.0.4", - "semver": "^7.3.4", - "vscode-languageserver-protocol": "3.17.0-next.6" - }, - "dependencies": { - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "requires": { - "lru-cache": "^6.0.0" - } - } + "semver": "^7.3.5", + "vscode-languageserver-protocol": "3.17.0-next.9" } }, "vscode-languageserver": { @@ -6009,25 +5999,25 @@ } }, "vscode-languageserver-protocol": { - "version": "3.17.0-next.6", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.6.tgz", - "integrity": "sha512-f1kGsoOpISB5jSqQNeMDl2446enxVahyux2e5vZap6pu/TC+2UlvPT4DCR0gPph95KOQZweL9zq1SzLoPdqhuA==", + "version": "3.17.0-next.9", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.0-next.9.tgz", + "integrity": "sha512-DGkRmbI1hRBMY6HU6MOyza5AvYp0+HcbMf2qdmI98luyQJ26dOfHY5K38OS4hlTHhdJg9RypTQ/uBbLZehmn1Q==", "requires": { - "vscode-jsonrpc": "7.0.0-next.1", - "vscode-languageserver-types": "3.17.0-next.2" + "vscode-jsonrpc": "8.0.0-next.3", + "vscode-languageserver-types": "3.17.0-next.4" }, "dependencies": { "vscode-jsonrpc": { - "version": "7.0.0-next.1", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-7.0.0-next.1.tgz", - "integrity": "sha512-dEmliPZGbSyIcEeKRGzosCy7y7zsc8FXg1l5BBOGgMUbemlo3vUnsa2GFqpILJwJvlbvkRcF2QASNwIlKe9J7g==" + "version": "8.0.0-next.3", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.0-next.3.tgz", + "integrity": "sha512-2wRiBR5tZAXZ4UxIO4F0cT/zN6OpruoWO0vc7EpQZxVfumb0pYiSegB+PaOzXCuFQzh7YEshW/XMg4zTz3FGVQ==" } } }, "vscode-languageserver-types": { - "version": "3.17.0-next.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.2.tgz", - "integrity": "sha512-L5S2kNLCgYJMVWgsZjBaorMM/6+itAfvOyl6Kv1bgFzDNaUKm9HsnUlehjpWPdV5DqnfJhJ5E03Z+/3Mw8ii+Q==" + "version": "3.17.0-next.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.0-next.4.tgz", + "integrity": "sha512-MraVkZDhfqa3ftnKW9rEDeqsV+ji8OrtEjx6mVjzVGm5U2XXT+mdqDWyQ+y0Gvb2/aa2oJJQyTAaDmRTUKiUbg==" }, "vscode-test": { "version": "1.4.0", diff --git a/package.json b/package.json index cae8117ad7..73e95b8cb1 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" diff --git a/src/extension.ts b/src/extension.ts index 0f522083b1..e08c7e12e1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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'; @@ -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(); } @@ -245,8 +251,8 @@ export function activate(context: ExtensionContext): Promise { }, middleware: { workspace: { - didChangeConfiguration: () => { - standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, { + didChangeConfiguration: async () => { + await standardClient.getClient().sendNotification(DidChangeConfigurationNotification.type, { settings: { java: getJavaConfig(requirements.java_home), } @@ -256,7 +262,7 @@ export function activate(context: ExtensionContext): Promise { // 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), @@ -278,6 +284,7 @@ export function activate(context: ExtensionContext): Promise { } const codeActionContext: CodeActionContext = { diagnostics: allDiagnostics, + triggerKind: CodeActionTriggerKind?.Automatic, only: context.only, }; params.context = client.code2ProtocolConverter.asCodeActionContext(codeActionContext); @@ -298,7 +305,6 @@ export function activate(context: ExtensionContext): Promise { } return result; }, (error) => { - client.logFailedRequest(CodeActionRequest.type, error); return Promise.resolve([]); }); } diff --git a/src/hoverAction.ts b/src/hoverAction.ts index 6cfca3c424..e878485e2d 100644 --- a/src/hoverAction.ts +++ b/src/hoverAction.ts @@ -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); diff --git a/src/refactorAction.ts b/src/refactorAction.ts index 69c4f47c2e..65123bc496 100644 --- a/src/refactorAction.ts +++ b/src/refactorAction.ts @@ -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); } diff --git a/src/standardLanguageClient.ts b/src/standardLanguageClient.ts index 49189b7768..adef14c1a4 100644 --- a/src/standardLanguageClient.ts +++ b/src/standardLanguageClient.ts @@ -311,7 +311,7 @@ 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'))); @@ -319,7 +319,7 @@ export class StandardLanguageClient { 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); @@ -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) { @@ -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() }); } @@ -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'; @@ -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); } } diff --git a/src/syntaxLanguageClient.ts b/src/syntaxLanguageClient.ts index 354a8726fe..ead8412d25 100644 --- a/src/syntaxLanguageClient.ts +++ b/src/syntaxLanguageClient.ts @@ -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), }