diff --git a/src/languageModelTool.ts b/src/languageModelTool.ts index 055103b..6587869 100644 --- a/src/languageModelTool.ts +++ b/src/languageModelTool.ts @@ -194,7 +194,33 @@ async function debugJavaApplication( } // Step 3: Construct and execute the debugjava command - const debugCommand = constructDebugCommand(input, projectType); + // + // For simple class names (no dot), resolve the fully-qualified class once + // here so we can reuse the result for both the command construction and + // the user-facing targetInfo message below. Previously these two paths + // each called findFullyQualifiedClassName independently, which: + // - duplicated the file system walk on the hot launch path (the FS walk + // is the actual user-visible slowdown — it stats every .java file + // under src/main/java up to MAX_FILE_SEARCH_DEPTH) + // - made the call sites harder to reason about, since detection + // ownership was split across constructDebugCommand and the targetInfo + // formatting block + // + // After this refactor, the caller owns detection and its telemetry, + // and constructDebugCommand accepts a pre-resolved name. + let detectedClassName: string | null = null; + if (!input.target.endsWith('.jar') + && !input.target.startsWith('-') + && !input.target.includes('.')) { + detectedClassName = findFullyQualifiedClassName(input.workspacePath, input.target, projectType); + recordLaunchInternal({ + name: 'classNameDetection', + projectType, + detected: !!detectedClassName, + }); + } + + const debugCommand = constructDebugCommand(input, projectType, detectedClassName); // Validate that we can construct a valid command if (!debugCommand || debugCommand === 'debugjava') { @@ -223,8 +249,9 @@ async function debugJavaApplication( } else if (input.target.includes('.')) { targetInfo = input.target; } else { - // Simple class name - check if we successfully detected the full name - const detectedClassName = findFullyQualifiedClassName(input.workspacePath, input.target, projectType); + // Simple class name - reuse the detection result from Step 3 above + // (do NOT call findFullyQualifiedClassName again — it walks the FS + // and the result is already in `detectedClassName`). if (detectedClassName) { targetInfo = `${detectedClassName} (detected from ${input.target})`; } else { @@ -591,10 +618,17 @@ async function ensureVSCodeCompilation(workspaceUri: vscode.Uri): Promise