-
Notifications
You must be signed in to change notification settings - Fork 703
Add Java debugger support #12076
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
base: main
Are you sure you want to change the base?
Add Java debugger support #12076
Changes from 1 commit
e55e8be
09a787e
13c00b5
68668ab
8a9369f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ export function isPythonInstalled() { | |
return isExtensionInstalled("ms-python.python"); | ||
} | ||
|
||
export function isJavaInstalled() { | ||
return isExtensionInstalled("vscjava.vscode-java-pack"); | ||
} | ||
|
||
export function getSupportedCapabilities(): string[] { | ||
const capabilities = ['prompting', 'baseline.v1', 'secret-prompts.v1']; | ||
|
||
|
@@ -37,6 +41,11 @@ export function getSupportedCapabilities(): string[] { | |
capabilities.push("ms-python.python"); | ||
} | ||
|
||
if (isJavaInstalled()) { | ||
capabilities.push("java"); | ||
capabilities.push("vscjava.vscode-java-pack"); | ||
} | ||
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you adjust detection to include the Debugger for Java extension, reflect that here by pushing the actual installed extension ID (prefer the debugger extension if present). This keeps capabilities aligned with what's installed. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
|
||
return capabilities; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,16 @@ export function isPythonLaunchConfiguration(obj: any): obj is PythonLaunchConfig | |
return obj && obj.type === 'python'; | ||
} | ||
|
||
export interface JavaLaunchConfiguration extends ExecutableLaunchConfiguration { | ||
type: "java"; | ||
main_class_path?: string; | ||
project_path?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write a comment to explain why both are included |
||
} | ||
|
||
export function isJavaLaunchConfiguration(obj: any): obj is JavaLaunchConfiguration { | ||
return obj && obj.type === 'java'; | ||
} | ||
|
||
export interface EnvVar { | ||
name: string; | ||
value: string; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { isJavaLaunchConfiguration } from "../../dcp/types"; | ||
import { invalidLaunchConfiguration } from "../../loc/strings"; | ||
import { ResourceDebuggerExtension } from "../debuggerExtensions"; | ||
|
||
export const javaDebuggerExtension: ResourceDebuggerExtension = { | ||
resourceType: 'java', | ||
debugAdapter: 'java', | ||
extensionId: 'vscjava.vscode-java-pack', | ||
displayName: 'Java', | ||
getProjectFile: (launchConfig) => { | ||
if (isJavaLaunchConfiguration(launchConfig) && launchConfig.project_path) { | ||
return launchConfig.project_path; | ||
marshalhayes marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error includes the full serialized launch configuration, which may leak sensitive values (e.g., env vars) into logs. Prefer a concise, non-sensitive message (e.g., include only the type and which required fields are missing) instead of JSON-stringifying the entire object. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detecting capability via the extension pack ID may miss users who installed only the Debugger for Java extension. Consider checking for either the debugger extension or the pack: return isExtensionInstalled('vscjava.vscode-java-debug') || isExtensionInstalled('vscjava.vscode-java-pack');
Copilot uses AI. Check for mistakes.