8000 Use a progress reporter to hint the current build status when run or debug a program by testforstephen · Pull Request #919 · microsoft/vscode-java-debug · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
- `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.
- `java.debug.settings.jdwp.requestTimeout`: The timeout (ms) of JDWP request when the debugger communicates with the target JVM. Defaults to 3000.
- `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.
- `java.silentNotification`: Controls whether notifications can be used to report progress. If true, use status bar to report progress instead. Defaults to `false`.

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.

Expand Down
36 changes: 27 additions & 9 deletions package-lock.json

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

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,11 @@
"type": "string",
"description": "%java.debugger.configuration.vmArgs.description%",
"default": ""
},
"java.silentNotification": {
"type": "boolean",
"description": "%java.debugger.configuration.silentNotification%",
"default": false
}
}
}
Expand All @@ -756,7 +761,8 @@
"@types/glob": "^7.1.3",
"@types/lodash": "^4.14.137",
"@types/mocha": "^5.2.7",
"@types/node": "^8.10.51",
"@types/node": "^14.14.10",
"@types/uuid": "^8.3.0",
"@types/vscode": "1.49.0",
"cross-env": "^5.2.0",
"gulp": "^4.0.2",
Expand All @@ -765,13 +771,15 @@
"shelljs": "^0.8.3",
"ts-loader": "^5.4.5",
"tslint": "^5.18.0",
"typescript": "^3.5.3",
"typescript": "^4.1.2",
"vscode-test": "^1.2.0",
"webpack": "^4.39.2",
"webpack-cli": "^3.3.7"
},
"dependencies": {
"compare-versions": "^3.6.0",
"lodash": "^4.17.19",
"uuid": "^8.3.1",
"vscode-extension-telemetry": "^0.1.6",
"vscode-extension-telemetry-wrapper": "^0.8.0"
}
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"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",
"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.",
"java.debugger.configuration.jdwp.requestTimeout.description": "The timeout (ms) of JDWP request when the debugger communicates with the target JVM.",
"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."
"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.",
"java.debugger.configuration.silentNotification": "Controls whether notifications can be used to report progress. If true, use status bar to report progress instead."
}
3 changes: 2 additions & 1 deletion package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "当发生异常时,跳过指定的类。你可以使用内置变量,如'$JDK'和'$Libraries'来跳过一组类,或者添加一个特定的类名表达式,如java.*,*.Foo。",
"java.debugger.configuration.jdwp.limitOfVariablesPerJdwpRequest.description": "一次JDWP请求中可以请求的变量或字段的最大数量。该值越高,在展开变量视图时,请求debuggee的频率就越低。同时数量过大也会导致JDWP请求超时。",
"java.debugger.configuration.jdwp.requestTimeout.description": "调试器与目标JVM通信时JDWP请求的超时时间(ms)。",
"java.debugger.configuration.vmArgs.description": "启动Java程序的默认VM参数。例如,使用'-Xmx1G -ea'将堆大小增加到1GB并启用断言。如果要为特定的调试会话定制VM参数,请修改launch.json中的'vmArgs'配置。"
"java.debugger.configuration.vmArgs.description": "启动Java程序的默认VM参数。例如,使用'-Xmx1G -ea'将堆大小增加到1GB并启用断言。如果要为特定的调试会话定制VM参数,请修改launch.json中的'vmArgs'配置。",
"java.debugger.configuration.silentNotification": "控制是否可以使用通知来报告进度。如果为真,则使用状态栏来报告进度。"
}
28 changes: 18 additions & 10 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ import { instrumentOperation, sendInfo, sendOperationError, setErrorCode } from
import * as anchor from "./anchor";
import * as commands from "./commands";
import * as lsPlugin from "./languageServerPlugin";
import { IProgressReporter } from "./progressAPI";
import * as utility from "./utility";

const JAVA_DEBUG_CONFIGURATION = "java.debug.settings";
const ON_BUILD_FAILURE_PROCEED = "onBuildFailureProceed";

export async function buildWorkspace(): Promise<boolean> {
enum CompileWorkspaceStatus {
FAILED = 0,
SUCCEED = 1,
WITHERROR = 2,
CANCELLED = 3,
}

export async function buildWorkspace(progressReporter: IProgressReporter): Promise<boolean> {
const buildResult = await instrumentOperation("build", async (operationId: string) => {
let error;
try {
await commands.executeJavaExtensionCommand(commands.JAVA_BUILD_WORKSPACE, false);
await commands.executeJavaExtensionCommand(commands.JAVA_BUILD_WORKSPACE, false, progressReporter.getCancellationToken());
} catch (err) {
error = err;
}
Expand All @@ -27,14 +35,14 @@ export async function buildWorkspace(): Promise<boolean> {
};
})();

if (buildResult.error) {
return handleBuildFailure(buildResult.operationId, buildResult.error);
if (progressReporter.isCancelled() || buildResult.error === CompileWorkspaceStatus.CANCELLED) {
return false;
} else {
return handleBuildFailure(buildResult.operationId, buildResult.error, progressReporter);
}

return true;
}

async function handleBuildFailure(operationId: string, err: any): Promise<boolean> {
async function handleBuildFailure(operationId: string, err: any, progressReporter: IProgressReporter): Promise<boolean> {
const configuration = vscode.workspace.getConfiguration(JAVA_DEBUG_CONFIGURATION);
const onBuildFailureProceed = configuration.get<boolean>(ON_BUILD_FAILURE_PROCEED);

Expand All @@ -48,13 +56,13 @@ async function handleBuildFailure(operationId: string, err: any): Promise<boolea
});
setErrorCode(error, Number(err));
sendOperationError(operationId, "build", error);
if (err === lsPlugin.CompileWorkspaceStatus.WITHERROR || err === lsPlugin.CompileWorkspaceStatus.FAILED) {
if (!onBuildFailureProceed && (err === lsPlugin.CompileWorkspaceStatus.WITHERROR || err === lsPlugin.CompileWorkspaceStatus.FAILED)) {
if (checkErrorsReportedByJavaExtension()) {
vscode.commands.executeCommand("workbench.actions.view.problems");
}

const ans = onBuildFailureProceed ? "Proceed" : (await vscode.window.showErrorMessage("Build failed, do you want to continue?",
"Proceed", "Fix...", "Cancel"));
progressReporter.hide(true);
const ans = await vscode.window.showErrorMessage("Build failed, do you want to continue?", "Proceed", "Fix...", "Cancel");
sendInfo(operationId, {
operationName: "build",
choiceForBuildError: ans || "esc",
Expand Down
Loading
0