Skip to content

Commit

Permalink
Merge pull request #64 from csordasmarton/remove_stop_analysis_window
Browse files Browse the repository at this point in the history
Remove unclosable CodeChecker analysis in progress window
  • Loading branch information
Discookie authored Jan 31, 2022
2 parents 65747d4 + c6ff2a6 commit e366a06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 48 deletions.
8 changes: 1 addition & 7 deletions src/backend/executor/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export enum ProcessType {
export interface ProcessParameters {
/** Default: true, false when type is parse */
forwardStdoutToLogs?: boolean,
/** Default: true, false when type is parse or version */
showProgressBar?: boolean,

/**
* Name of the process, preferred to be one of ProcessType.
* Default: other
Expand Down Expand Up @@ -78,15 +77,10 @@ export class ScheduledProcess implements Disposable {
this.processParameters = parameters;

const forwardDefaults: string[] = [ ProcessType.parse ];
const progressDefaults: string[] = [ ProcessType.parse, ProcessType.version ];

if (this.processParameters.forwardStdoutToLogs === undefined) {
this.processParameters.forwardStdoutToLogs = !forwardDefaults.includes(parameters.processType ?? '');
}

if (this.processParameters.showProgressBar === undefined) {
this.processParameters.showProgressBar = !progressDefaults.includes(parameters.processType ?? '');
}
}

dispose() {
Expand Down
42 changes: 1 addition & 41 deletions src/editor/executor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
CancellationTokenSource,
ExtensionContext,
ProgressLocation,
StatusBarAlignment,
StatusBarItem,
commands,
Expand All @@ -12,7 +10,6 @@ import { ExtensionApi } from '../backend';
import { ProcessStatus } from '../backend/executor/process';

export class ExecutorAlerts {
private activeToken?: CancellationTokenSource;
private statusBarItem: StatusBarItem;
private enableProgress = true;

Expand Down Expand Up @@ -43,16 +40,11 @@ export class ExecutorAlerts {

onStatusChange(status: ProcessStatus) {
// Do not update when a non-progressbar process was finished
if (ExtensionApi.executorManager.activeProcess !== undefined) {
this.enableProgress = ExtensionApi.executorManager.activeProcess.processParameters.showProgressBar!;
}

if (!this.enableProgress) {
if (ExtensionApi.executorManager.activeProcess === undefined) {
return;
}

if (status === ProcessStatus.running) {
this.showProgressbar('CodeChecker: analysis in progress...');
this.statusBarItem.text = 'CodeChecker: analysis in progress...';
this.statusBarItem.show();
return;
Expand All @@ -76,38 +68,6 @@ export class ExecutorAlerts {
break;
}

this.hideProgressbar();
this.statusBarItem.show();
}

showProgressbar(message: string) {
// Clear previous alert, and then create the new progress
if (this.activeToken !== undefined) {
this.activeToken.cancel();
}

this.activeToken = new CancellationTokenSource();

window.withProgress(
{ cancellable: true, location: ProgressLocation.Notification, title: message },
async (_progress, cancelButton) => new Promise((res, _rej) => {
this.activeToken?.token.onCancellationRequested(() => {
res(null);
});

cancelButton.onCancellationRequested(() => {
// On Cancel button, kill the process
ExtensionApi.executorBridge.stopAnalysis();
res(null);
});
})
);
}

hideProgressbar() {
if (this.activeToken !== undefined) {
this.activeToken.cancel();
this.activeToken = undefined;
}
}
}
8 changes: 8 additions & 0 deletions src/sidebar/views/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ export class OverviewView implements TreeDataProvider<OverviewItem> {
command: 'codechecker.executor.analyzeProject',
}
),
new OverviewItem(
'Stop analysis',
'debug-stop',
{
title: 'stopAnalysis',
command: 'codechecker.executor.stopAnalysis',
}
),
],
'ccNotFound': [
new OverviewItem(
Expand Down

0 comments on commit e366a06

Please sign in to comment.