@@ -30,7 +30,7 @@ export enum EmptyReason {
3030
3131export interface INodeImportClass {
3232 uri : string ;
33- value : string ; // Changed from 'class' to 'className' to match Java code
33+ value : string ;
3434}
3535
3636export interface IImportClassContentResult {
@@ -175,7 +175,7 @@ export namespace CopilotHelper {
175175 * @returns Result object containing project dependencies and error information
176176 */
177177 export async function resolveProjectDependenciesWithReason (
178- projectUri : Uri ,
178+ fileUri : Uri ,
179179 cancellationToken ?: CancellationToken
180180 ) : Promise < IProjectDependenciesResult > {
181181 if ( cancellationToken ?. isCancellationRequested ) {
@@ -187,7 +187,7 @@ export namespace CopilotHelper {
187187 }
188188
189189 try {
190- const normalizedUri = decodeURIComponent ( Uri . file ( projectUri . fsPath ) . toString ( ) ) ;
190+ const normalizedUri = decodeURIComponent ( Uri . file ( fileUri . fsPath ) . toString ( ) ) ;
191191 const commandPromise = commands . executeCommand (
192192 Commands . EXECUTE_WORKSPACE_COMMAND ,
193193 Commands . JAVA_PROJECT_GET_DEPENDENCIES ,
@@ -267,20 +267,24 @@ export namespace CopilotHelper {
267267 * @returns Array of context items for project dependencies, or empty array if no workspace folders
268268 */
269269 export async function resolveAndConvertProjectDependencies (
270- workspaceFolders : readonly { uri : Uri } [ ] | undefined ,
270+ activeEditor : { document : { uri : Uri ; languageId : string } } | undefined ,
271271 copilotCancel : CancellationToken ,
272272 checkCancellation : ( token : CancellationToken ) => void
273273 ) : Promise < { name : string ; value : string ; importance : number } [ ] > {
274274 const items : any [ ] = [ ] ;
275275 // Check if workspace folders exist
276- if ( ! workspaceFolders || workspaceFolders . length === 0 ) {
277- sendContextOperationTelemetry ( "resolveProjectDependencies " , "ContextEmpty" , sendInfo , EmptyReason . NoWorkspace ) ;
276+ if ( ! activeEditor ) {
277+ sendContextOperationTelemetry ( "resolveLocalImports " , "ContextEmpty" , sendInfo , EmptyReason . NoActiveEditor ) ;
278278 return items ;
279279 }
280- const projectUri = workspaceFolders [ 0 ] ;
280+ if ( activeEditor . document . languageId !== 'java' ) {
281+ sendContextOperationTelemetry ( "resolveLocalImports" , "ContextEmpty" , sendInfo , EmptyReason . NotJavaFile ) ;
282+ return items ;
283+ }
284+ const documentUri = activeEditor . document . uri ;
281285
282286 // Resolve project dependencies
283- const projectDependenciesResult = await resolveProjectDependenciesWithReason ( projectUri . uri , copilotCancel ) ;
287+ const projectDependenciesResult = await resolveProjectDependenciesWithReason ( documentUri , copilotCancel ) ;
284288
285289 // Check for cancellation after dependency resolution
286290 checkCancellation ( copilotCancel ) ;
0 commit comments