build workspace before trigger debug and support single file debug (#129)
* build workspace before trigger debug and support single file debug Signed-off-by: xuzho <xuzho@microsoft.com> * update requirement Signed-off-by: xuzho <xuzho@microsoft.com>
This commit is contained in:
parent
6c1fa39e3e
commit
ae3b9d7996
|
@ -19,7 +19,7 @@ A lightweight Java Debugger based on [Java Debug Server](https://github.com/Micr
|
|||
## Requirements
|
||||
- JDK (version 1.8.0 or later)
|
||||
- VS Code (version 1.17.0 or later)
|
||||
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.12.0 or later)
|
||||
- [Language Support for Java by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java) (version 0.13.0 or later)
|
||||
|
||||
## Install
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ export const JAVA_RESOLVE_CLASSPATH = "vscode.java.resolveClasspath";
|
|||
|
||||
export const JAVA_RESOLVE_MAINCLASS = "vscode.java.resolveMainClass";
|
||||
|
||||
export const JAVA_BUILD_WORKSPACE = "vscode.java.buildWorkspace";
|
||||
export const JAVA_BUILD_WORKSPACE = "java.workspace.compile";
|
||||
|
||||
export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
|
||||
|
||||
|
|
|
@ -79,10 +79,23 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
|
|||
// log a warning message and continue, since logger failure should not block debug session
|
||||
console.log("Cannot set log level to java debuggeer.")
|
||||
}
|
||||
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
|
||||
// VSCode will create a launch.json automatically if no launch.json yet.
|
||||
|
||||
// trigger build workspace
|
||||
try {
|
||||
const buildResult = await vscode.commands.executeCommand(commands.JAVA_BUILD_WORKSPACE);
|
||||
console.log(buildResult);
|
||||
} catch (err) {
|
||||
vscode.window.showErrorMessage("Build failed, please fix build error first.");
|
||||
return config;
|
||||
} else if (config.request === "launch") {
|
||||
}
|
||||
|
||||
if (Object.keys(config).length === 0) { // No launch.json in current workspace.
|
||||
// Generate config in memory for files without project.
|
||||
config.type = "java";
|
||||
config.name = "Java Debug";
|
||||
config.request = "launch";
|
||||
}
|
||||
if (config.request === "launch") {
|
||||
if (!config.mainClass) {
|
||||
const res = <any[]>(await resolveMainClass());
|
||||
if (res.length === 0) {
|
||||
|
|
Loading…
Reference in New Issue