Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Also run plain Java when noDebug from launch.json #1521

Merged
merged 1 commit into from
Aug 2, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export interface DebugDiscoveryParams {
path: string;
path: string | undefined;
mainClass: string | undefined;
buildTarget: string | undefined;
runType: RunType;
args: string[] | undefined;
jvmOptions: string[] | undefined;
env: Map<string, string> | undefined;
envFile: string | undefined;
}

export enum RunType {
Expand Down
41 changes: 33 additions & 8 deletions packages/metals-vscode/src/debugger/scalaDebugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ class ScalaMainConfigProvider implements vscode.DebugConfigurationProvider {
const args: DebugDiscoveryParams = {
path: editor.document.uri.toString(true),
runType: RunType.RunOrTestFile,
buildTarget: undefined,
mainClass: undefined,
args: undefined,
jvmOptions: undefined,
env: undefined,
envFile: undefined,
};
await startDiscovery(debugConfiguration.noDebug, args);
return debugConfiguration;
Expand All @@ -186,15 +192,34 @@ class ScalaDebugServerFactory implements vscode.DebugAdapterDescriptorFactory {
session.configuration.testClass !== undefined ||
session.configuration.hostName !== undefined
) {
const debugSession = await vscode.commands.executeCommand<DebugSession>(
ServerCommands.DebugAdapterStart,
session.configuration
);

if (debugSession === undefined) {
return null;
if (session.configuration.noDebug) {
const args: DebugDiscoveryParams = {
path: undefined,
mainClass: session.configuration.mainClass,
buildTarget: session.configuration.buildTarget,
runType: RunType.Run,
args: session.configuration.args,
jvmOptions: session.configuration.jvmOptions,
env: session.configuration.env,
envFile: session.configuration.envFile,
};
await startDiscovery(session.configuration.noDebug, args);

// This is the only way not to have to run full fledged DAP server
return new vscode.DebugAdapterExecutable("echo", [
'"Running in the task window"',
]);
} else {
return debugServerFromUri(debugSession.uri);
const debugSession = await vscode.commands.executeCommand<DebugSession>(
ServerCommands.DebugAdapterStart,
session.configuration
);

if (debugSession === undefined) {
return null;
} else {
return debugServerFromUri(debugSession.uri);
}
}
}
return null;
Expand Down
12 changes: 12 additions & 0 deletions packages/metals-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
const canRetryWithJar =
javaHome && !coursier.endsWith(".jar") && !forceCoursierJar;

function retry(error: any): Promise<any> {

Check warning on line 239 in packages/metals-vscode/src/extension.ts

View workflow job for this annotation

GitHub Actions / Eslint

Unexpected any. Specify a different type

Check warning on line 239 in packages/metals-vscode/src/extension.ts

View workflow job for this annotation

GitHub Actions / Eslint

Unexpected any. Specify a different type
if (canRetryWithJar) {
outputChannel.appendLine(
"Trying again with the embedded coursier. This might take longer."
Expand Down Expand Up @@ -278,7 +278,7 @@
serverProperties,
javaConfig,
serverVersion
).catch((reason): Promise<any> => {

Check warning on line 281 in packages/metals-vscode/src/extension.ts

View workflow job for this annotation

GitHub Actions / Eslint

Unexpected any. Specify a different type
outputChannel.appendLine(
"Launching Metals failed with the following:"
);
Expand Down Expand Up @@ -842,6 +842,12 @@
const args: DebugDiscoveryParams = {
path: editor.document.uri.toString(true),
runType: RunType.RunOrTestFile,
buildTarget: undefined,
mainClass: undefined,
args: undefined,
jvmOptions: undefined,
env: undefined,
envFile: undefined,
};
scalaDebugger.startDiscovery(true, args).then((wasStarted) => {
if (!wasStarted) {
Expand All @@ -854,6 +860,12 @@
const args: DebugDiscoveryParams = {
path: editor.document.uri.toString(true),
runType: RunType.TestTarget,
buildTarget: undefined,
mainClass: undefined,
args: undefined,
jvmOptions: undefined,
env: undefined,
envFile: undefined,
};
scalaDebugger.startDiscovery(true, args).then((wasStarted) => {
if (!wasStarted) {
Expand Down
Loading