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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht

### Launch

- `mainClass` (required) - The main class of the program (fully qualified name, e.g. com.xyz.MainClass).
- `mainClass` (required) - The main class of the program (fully qualified name, e.g. [mymodule/]com.xyz.MainClass).
- `args` - The command line arguments passed to the program.
- `sourcePaths` - The extra source directories of the program. The debugger looks for source code from project settings by default. This option allows the debugger to look for source code in extra directories.
- `modulePaths` - The modulepaths for launching the JVM. If not specified, the debugger will automatically resolve from current project.
- `classPaths` - The classpaths for launching the JVM. If not specified, the debugger will automatically resolve from current project.
- `encoding` - The `file.encoding` setting for the JVM. If not specified, 'UTF-8' will be used. Possible values can be found in http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html.
- `vmArgs` - The extra options and system properties for the JVM (e.g. -Xms\<size\> -Xmx\<size\> -D\<name\>=\<value\>).
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"mainClass": {
"type": "string",
"description": "The main class of the program (fully qualified name, e.g. com.xyz.MainClass).",
"description": "The main class of the program (fully qualified name, e.g. [mymodule/]com.xyz.MainClass).",
"default": ""
},
"args": {
Expand All @@ -73,6 +73,14 @@
"description": "The extra options and system properties for the JVM (e.g. -Xms<size> -Xmx<size> -D<name>=<value>).",
"default": ""
},
"modulePaths": {
"type": "array",
"items": {
"type": "string"
},
"description": "The modulepaths for launching the JVM. If not specified, the debugger will automatically resolve from current project.",
"default": []
},
"classPaths": {
"type": "array",
"items": {
Expand Down
24 changes: 16 additions & 8 deletions src/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
const res = <any[]>(await resolveMainClass());
if (res.length === 0) {
vscode.window.showErrorMessage(
"No main class is resolved in the workspace. Please specify the mainClass (e.g. com.xyz.MainClass) in the launch.json.");
"Cannot resolve main class automatically, please specify the mainClass " +
"(e.g. [mymodule/]com.xyz.MainClass) in the launch.json.");
return;
}
const pickItems = res.map((item) => {
Expand All @@ -110,17 +111,20 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
config.mainClass = selection.item.mainClass;
config.projectName = selection.item.projectName;
} else {
vscode.window.showErrorMessage("Please specify the mainClass (e.g. com.xyz.MainClass) in the launch.json.");
this.log("usageError", "Please specify the mainClass (e.g. com.xyz.MainClass) in the launch.json.");
vscode.window.showErrorMessage("Please specify the mainClass (e.g. [mymodule/]com.xyz.MainClass) in the launch.json.");
this.log("usageError", "Please specify the mainClass (e.g. [mymodule/]com.xyz.MainClass) in the launch.json.");
return undefined;
}
}
if (!config.classPaths || !Array.isArray(config.classPaths) || !config.classPaths.length) {
config.classPaths = await resolveClasspath(config.mainClass, config.projectName);
if (this.isEmptyArray(config.classPaths) && this.isEmptyArray(config.modulePaths)) {
const result = <any[]>(await resolveClasspath(config.mainClass, config.projectName));
config.modulePaths = result[0];
config.classPaths = result[1];
}
if (!config.classPaths || !Array.isArray(config.classPaths) || !config.classPaths.length) {
vscode.window.showErrorMessage("Cannot resolve the classpaths automatically, please specify the value in the launch.json.");
this.log("usageError", "Cannot resolve the classpaths automatically, please specify the value in the launch.json.");
if (this.isEmptyArray(config.classPaths) && this.isEmptyArray(config.modulePaths)) {
const hintMessage = "Cannot resolve the modulepaths/classpaths automatically, please specify the value in the launch.json.";
vscode.window.showErrorMessage(hintMessage);
this.log("usageError", hintMessage);
return undefined;
}
} else if (config.request === "attach") {
Expand Down Expand Up @@ -177,6 +181,10 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
this._reporter.sendTelemetryEvent(type, { message });
}
}

private isEmptyArray(configItems: any): boolean {
return !Array.isArray(configItems) || !configItems.length;
}
}

function startDebugSession() {
Expand Down