@@ -82,18 +82,20 @@ export async function listScanResults(
8282 // Do not use .. in between because there could be multiple project paths in the same parent dir.
8383 const filePath = path . join ( projectPath , key . split ( '/' ) . slice ( 1 ) . join ( '/' ) )
8484 if ( existsSync ( filePath ) && statSync ( filePath ) . isFile ( ) ) {
85+ const document = await vscode . workspace . openTextDocument ( filePath )
8586 const aggregatedCodeScanIssue : AggregatedCodeScanIssue = {
8687 filePath : filePath ,
87- issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , editor , jobId , scope ) ) ,
88+ issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , jobId , scope , document ) ) ,
8889 }
8990 aggregatedCodeScanIssueList . push ( aggregatedCodeScanIssue )
9091 }
9192 }
9293 const maybeAbsolutePath = `/${ key } `
9394 if ( existsSync ( maybeAbsolutePath ) && statSync ( maybeAbsolutePath ) . isFile ( ) ) {
95+ const document = await vscode . workspace . openTextDocument ( maybeAbsolutePath )
9496 const aggregatedCodeScanIssue : AggregatedCodeScanIssue = {
9597 filePath : maybeAbsolutePath ,
96- issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , editor , jobId , scope ) ) ,
98+ issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , jobId , scope , document ) ) ,
9799 }
98100 aggregatedCodeScanIssueList . push ( aggregatedCodeScanIssue )
99101 }
@@ -103,18 +105,20 @@ export async function listScanResults(
103105
104106function mapRawToCodeScanIssue (
105107 issue : RawCodeScanIssue ,
106- editor : vscode . TextEditor | undefined ,
107108 jobId : string ,
108- scope : CodeWhispererConstants . CodeAnalysisScope
109+ scope : CodeWhispererConstants . CodeAnalysisScope ,
110+ document : vscode . TextDocument
109111) : CodeScanIssue {
110112 const isIssueTitleIgnored = CodeWhispererSettings . instance . getIgnoredSecurityIssues ( ) . includes ( issue . title )
111- const isSingleIssueIgnored =
112- editor &&
113- detectCommentAboveLine ( editor . document , issue . startLine - 1 , CodeWhispererConstants . amazonqIgnoreNextLine )
114- const language = editor
115- ? runtimeLanguageContext . getLanguageContext ( editor . document . languageId , path . extname ( editor . document . fileName ) )
116- . language
117- : 'plaintext'
113+ const isSingleIssueIgnored = detectCommentAboveLine (
114+ document ,
115+ issue . startLine - 1 ,
116+ CodeWhispererConstants . amazonqIgnoreNextLine
117+ )
118+ const language = runtimeLanguageContext . getLanguageContext (
119+ document . languageId ,
120+ path . extname ( document . fileName )
121+ ) . language
118122 return {
119123 startLine : issue . startLine - 1 >= 0 ? issue . startLine - 1 : 0 ,
120124 endLine : issue . endLine ,
0 commit comments