@@ -3,7 +3,7 @@ import Copilot from "../Copilot";
33import { getClassesContainedInRange , getInnermostClassContainsRange , getIntersectionMethodsOfRange , getProjectJavaVersion , getUnionRange , logger } from "../utils" ;
44import { Inspection } from "./Inspection" ;
55import path from "path" ;
6- import { TextDocument , SymbolKind , ProgressLocation , commands , Position , Range , Selection , window , LanguageModelChatMessage , LanguageModelChatMessageRole } from "vscode" ;
6+ import { TextDocument , SymbolKind , ProgressLocation , commands , Position , Range , Selection , window , LanguageModelChatMessage } from "vscode" ;
77import { COMMAND_FIX_INSPECTION } from "./commands" ;
88import InspectionCache from "./InspectionCache" ;
99import { SymbolNode } from "./SymbolNode" ;
@@ -162,21 +162,21 @@ export default class InspectionCopilot extends Copilot {
162162 const symbolKind = SymbolKind [ symbols [ 0 ] . kind ] . toLowerCase ( ) ;
163163 const inspections = await window . withProgress ( {
164164 location : ProgressLocation . Notification ,
165- title : `Inspecting ${ symbolKind } ${ symbolName } ... of \ "${ path . basename ( document . fileName ) } \ "` ,
165+ title : `Inspecting ${ symbolKind } ${ symbolName } ... of "${ path . basename ( document . fileName ) } "` ,
166166 cancellable : false
167167 } , ( _progress ) => {
168168 return this . doInspectRange ( document , expandedRange ) ;
169169 } ) ;
170170
171171 // show message based on the number of inspections
172172 if ( inspections . length < 1 ) {
173- void window . showInformationMessage ( `Inspected ${ symbolKind } ${ symbolName } ... of \ "${ path . basename ( document . fileName ) } \ " and got 0 suggestions.` ) ;
173+ void window . showInformationMessage ( `Inspected ${ symbolKind } ${ symbolName } ... of "${ path . basename ( document . fileName ) } " and got 0 suggestions.` ) ;
174174 } else if ( inspections . length == 1 ) {
175175 // apply the only suggestion automatically
176176 void commands . executeCommand ( COMMAND_FIX_INSPECTION , inspections [ 0 ] . problem , inspections [ 0 ] . solution , 'auto' ) ;
177177 } else {
178178 // show message to go to the first suggestion
179- void window . showInformationMessage ( `Inspected ${ symbolKind } ${ symbolName } ... of \ "${ path . basename ( document . fileName ) } \ " and got ${ inspections . length } suggestions.` , "Go to" ) . then ( selection => {
179+ void window . showInformationMessage ( `Inspected ${ symbolKind } ${ symbolName } ... of "${ path . basename ( document . fileName ) } " and got ${ inspections . length } suggestions.` , "Go to" ) . then ( selection => {
180180 selection === "Go to" && void Inspection . revealFirstLineOfInspection ( inspections [ 0 ] ) ;
181181 } ) ;
182182 }
@@ -220,10 +220,8 @@ export default class InspectionCopilot extends Copilot {
220220 const adjustedRange = new Range ( new Position ( range . start . line , 0 ) , new Position ( range . end . line , document . lineAt ( range . end . line ) . text . length ) ) ;
221221 const content : string = document . getText ( adjustedRange ) ;
222222 const startLine = range . start . line ;
223- const javaVersion = await getProjectJavaVersion ( document ) ;
224- const inspections = await this . inspectCode ( content , {
225- javaVersion
226- } ) ;
223+ const projectContext = await this . collectProjectContext ( document ) ;
224+ const inspections = await this . inspectCode ( content , projectContext ) ;
227225 inspections . forEach ( s => {
228226 s . document = document ;
229227 // real line index to the start of the document
@@ -356,6 +354,11 @@ export default class InspectionCopilot extends Copilot {
356354 }
357355 return codeLines ;
358356 }
357+
358+ async collectProjectContext ( document : TextDocument ) : Promise < ProjectContext > {
359+ const javaVersion = await getProjectJavaVersion ( document ) ;
360+ return { javaVersion } ;
361+ }
359362}
360363
361364export interface ProjectContext {
0 commit comments