@@ -6,7 +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
+ import path from 'path' ;
10
10
11
11
const failedResponseReturn : SubmitRepresentationResponse = { jobId : '' , status : 'failed' } ;
12
12
@@ -47,7 +47,7 @@ export const handleDocumentAnalyze = async (
47
47
getExtensionEventEmitter ( ) . fire ( {
48
48
type : 'CURRENT_PROJECT' ,
49
49
data : {
50
- name : currentWorkSpaceFolder
50
+ name : currentWorkSpaceFolder ,
51
51
} ,
52
52
} ) ;
53
53
@@ -58,27 +58,27 @@ export const handleDocumentAnalyze = async (
58
58
jobId !== undefined
59
59
? await submitService . getJobStatus ( sessionToken , jobId )
60
60
: await submitService . submitTextFile (
61
- metaDataDocument . relativePath ,
62
- metaDataDocument . fileContent ,
63
- metaDataDocument . filePath ,
64
- sessionToken ,
65
- ) ;
61
+ metaDataDocument . relativePath ,
62
+ metaDataDocument . fileContent ,
63
+ metaDataDocument . filePath ,
64
+ sessionToken ,
65
+ ) ;
66
66
67
67
const verifiedResponse = verifyResponseOfSubmit ( response ) ;
68
68
if ( ! verifiedResponse || ! verifiedResponse . results ) {
69
69
if ( ! suppressRateLimitErrors ) {
70
- getExtensionEventEmitter ( ) . fire ( {
71
- type : 'Analysis_Error' ,
72
- data : '' ,
73
- } ) ;
74
- getExtensionEventEmitter ( ) . fire ( {
75
- type : 'CURRENT_PROJECT' ,
76
- data : {
77
- name : currentWorkSpaceFolder
78
- } ,
79
- } ) ;
80
70
vscode . window . showErrorMessage ( CONSTANTS . analyzeCommandTimeoutMessage ) ;
81
71
}
72
+ getExtensionEventEmitter ( ) . fire ( {
73
+ type : 'Analysis_Error' ,
74
+ data : '' ,
75
+ } ) ;
76
+ getExtensionEventEmitter ( ) . fire ( {
77
+ type : 'CURRENT_PROJECT' ,
78
+ data : {
79
+ name : currentWorkSpaceFolder ,
80
+ } ,
81
+ } ) ;
82
82
83
83
return failedResponseReturn ;
84
84
} else if ( verifiedResponse . status === 'failed' ) {
@@ -89,7 +89,7 @@ export const handleDocumentAnalyze = async (
89
89
getExtensionEventEmitter ( ) . fire ( {
90
90
type : 'CURRENT_PROJECT' ,
91
91
data : {
92
- name : currentWorkSpaceFolder
92
+ name : currentWorkSpaceFolder ,
93
93
} ,
94
94
} ) ;
95
95
vscode . window . showErrorMessage ( CONSTANTS . analyzeCommandErrorMessage ) ;
@@ -111,7 +111,7 @@ export const handleDocumentAnalyze = async (
111
111
getExtensionEventEmitter ( ) . fire ( {
112
112
type : 'CURRENT_PROJECT' ,
113
113
data : {
114
- name : currentWorkSpaceFolder
114
+ name : currentWorkSpaceFolder ,
115
115
} ,
116
116
} ) ;
117
117
vscode . window . showErrorMessage ( CONSTANTS . analyzeCommandErrorMessage ) ;
@@ -121,14 +121,30 @@ export const handleDocumentAnalyze = async (
121
121
122
122
// convert problem paths to absolute path and normalize them
123
123
const workspaceFolderPath = vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath ;
124
- if ( ! workspaceFolderPath ) { return failedResponseReturn ; }
124
+ if ( ! workspaceFolderPath ) {
125
+ getExtensionEventEmitter ( ) . fire ( {
126
+ type : 'Analysis_Error' ,
127
+ data : '' ,
128
+ } ) ;
129
+ getExtensionEventEmitter ( ) . fire ( {
130
+ type : 'CURRENT_PROJECT' ,
131
+ data : {
132
+ name : currentWorkSpaceFolder ,
133
+ } ,
134
+ } ) ;
135
+
136
+ return failedResponseReturn ;
137
+ }
125
138
verifiedResponse . results . forEach ( result => {
126
139
result . path = path . join ( workspaceFolderPath , result . path ) ;
127
140
} ) ;
128
141
129
142
let results : AnalyzeState = { } ;
130
143
const analyzeStateValue = new Analyze ( context ) . get ( ) ?. value ;
131
- _debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: analyzeStateValue: ' + JSON . stringify ( analyzeStateValue ) ) ;
144
+ _debug ?. appendLine (
145
+ 'AnalyzeDocument.ts: handleDocumentAnalyze: analyzeStateValue: ' +
146
+ JSON . stringify ( analyzeStateValue ) ,
147
+ ) ;
132
148
133
149
if ( analyzeStateValue ) {
134
150
const responseProblemsFilePaths = verifiedResponse . results . map ( problem => {
@@ -163,10 +179,7 @@ export const handleDocumentAnalyze = async (
163
179
currFile . editor . document . lineAt ( endLine - 1 ) . text . length ,
164
180
) ;
165
181
166
- const text = currFile . editor . document
167
- . getText ( range )
168
- . replace ( '\n' , '' )
169
- . replace ( '\t' , '' ) ;
182
+ const text = currFile . editor . document . getText ( range ) . replace ( '\n' , '' ) . replace ( '\t' , '' ) ;
170
183
if ( text . length === 0 || text === '' || text === ' ' ) {
171
184
return false ;
172
185
}
@@ -190,7 +203,9 @@ export const handleDocumentAnalyze = async (
190
203
191
204
_debug ?. appendLine ( 'AnalyzeDocument.ts: Document File path' + currFile . absPath ) ;
192
205
const problems = Util . getCurrentEditorProblems ( results , currFile . absPath ) ;
193
- _debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: problems: ' + JSON . stringify ( problems ) ) ;
206
+ _debug ?. appendLine (
207
+ 'AnalyzeDocument.ts: handleDocumentAnalyze: problems: ' + JSON . stringify ( problems ) ,
208
+ ) ;
194
209
if ( ! problems ) {
195
210
getExtensionEventEmitter ( ) . fire ( {
196
211
type : 'Analysis_Error' ,
@@ -199,7 +214,7 @@ export const handleDocumentAnalyze = async (
199
214
getExtensionEventEmitter ( ) . fire ( {
200
215
type : 'CURRENT_PROJECT' ,
201
216
data : {
202
- name : currentWorkSpaceFolder
217
+ name : currentWorkSpaceFolder ,
203
218
} ,
204
219
} ) ;
205
220
vscode . window . showErrorMessage ( CONSTANTS . analyzeCommandErrorMessage ) ;
@@ -210,7 +225,9 @@ export const handleDocumentAnalyze = async (
210
225
const paths = problems . map ( item => item . path ) ;
211
226
212
227
const isUserOnValidEditor = paths . includes ( currFile . absPath ) ;
213
- _debug ?. appendLine ( 'AnalyzeDocument.ts: handleDocumentAnalyze: isUserOnValidEditor: ' + isUserOnValidEditor ) ;
228
+ _debug ?. appendLine (
229
+ 'AnalyzeDocument.ts: handleDocumentAnalyze: isUserOnValidEditor: ' + isUserOnValidEditor ,
230
+ ) ;
214
231
if ( isUserOnValidEditor ) {
215
232
Util . decorateCurrentEditorWithHighlights ( problems , currFile . editor , _debug ) ;
216
233
}
@@ -226,14 +243,13 @@ export const handleDocumentAnalyze = async (
226
243
getExtensionEventEmitter ( ) . fire ( {
227
244
type : 'CURRENT_PROJECT' ,
228
245
data : {
229
- name : currentWorkSpaceFolder
246
+ name : currentWorkSpaceFolder ,
230
247
} ,
231
248
} ) ;
232
249
233
- return verifiedResponse
250
+ return verifiedResponse ;
234
251
}
235
252
236
-
237
253
getExtensionEventEmitter ( ) . fire ( {
238
254
type : 'Analysis_Completed' ,
239
255
data : { shouldResetRecomendation : true , shouldMoveToAnalyzePage : true , ...results } ,
@@ -242,7 +258,7 @@ export const handleDocumentAnalyze = async (
242
258
getExtensionEventEmitter ( ) . fire ( {
243
259
type : 'CURRENT_PROJECT' ,
244
260
data : {
245
- name : currentWorkSpaceFolder
261
+ name : currentWorkSpaceFolder ,
246
262
} ,
247
263
} ) ;
248
264
0 commit comments