Skip to content

Commit

Permalink
Show server tasks in terminal (#1153)
Browse files Browse the repository at this point in the history
Signed-off-by: Rome Li <[email protected]>
  • Loading branch information
akaroml authored and fbricon committed Nov 25, 2019
1 parent 84f4522 commit bb55be7
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 48 deletions.
79 changes: 50 additions & 29 deletions package-lock.json

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

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"preview": true,
"enableProposedApi": false,
"engines": {
"vscode": "^1.36.0"
"vscode": "^1.40.0"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -452,6 +452,11 @@
"command": "java.project.listSourcePaths",
"title": "List all Java source paths",
"category": "Java"
},
{
"command": "java.show.server.task.status",
"title": "Show Build Job Status",
"category": "Java"
}
],
"keybindings": [
Expand Down Expand Up @@ -541,13 +546,15 @@
},
"devDependencies": {
"@types/glob": "5.0.30",
"@types/lodash.findindex": "^4.6.6",
"@types/mocha": "^5.2.5",
"@types/node": "^6.0.40",
"@types/vscode": "^1.36.0",
"@types/vscode": "^1.40.0",
"@types/winston": "^2.4.4",
"gulp": "^4.0.0",
"gulp-decompress": "2.0.1",
"gulp-download": "0.0.1",
"lodash.findindex": "^4.6.0",
"mocha": "^5.2.0",
"ts-loader": "^5.3.1",
"tslint": "^5.11.0",
Expand Down
4 changes: 4 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,8 @@ export namespace Commands {
* Navigate To Super Method Command.
*/
export const NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND = 'java.action.navigateToSuperImplementation';
/**
* Show server task status
*/
export const SHOW_SERVER_TASK_STATUS = 'java.show.server.task.status';
}
25 changes: 9 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import { getJavaConfiguration } from './utils';
import { onConfigurationChange, excludeProjectSettingsFiles } from './settings';
import { logger, initializeLogFile } from './log';
import glob = require('glob');
import { serverTasks } from './serverTasks';
import { serverTaskPresenter } from './serverTaskPresenter';

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

const item = window.createStatusBarItem(StatusBarAlignment.Right, Number.MIN_VALUE);
item.text = '$(sync~spin)';
item.command = Commands.OPEN_OUTPUT;
const progressBar = window.createStatusBarItem(StatusBarAlignment.Left, Number.MIN_VALUE + 1);
item.command = Commands.SHOW_SERVER_TASK_STATUS;

commands.executeCommand(Commands.SHOW_SERVER_TASK_STATUS);

let serverOptions;
const port = process.env['SERVER_PORT'];
Expand Down Expand Up @@ -215,8 +217,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
switch (report.type) {
case 'Started':
item.text = '$(thumbsup)';
p.report({ message: 'Finished' });
lastStatus = item.text;
commands.executeCommand('setContext', 'javaLSReady', true);
resolve({
apiVersion: ExtensionApiVersion,
Expand All @@ -228,8 +228,6 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
break;
case 'Error':
item.text = '$(thumbsdown)';
lastStatus = item.text;
p.report({ message: 'Finished with Error' });
toggleItem(window.activeTextEditor, item);
resolve({
apiVersion: ExtensionApiVersion,
Expand All @@ -240,22 +238,15 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
});
break;
case 'Starting':
p.report({ message: report.message });
break;
case 'Message':
item.text = report.message;
setTimeout(() => { item.text = lastStatus; }, 3000);
// message goes to progress report instead
break;
}
item.tooltip = report.message;
toggleItem(window.activeTextEditor, item);
});
languageClient.onNotification(ProgressReportNotification.type, (progress) => {
progressBar.show();
progressBar.text = progress.status;
if (progress.complete) {
setTimeout(() => { progressBar.hide(); }, 500);
}
serverTasks.updateServerTask(progress);
});
languageClient.onNotification(ActionableNotification.type, (notification) => {
let show = null;
Expand Down Expand Up @@ -441,6 +432,8 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {

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

context.subscriptions.push(commands.registerCommand(Commands.SHOW_SERVER_TASK_STATUS, () => serverTaskPresenter.presentServerTaskView()));

context.subscriptions.push(onConfigurationChange(languageClient, context));
toggleItem(window.activeTextEditor, item);
});
Expand Down
Loading

0 comments on commit bb55be7

Please sign in to comment.