Skip to content

Commit 05d4160

Browse files
hopehadfieldrgrunber
authored andcommitted
Support WorkDoneProgress in progress reporting
Signed-off-by: Hope Hadfield <hhadfiel@redhat.com>
1 parent 8fa2464 commit 05d4160

9 files changed

Lines changed: 27 additions & 40 deletions

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ The following settings are supported:
149149
* `java.completion.filteredTypes`: Defines the type filters. All types whose fully qualified name matches the selected filter strings will be ignored in content assist or quick fix proposals and when organizing imports. For example 'java.awt.*' will hide all types from the awt packages.
150150
* `java.completion.favoriteStaticMembers` : Defines a list of static members or types with static members.
151151
* `java.completion.importOrder` : Defines the sorting order of import statements.
152-
* `java.progressReports.enabled` : [Experimental] Enable/disable progress reports from background processes on the server.
153152
* `java.format.enabled` : Enable/disable the default Java formatter.
154153
* `java.format.settings.url` : Specifies the url or file path to the [Eclipse formatter xml settings](https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings).
155154
* `java.format.settings.profile` : Optional formatter profile name from the Eclipse formatter settings.

package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,6 @@
653653
"description": "Enable/disable smart folding range support. If disabled, it will use the default indentation-based folding range provided by VS Code.",
654654
"scope": "window"
655655
},
656-
"java.progressReports.enabled": {
657-
"type": "boolean",
658-
"description": "[Experimental] Enable/disable progress reports from background processes on the server.",
659-
"default": true,
660-
"scope": "window"
661-
},
662656
"java.format.settings.url": {
663657
"type": "string",
664658
"markdownDescription": "Specifies the url or file path to the [Eclipse formatter xml settings](https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings).",

src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
157157
workspaceFolders: workspace.workspaceFolders ? workspace.workspaceFolders.map(f => f.uri.toString()) : null,
158158
settings: { java: getJavaConfig(requirements.java_home) },
159159
extendedClientCapabilities: {
160-
progressReportProvider: getJavaConfiguration().get('progressReports.enabled'),
161160
classFileContentsSupport: true,
162161
overrideMethodsPromptSupport: true,
163162
hashCodeEqualsPromptSupport: true,

src/protocol.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ export interface StatusReport {
8282
}
8383

8484
export interface ProgressReport {
85-
id: string;
86-
task: string;
87-
subTask: string;
88-
status: string;
89-
workDone: number;
90-
totalWork: number;
85+
token: string;
86+
value: any;
9187
complete: boolean;
9288
}
9389

90+
export enum ProgressKind {
91+
begin = "begin",
92+
report = "report",
93+
end = "end"
94+
}
95+
9496
export interface ActionableMessage {
9597
severity: MessageType;
9698
message: string;
@@ -107,8 +109,9 @@ export namespace StatusNotification {
107109
export const type = new NotificationType<StatusReport>('language/status');
108110
}
109111

110-
export namespace ProgressReportNotification {
111-
export const type = new NotificationType<ProgressReport>('language/progressReport');
112+
// See https://github.com/microsoft/vscode-languageserver-node/blob/release/client/8.1.0/jsonrpc/src/common/connection.ts#L53-L55
113+
export namespace ProgressNotification {
114+
export const type = new NotificationType<ProgressReport>('$/progress');
112115
}
113116

114117
export namespace ClassFileContentsRequest {

src/serverStatus.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { EventEmitter } from "vscode";
44
import { serverTasks } from "./serverTasks";
5+
import { ProgressKind } from "./protocol";
56

67
export enum ServerStatusKind {
78
ready = "Ready",
@@ -31,7 +32,7 @@ export namespace serverStatus {
3132

3233
export function initialize() {
3334
serverTasks.onDidUpdateServerTask(tasks => {
34-
isBusy = tasks.some(task => !task.complete);
35+
isBusy = tasks.some(task => !(task.complete));
3536
fireEvent();
3637
});
3738
}

src/serverTaskPresenter.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions, window, ProgressLocation, Progress, workspace } from "vscode";
1+
import { tasks, Task, TaskScope, Pseudoterminal, CustomExecution, TaskExecution, TaskRevealKind, TaskPanelKind, EventEmitter, Event, TerminalDimensions, window, Progress, ProgressLocation, workspace } from "vscode";
22
import { serverTasks } from "./serverTasks";
33
import { Disposable } from "vscode-languageclient";
4-
import { ProgressReport } from "./protocol";
4+
import { ProgressReport, ProgressKind } from "./protocol";
55
import { Commands } from "./commands";
66
import { getJavaConfiguration } from "./utils";
77

@@ -91,17 +91,11 @@ class ServerTaskTerminal implements Pseudoterminal {
9191

9292
private printTask(report: ProgressReport) {
9393
if (report.complete) {
94-
this.onDidWriteEvent.fire(`${report.id.slice(0, 8)} ${report.task} [Done]\r\n`);
94+
this.onDidWriteEvent.fire(`${report.token.slice(0, 8)} ${report.value.message} [Done]\r\n`);
9595
return;
9696
}
9797

98-
let taskMsg = `${report.id.slice(0, 8)} ${report.task}`;
99-
if (report.status) {
100-
taskMsg += `: ${report.status}`;
101-
}
102-
if (report.totalWork && report.workDone >= 0) {
103-
taskMsg += ` [${report.workDone}/${report.totalWork}]`;
104-
}
98+
const taskMsg = `${report.token.slice(0, 8)} ${report.value.message}`;
10599

106100
this.onDidWriteEvent.fire(`${taskMsg}\r\n`);
107101
}
@@ -141,19 +135,16 @@ export class ActivationProgressNotification {
141135
} else if (!showBuildStatusEnabled) {
142136
return;
143137
}
144-
const isProgressReportEnabled: boolean = getJavaConfiguration().get("progressReports.enabled");
145-
const title = isProgressReportEnabled ? "Opening Java Projects" : "Opening Java Projects...";
138+
const title = "Opening Java Projects";
146139
window.withProgress({
147140
location: ProgressLocation.Notification,
148141
title,
149142
cancellable: false,
150143
}, (progress: Progress<{ message?: string; increment?: number }>) => {
151144
return new Promise<void>((resolve) => {
152-
if (isProgressReportEnabled) {
153-
progress.report({
154-
message: `[check details](command:${Commands.SHOW_SERVER_TASK_STATUS})`
155-
});
156-
}
145+
progress.report({
146+
message: `[check details](command:${Commands.SHOW_SERVER_TASK_STATUS})`
147+
});
157148
this.onHide(() => {
158149
for (const disposable of this.disposables) {
159150
disposable.dispose();

src/serverTasks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { EventEmitter, Progress } from "vscode";
2-
import { ProgressReport } from "./protocol";
1+
import { EventEmitter } from "vscode";
2+
import { ProgressReport, ProgressKind } from "./protocol";
33

44
const findIndex = require("lodash.findindex");
55

@@ -56,7 +56,7 @@ function recycleTasks(tasks: ProgressReport[], length: number) {
5656
}
5757

5858
function applyReport(report: ProgressReport) {
59-
const index = findIndex(tasks, task => task.id === report.id);
59+
const index = findIndex(tasks, task => task.token === report.token);
6060
if (index === -1) {
6161
tasks.push(report);
6262
} else {

src/settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ function hasJavaConfigChanged(oldConfig: WorkspaceConfiguration, newConfig: Work
133133
return hasConfigKeyChanged('jdt.ls.java.home', oldConfig, newConfig)
134134
|| hasConfigKeyChanged('home', oldConfig, newConfig)
135135
|| hasConfigKeyChanged('jdt.ls.vmargs', oldConfig, newConfig)
136-
|| hasConfigKeyChanged('progressReports.enabled', oldConfig, newConfig)
137136
|| hasConfigKeyChanged('server.launchMode', oldConfig, newConfig)
138137
|| hasConfigKeyChanged('sharedIndexes.location', oldConfig, newConfig);;
139138
}

src/standardLanguageClient.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as pasteAction from './pasteAction';
2222
import { registerPasteEventHandler } from './pasteEventHandler';
2323
import { collectBuildFilePattern, onExtensionChange } from "./plugin";
2424
import { pomCodeActionMetadata, PomCodeActionProvider } from "./pom/pomCodeActionProvider";
25-
import { ActionableNotification, BuildProjectParams, BuildProjectRequest, CompileWorkspaceRequest, CompileWorkspaceStatus, EventNotification, EventType, ExecuteClientCommandRequest, FeatureStatus, FindLinks, GradleCompatibilityInfo, LinkLocation, ProgressReportNotification, ServerNotification, SourceAttachmentAttribute, SourceAttachmentRequest, SourceAttachmentResult, SourceInvalidatedEvent, StatusNotification, UpgradeGradleWrapperInfo } from "./protocol";
25+
import { ActionableNotification, BuildProjectParams, BuildProjectRequest, CompileWorkspaceRequest, CompileWorkspaceStatus, EventNotification, EventType, ExecuteClientCommandRequest, FeatureStatus, FindLinks, GradleCompatibilityInfo, LinkLocation, ProgressKind, ProgressNotification, ServerNotification, SourceAttachmentAttribute, SourceAttachmentRequest, SourceAttachmentResult, SourceInvalidatedEvent, StatusNotification, UpgradeGradleWrapperInfo } from "./protocol";
2626
import * as refactorAction from './refactorAction';
2727
import { getJdkUrl, RequirementsData, sortJdksBySource, sortJdksByVersion } from "./requirements";
2828
import { serverStatus, ServerStatusKind } from "./serverStatus";
@@ -192,7 +192,8 @@ export class StandardLanguageClient {
192192
}
193193
});
194194

195-
this.languageClient.onNotification(ProgressReportNotification.type, (progress) => {
195+
this.languageClient.onNotification(ProgressNotification.type, (progress) => {
196+
progress.complete = progress.value.kind === ProgressKind.end;
196197
serverTasks.updateServerTask(progress);
197198
});
198199

0 commit comments

Comments
 (0)