Skip to content

Commit 39a84b3

Browse files
Display the running launch config name in progress bar for transparency (#1299)
1 parent fcc0eca commit 39a84b3

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

src/configurationProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
108108
progressReporter.observe(token);
109109
const defaultLaunchConfig = {
110110
type: "java",
111-
name: "Launch Current File",
111+
name: "Current File",
112112
request: "launch",
113113
// tslint:disable-next-line
114114
mainClass: "${file}",
@@ -169,7 +169,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
169169
}
170170

171171
private constructLaunchConfigName(mainClass: string, cache: { [key: string]: any }) {
172-
const name = `Launch ${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`;
172+
const name = `${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`;
173173
if (cache[name] === undefined) {
174174
cache[name] = 0;
175175
return name;
@@ -204,7 +204,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
204204
if (!progressReporter && config.__progressId) {
205205
return undefined;
206206
} else if (!progressReporter) {
207-
progressReporter = progressProvider.createProgressReporter(config.noDebug ? "Run" : "Debug");
207+
progressReporter = progressProvider.createProgressReporter(utility.launchJobName(config.name, config.noDebug));
208208
}
209209

210210
progressReporter.observe(token);

src/debugCodeLensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async function constructDebugConfig(mainClass: string, projectName: string, work
152152
if (!debugConfig) {
153153
debugConfig = {
154154
type: "java",
155-
name: `Launch ${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`,
155+
name: `${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`,
156156
request: "launch",
157157
mainClass,
158158
projectName,

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ async function launchMain(mainMethods: IMainClassOption[], uri: vscode.Uri, noDe
330330
throw new utility.OperationCancelledError("");
331331
}
332332

333+
progressReporter.setJobName(utility.launchJobNameByMainClass(pick.mainClass, noDebug));
333334
progressReporter.report("Launching main class...");
334335
startDebugging(pick.mainClass, pick.projectName || "", uri, noDebug, progressReporter);
335336
}
@@ -366,6 +367,7 @@ async function runJavaProject(node: any, noDebug: boolean) {
366367
throw new utility.OperationCancelledError("");
367368
}
368369

370+
progressReporter.setJobName(utility.launchJobNameByMainClass(pick.mainClass, noDebug));
369371
progressReporter.report("Launching main class...");
370372
const projectName: string | undefined = pick.projectName;
371373
const mainClass: string = pick.mainClass;
@@ -379,7 +381,7 @@ async function runJavaProject(node: any, noDebug: boolean) {
379381
});
380382
const debugConfig = existConfig || {
381383
type: "java",
382-
name: `Launch ${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`,
384+
name: `${mainClass.substr(mainClass.lastIndexOf(".") + 1)}`,
383385
request: "launch",
384386
mainClass,
385387
projectName,

src/progressAPI.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
import { CancellationToken, ProgressLocation } from "vscode";
55

66
export interface IProgressReporter {
7+
/**
8+
* Set the job name.
9+
* @param jobName the job name
10+
*/
11+
setJobName(jobName: string): void;
12+
713
/**
814
* Returns the id of the progress reporter.
915
*/

src/progressImpl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class ProgressReporter implements IProgressReporter {
5252
this._disposables.push(this._tokenSource);
5353
}
5454

55+
public setJobName(jobName: string): void {
56+
this._jobName = jobName;
57+
}
58+
5559
public getId(): string {
5660
return this._id;
5761
}

src/utility.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,13 @@ function getJavaServerMode(): ServerMode {
313313
return vscode.workspace.getConfiguration().get("java.server.launchMode")
314314
|| ServerMode.HYBRID;
315315
}
316+
317+
export function launchJobName(configName: string, noDebug: boolean): string {
318+
let jobName = noDebug ? "Run" : "Debug";
319+
jobName += configName ? ` '${configName} '` : "";
320+
return jobName;
321+
}
322+
323+
export function launchJobNameByMainClass(mainClass: string, noDebug: boolean): string {
324+
return launchJobName(mainClass.substr(mainClass.lastIndexOf(".") + 1), noDebug);
325+
}

0 commit comments

Comments
 (0)