Skip to content

Commit bb79764

Browse files
Use a progress reporter to hint the current build status when run or debug a program
1 parent b41dabe commit bb79764

14 files changed

+538
-180
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
121121
- `java.debug.settings.jdwp.limitOfVariablesPerJdwpRequest`: The maximum number of variables or fields that can be requested in one JDWP request. The higher the value, the less frequently debuggee will be requested when expanding the variable view. Also a large number can cause JDWP request timeout. Defaults to 100.
122122
- `java.debug.settings.jdwp.requestTimeout`: The timeout (ms) of JDWP request when the debugger communicates with the target JVM. Defaults to 3000.
123123
- `java.debug.settings.vmArgs`: The default VM arguments to launch the Java program. Eg. Use '-Xmx1G -ea' to increase the heap size to 1GB and enable assertions. If you want to customize the VM arguments for a specific debug session, please modify the 'vmArgs' config in launch.json.
124+
- `java.debug.settings.showRunStatusAsNotification`: Show the build status as the progress notification every time you run or debug a program. Defaults to `true`.
124125

125126
Pro Tip: The documentation [Configuration.md](https://github.com/microsoft/vscode-java-debug/blob/master/Configuration.md) provides lots of samples to demonstrate how to use these debug configurations, recommend to take a look.
126127

package-lock.json

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

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,11 @@
741741
"type": "string",
742742
"description": "%java.debugger.configuration.vmArgs.description%",
743743
"default": ""
744+
},
745+
"java.debug.settings.showRunStatusAsNotification": {
746+
"type": "boolean",
747+
"description": "%java.debugger.configuration.showRunStatusAsNotification%",
748+
"default": true
744749
}
745750
}
746751
}
@@ -756,7 +761,8 @@
756761
"@types/glob": "^7.1.3",
757762
"@types/lodash": "^4.14.137",
758763
"@types/mocha": "^5.2.7",
759-
"@types/node": "^8.10.51",
764+
"@types/node": "^14.14.10",
765+
"@types/uuid": "^8.3.0",
760766
"@types/vscode": "1.49.0",
761767
"cross-env": "^5.2.0",
762768
"gulp": "^4.0.2",
@@ -765,13 +771,15 @@
765771
"shelljs": "^0.8.3",
766772
"ts-loader": "^5.4.5",
767773
"tslint": "^5.18.0",
768-
"typescript": "^3.5.3",
774+
"typescript": "^4.1.2",
769775
"vscode-test": "^1.2.0",
770776
"webpack": "^4.39.2",
771777
"webpack-cli": "^3.3.7"
772778
},
773779
"dependencies": {
780+
"compare-versions": "^3.6.0",
774781
"lodash": "^4.17.19",
782+
"uuid": "^8.3.1",
775783
"vscode-extension-telemetry": "^0.1.6",
776784
"vscode-extension-telemetry-wrapper": "^0.8.0"
777785
}

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@
5858
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "Skip the specified classes when breaking on exception. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo",
5959
"java.debugger.configuration.jdwp.limitOfVariablesPerJdwpRequest.description": "The maximum number of variables or fields that can be requested in one JDWP request. The higher the value, the less frequently debuggee will be requested when expanding the variable view. Also a large number can cause JDWP request timeout.",
6060
"java.debugger.configuration.jdwp.requestTimeout.description": "The timeout (ms) of JDWP request when the debugger communicates with the target JVM.",
61-
"java.debugger.configuration.vmArgs.description": "The default VM arguments to launch the Java program. Eg. Use '-Xmx1G -ea' to increase the heap size to 1GB and enable assertions. If you want to customize the VM arguments for a specific debug session, please modify the 'vmArgs' config in launch.json."
61+
"java.debugger.configuration.vmArgs.description": "The default VM arguments to launch the Java program. Eg. Use '-Xmx1G -ea' to increase the heap size to 1GB and enable assertions. If you want to customize the VM arguments for a specific debug session, please modify the 'vmArgs' config in launch.json.",
62+
"java.debugger.configuration.showRunStatusAsNotification": "Show the build status as the progress notification every time you run or debug a program."
6263
}

package.nls.zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "当发生异常时,跳过指定的类。你可以使用内置变量,如'$JDK'和'$Libraries'来跳过一组类,或者添加一个特定的类名表达式,如java.*,*.Foo。",
5757
"java.debugger.configuration.jdwp.limitOfVariablesPerJdwpRequest.description": "一次JDWP请求中可以请求的变量或字段的最大数量。该值越高,在展开变量视图时,请求debuggee的频率就越低。同时数量过大也会导致JDWP请求超时。",
5858
"java.debugger.configuration.jdwp.requestTimeout.description": "调试器与目标JVM通信时JDWP请求的超时时间(ms)。",
59-
"java.debugger.configuration.vmArgs.description": "启动Java程序的默认VM参数。例如,使用'-Xmx1G -ea'将堆大小增加到1GB并启用断言。如果要为特定的调试会话定制VM参数,请修改launch.json中的'vmArgs'配置。"
59+
"java.debugger.configuration.vmArgs.description": "启动Java程序的默认VM参数。例如,使用'-Xmx1G -ea'将堆大小增加到1GB并启用断言。如果要为特定的调试会话定制VM参数,请修改launch.json中的'vmArgs'配置。",
60+
"java.debugger.configuration.showRunStatusAsNotification": "每次运行或调试程序时,将构建状态显示为进度通知。"
6061
}

src/build.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ import { instrumentOperation, sendInfo, sendOperationError, setErrorCode } from
77
import * as anchor from "./anchor";
88
import * as commands from "./commands";
99
import * as lsPlugin from "./languageServerPlugin";
10+
import { IProgressReporter } from "./progressAPI";
1011
import * as utility from "./utility";
1112

1213
const JAVA_DEBUG_CONFIGURATION = "java.debug.settings";
1314
const ON_BUILD_FAILURE_PROCEED = "onBuildFailureProceed";
1415

15-
export async function buildWorkspace(): Promise<boolean> {
16+
enum CompileWorkspaceStatus {
17+
FAILED = 0,
18+
SUCCEED = 1,
19+
WITHERROR = 2,
20+
CANCELLED = 3,
21+
}
22+
23+
export async function buildWorkspace(progressReporter: IProgressReporter): Promise<boolean> {
1624
const buildResult = await instrumentOperation("build", async (operationId: string) => {
1725
let error;
1826
try {
19-
await commands.executeJavaExtensionCommand(commands.JAVA_BUILD_WORKSPACE, false);
27+
await commands.executeJavaExtensionCommand(commands.JAVA_BUILD_WORKSPACE, false, progressReporter.getCancellationToken());
2028
} catch (err) {
2129
error = err;
2230
}
@@ -27,11 +35,11 @@ export async function buildWorkspace(): Promise<boolean> {
2735
};
2836
})();
2937

30-
if (buildResult.error) {
38+
if (buildResult.error === CompileWorkspaceStatus.CANCELLED) {
39+
return false;
40+
} else {
3141
return handleBuildFailure(buildResult.operationId, buildResult.error);
3242
}
33-
34-
return true;
3543
}
3644

3745
async function handleBuildFailure(operationId: string, err: any): Promise<boolean> {

0 commit comments

Comments
 (0)