Skip to content

Commit bb55be7

Browse files
akaromlfbricon
authored andcommitted
Show server tasks in terminal (#1153)
Signed-off-by: Rome Li <rome.li@microsoft.com>
1 parent 84f4522 commit bb55be7

File tree

7 files changed

+235
-48
lines changed

7 files changed

+235
-48
lines changed

package-lock.json

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

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"preview": true,
1212
"enableProposedApi": false,
1313
"engines": {
14-
"vscode": "^1.36.0"
14+
"vscode": "^1.40.0"
1515
},
1616
"repository": {
1717
"type": "git",
@@ -452,6 +452,11 @@
452452
"command": "java.project.listSourcePaths",
453453
"title": "List all Java source paths",
454454
"category": "Java"
455+
},
456+
{
457+
"command": "java.show.server.task.status",
458+
"title": "Show Build Job Status",
459+
"category": "Java"
455460
}
456461
],
457462
"keybindings": [
@@ -541,13 +546,15 @@
541546
},
542547
"devDependencies": {
543548
"@types/glob": "5.0.30",
549+
"@types/lodash.findindex": "^4.6.6",
544550
"@types/mocha": "^5.2.5",
545551
"@types/node": "^6.0.40",
546-
"@types/vscode": "^1.36.0",
552+
"@types/vscode": "^1.40.0",
547553
"@types/winston": "^2.4.4",
548554
"gulp": "^4.0.0",
549555
"gulp-decompress": "2.0.1",
550556
"gulp-download": "0.0.1",
557+
"lodash.findindex": "^4.6.0",
551558
"mocha": "^5.2.0",
552559
"ts-loader": "^5.3.1",
553560
"tslint": "^5.11.0",

src/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,8 @@ export namespace Commands {
168168
* Navigate To Super Method Command.
169169
*/
170170
export const NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND = 'java.action.navigateToSuperImplementation';
171+
/**
172+
* Show server task status
173+
*/
174+
export const SHOW_SERVER_TASK_STATUS = 'java.show.server.task.status';
171175
}

src/extension.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ import { getJavaConfiguration } from './utils';
2525
import { onConfigurationChange, excludeProjectSettingsFiles } from './settings';
2626
import { logger, initializeLogFile } from './log';
2727
import glob = require('glob');
28+
import { serverTasks } from './serverTasks';
29+
import { serverTaskPresenter } from './serverTaskPresenter';
2830

29-
let lastStatus;
3031
let languageClient: LanguageClient;
3132
const jdtEventEmitter = new EventEmitter<Uri>();
3233
const cleanWorkspaceFileName = '.cleanWorkspace';
@@ -180,8 +181,9 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
180181

181182
const item = window.createStatusBarItem(StatusBarAlignment.Right, Number.MIN_VALUE);
182183
item.text = '$(sync~spin)';
183-
item.command = Commands.OPEN_OUTPUT;
184-
const progressBar = window.createStatusBarItem(StatusBarAlignment.Left, Number.MIN_VALUE + 1);
184+
item.command = Commands.SHOW_SERVER_TASK_STATUS;
185+
186+
commands.executeCommand(Commands.SHOW_SERVER_TASK_STATUS);
185187

186188
let serverOptions;
187189
const port = process.env['SERVER_PORT'];
@@ -215,8 +217,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
215217
switch (report.type) {
216218
case 'Started':
217219
item.text = '$(thumbsup)';
218-
p.report({ message: 'Finished' });
219-
lastStatus = item.text;
220220
commands.executeCommand('setContext', 'javaLSReady', true);
221221
resolve({
222222
apiVersion: ExtensionApiVersion,
@@ -228,8 +228,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
228228
break;
229229
case 'Error':
230230
item.text = '$(thumbsdown)';
231-
lastStatus = item.text;
232-
p.report({ message: 'Finished with Error' });
233231
toggleItem(window.activeTextEditor, item);
234232
resolve({
235233
apiVersion: ExtensionApiVersion,
@@ -240,22 +238,15 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
240238
});
241239
break;
242240
case 'Starting':
243-
p.report({ message: report.message });
244-
break;
245241
case 'Message':
246-
item.text = report.message;
247-
setTimeout(() => { item.text = lastStatus; }, 3000);
242+
// message goes to progress report instead
248243
break;
249244
}
250245
item.tooltip = report.message;
251246
toggleItem(window.activeTextEditor, item);
252247
});
253248
languageClient.onNotification(ProgressReportNotification.type, (progress) => {
254-
progressBar.show();
255-
progressBar.text = progress.status;
256-
if (progress.complete) {
257-
setTimeout(() => { progressBar.hide(); }, 500);
258-
}
249+
serverTasks.updateServerTask(progress);
259250
});
260251
languageClient.onNotification(ActionableNotification.type, (notification) => {
261252
let show = null;
@@ -441,6 +432,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
441432

442433
context.subscriptions.push(commands.registerCommand(Commands.CLEAN_WORKSPACE, () => cleanWorkspace(workspacePath)));
443434

435+
context.subscriptions.push(commands.registerCommand(Commands.SHOW_SERVER_TASK_STATUS, () => serverTaskPresenter.presentServerTaskView()));
436+
444437
context.subscriptions.push(onConfigurationChange(languageClient, context));
445438
toggleItem(window.activeTextEditor, item);
446439
});

0 commit comments

Comments
 (0)