@@ -6,6 +6,7 @@ import { AnalyzeState, Analyze, AnalyseMetaData } from '../state';
6
6
import Util from '../utils' ;
7
7
import CONSTANTS from '../constants' ;
8
8
import { getExtensionEventEmitter } from '../events' ;
9
+ import path from 'path'
9
10
10
11
const failedResponseReturn : SubmitRepresentationResponse = { jobId : '' , status : 'failed' } ;
11
12
@@ -101,8 +102,8 @@ export const handleDocumentAnalyze = async (
101
102
return verifiedResponse ;
102
103
}
103
104
104
- const documentMetaData = Util . getFileNameFromCurrentEditor ( ) ;
105
- if ( ! documentMetaData ) {
105
+ const currFile = Util . getCurrentFile ( ) ;
106
+ if ( ! currFile ) {
106
107
getExtensionEventEmitter ( ) . fire ( {
107
108
type : 'Analysis_Error' ,
108
109
data : '' ,
@@ -118,20 +119,26 @@ export const handleDocumentAnalyze = async (
118
119
return failedResponseReturn ;
119
120
}
120
121
122
+ // convert problem paths to absolute path and normalize them
123
+ const workspaceFolderPath = vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath ;
124
+ if ( ! workspaceFolderPath ) { return failedResponseReturn ; }
125
+ verifiedResponse . results . forEach ( result => {
126
+ result . path = path . join ( workspaceFolderPath , result . path ) ;
127
+ } ) ;
128
+
121
129
let results : AnalyzeState = { } ;
122
130
const analyzeStateValue = new Analyze ( context ) . get ( ) ?. value ;
123
131
_debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: analyzeStateValue: ' + JSON . stringify ( analyzeStateValue ) ) ;
124
132
125
133
if ( analyzeStateValue ) {
126
- const aggregatedProblemsFilePaths = verifiedResponse . results . map ( problem => {
134
+ const responseProblemsFilePaths = verifiedResponse . results . map ( problem => {
127
135
return problem . path ;
128
136
} ) ;
129
137
130
138
const buggerAnalyzeStateValue : AnalyzeState = { } ;
131
139
132
- Object . keys ( analyzeStateValue ) . forEach ( key => {
133
- const problem = analyzeStateValue [ key ] ;
134
- if ( ! aggregatedProblemsFilePaths . includes ( problem . path ) ) {
140
+ Object . entries ( analyzeStateValue ) . forEach ( ( [ key , problem ] ) => {
141
+ if ( ! responseProblemsFilePaths . includes ( problem . path ) ) {
135
142
buggerAnalyzeStateValue [ key ] = { ...problem } ;
136
143
}
137
144
} ) ;
@@ -153,10 +160,10 @@ export const handleDocumentAnalyze = async (
153
160
startLine - 1 ,
154
161
0 ,
155
162
endLine - 1 ,
156
- documentMetaData . editor . document . lineAt ( endLine - 1 ) . text . length ,
163
+ currFile . editor . document . lineAt ( endLine - 1 ) . text . length ,
157
164
) ;
158
165
159
- const text = documentMetaData . editor . document
166
+ const text = currFile . editor . document
160
167
. getText ( range )
161
168
. replace ( '\n' , '' )
162
169
. replace ( '\t' , '' ) ;
@@ -181,8 +188,8 @@ export const handleDocumentAnalyze = async (
181
188
results [ key ] = { ...analyzeMetaData } ;
182
189
} ) ;
183
190
184
- _debug ?. appendLine ( 'AnalyzeDocument.ts: Document File name ' + documentMetaData . fileName ) ;
185
- const problems = Util . getCurrentEditorProblems ( results , documentMetaData . fileName ) ;
191
+ _debug ?. appendLine ( 'AnalyzeDocument.ts: Document File path ' + currFile . absPath ) ;
192
+ const problems = Util . getCurrentEditorProblems ( results , currFile . absPath ) ;
186
193
_debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: problems: ' + JSON . stringify ( problems ) ) ;
187
194
if ( ! problems ) {
188
195
getExtensionEventEmitter ( ) . fire ( {
@@ -202,10 +209,10 @@ export const handleDocumentAnalyze = async (
202
209
203
210
const paths = problems . map ( item => item . path ) ;
204
211
205
- const isUserOnValidEditor = paths . includes ( documentMetaData . fileName ) ;
212
+ const isUserOnValidEditor = paths . includes ( currFile . absPath ) ;
206
213
_debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: isUserOnValidEditor: ' + isUserOnValidEditor ) ;
207
214
if ( isUserOnValidEditor ) {
208
- Util . decorateCurrentEditorWithHighlights ( problems , documentMetaData . editor , _debug ) ;
215
+ Util . decorateCurrentEditorWithHighlights ( problems , currFile . editor , _debug ) ;
209
216
}
210
217
211
218
await analyzeState . set ( results ) ;
0 commit comments