@@ -82,18 +82,20 @@ export async function listScanResults(
82
82
// Do not use .. in between because there could be multiple project paths in the same parent dir.
83
83
const filePath = path . join ( projectPath , key . split ( '/' ) . slice ( 1 ) . join ( '/' ) )
84
84
if ( existsSync ( filePath ) && statSync ( filePath ) . isFile ( ) ) {
85
+ const document = await vscode . workspace . openTextDocument ( filePath )
85
86
const aggregatedCodeScanIssue : AggregatedCodeScanIssue = {
86
87
filePath : filePath ,
87
- issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , editor , jobId , scope ) ) ,
88
+ issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , jobId , scope , document ) ) ,
88
89
}
89
90
aggregatedCodeScanIssueList . push ( aggregatedCodeScanIssue )
90
91
}
91
92
}
92
93
const maybeAbsolutePath = `/${ key } `
93
94
if ( existsSync ( maybeAbsolutePath ) && statSync ( maybeAbsolutePath ) . isFile ( ) ) {
95
+ const document = await vscode . workspace . openTextDocument ( maybeAbsolutePath )
94
96
const aggregatedCodeScanIssue : AggregatedCodeScanIssue = {
95
97
filePath : maybeAbsolutePath ,
96
- issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , editor , jobId , scope ) ) ,
98
+ issues : issues . map ( ( issue ) => mapRawToCodeScanIssue ( issue , jobId , scope , document ) ) ,
97
99
}
98
100
aggregatedCodeScanIssueList . push ( aggregatedCodeScanIssue )
99
101
}
@@ -103,18 +105,20 @@ export async function listScanResults(
103
105
104
106
function mapRawToCodeScanIssue (
105
107
issue : RawCodeScanIssue ,
106
- editor : vscode . TextEditor | undefined ,
107
108
jobId : string ,
108
- scope : CodeWhispererConstants . CodeAnalysisScope
109
+ scope : CodeWhispererConstants . CodeAnalysisScope ,
110
+ document : vscode . TextDocument
109
111
) : CodeScanIssue {
110
112
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
118
122
return {
119
123
startLine : issue . startLine - 1 >= 0 ? issue . startLine - 1 : 0 ,
120
124
endLine : issue . endLine ,
0 commit comments