Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae3b9d7

Browse files
authored
build workspace before trigger debug and support single file debug (microsoft#129)
* build workspace before trigger debug and support single file debug Signed-off-by: xuzho <[email protected]> * update requirement Signed-off-by: xuzho <[email protected]>
1 parent 6c1fa39 commit ae3b9d7

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A lightweight Java Debugger based on [Java Debug Server](https://github.com/Micr
1919
## Requirements
2020
- JDK (version 1.8.0 or later)
2121
- VS Code (version 1.17.0 or later)
22-
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.12.0 or later)
22+
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.13.0 or later)
2323

2424
## Install
2525

src/commands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const JAVA_RESOLVE_CLASSPATH = "vscode.java.resolveClasspath";
1313

1414
export const JAVA_RESOLVE_MAINCLASS = "vscode.java.resolveMainClass";
1515

16-
export const JAVA_BUILD_WORKSPACE = "vscode.java.buildWorkspace";
16+
export const JAVA_BUILD_WORKSPACE = "java.workspace.compile";
1717

1818
export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
1919

src/configurationProvider.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,23 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
7979
// log a warning message and continue, since logger failure should not block debug session
8080
console.log("Cannot set log level to java debuggeer.")
8181
}
82-
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
83-
// VSCode will create a launch.json automatically if no launch.json yet.
82+
83+
// trigger build workspace
84+
try {
85+
const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE);
86+
console.log(buildResult);
87+
} catch (err) {
88+
vscode.window.showErrorMessage("Build failed, please fix build error first.");
8489
return config;
85-
} else if (config.request === "launch") {
90+
}
91+
92+
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
93+
// Generate config in memory for files without project.
94+
config.type = "java";
95+
config.name = "Java Debug";
96+
config.request = "launch";
97+
}
98+
if (config.request === "launch") {
8699
if (!config.mainClass) {
87100
const res = <any[]>(await resolveMainClass());
88101
if (res.length === 0) {

0 commit comments

Comments
 (0)