Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions extension/src/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export function isPythonInstalled() {
return isExtensionInstalled("ms-python.python");
}

export function isJavaInstalled() {
return isExtensionInstalled("vscjava.vscode-java-pack");
}
Comment on lines +22 to +24
Copy link

Copilot AI Oct 17, 2025

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.


export function getSupportedCapabilities(): string[] {
const capabilities = ['prompting', 'baseline.v1', 'secret-prompts.v1'];

Expand All @@ -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
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The 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.


return capabilities;
}

Expand Down
10 changes: 10 additions & 0 deletions extension/src/dcp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand Down
7 changes: 6 additions & 1 deletion extension/src/debugger/debuggerExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { debugProject } from "../loc/strings";
import { mergeEnvs } from "../utils/environment";
import { extensionLogOutputChannel } from "../utils/logging";
import { projectDebuggerExtension } from "./languages/dotnet";
import { isCsharpInstalled, isPythonInstalled } from "../capabilities";
import { isCsharpInstalled, isJavaInstalled, isPythonInstalled } from "../capabilities";
import { pythonDebuggerExtension } from "./languages/python";
import { javaDebuggerExtension } from "./languages/java";

// Represents a resource-specific debugger extension for when the default session configuration is not sufficient to launch the resource.
export interface ResourceDebuggerExtension {
Expand Down Expand Up @@ -70,6 +71,10 @@ export function getResourceDebuggerExtensions(): ResourceDebuggerExtension[] {
extensions.push(pythonDebuggerExtension);
}

if (isJavaInstalled()) {
extensions.push(javaDebuggerExtension);
}

return extensions;
}

17 changes: 17 additions & 0 deletions extension/src/debugger/languages/java.ts
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;
}

throw new Error(invalidLaunchConfiguration(JSON.stringify(launchConfig)));
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The 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.

}
};
Loading