@@ -59,27 +59,12 @@ function! syntastic#preprocess#cppcheck(errors) abort " {{{2
59
59
return map (copy (a: errors ), ' substitute(v:val, '' \v^\[[^]]+\]\zs( -\> \[[^]]+\])+\ze:'' , "", "")' )
60
60
endfunction " }}}2
61
61
62
- " @vimlint(EVL102, 1, l:true)
63
- " @vimlint(EVL102, 1, l:false)
64
- " @vimlint(EVL102, 1, l:null)
65
62
function ! syntastic#preprocess#flow (errors) abort " {{{2
66
- " JSON artifacts
67
- let true = 1
68
- let false = 0
69
- let null = ' '
70
-
71
63
let idx = 0
72
- while idx < len (a: errors ) && a: errors [idx][0 ] != ' {'
64
+ while idx < len (a: errors ) && a: errors [idx][0 ] !=# ' {'
73
65
let idx += 1
74
66
endwhile
75
-
76
- " A hat tip to Marc Weber for this trick
77
- " http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
78
- try
79
- let errs = eval (join (a: errors [idx :], ' ' ))
80
- catch
81
- let errs = {}
82
- endtry
67
+ let errs = s: _decode_JSON (join (a: errors [idx :], ' ' ))
83
68
84
69
let out = []
85
70
if type (errs) == type ({}) && has_key (errs, ' errors' ) && type (errs[' errors' ]) == type ([])
@@ -108,25 +93,22 @@ function! syntastic#preprocess#flow(errors) abort " {{{2
108
93
109
94
call add (out, msg)
110
95
catch /\m^Vim\%((\a\+)\)\=:E716/
111
- call syntastic#log#warn (' checker javascript/flow: unknown error format' )
96
+ call syntastic#log#warn (' checker javascript/flow: unrecognized error format' )
112
97
let out = []
113
98
break
114
99
endtry
115
100
else
116
- call syntastic#log#warn (' checker javascript/flow: unknown error format' )
101
+ call syntastic#log#warn (' checker javascript/flow: unrecognized error format' )
117
102
let out = []
118
103
break
119
104
endif
120
105
endfor
121
106
else
122
- call syntastic#log#warn (' checker javascript/flow: unknown error format' )
107
+ call syntastic#log#warn (' checker javascript/flow: unrecognized error format' )
123
108
endif
124
109
125
110
return out
126
111
endfunction " }}}2
127
- " @vimlint(EVL102, 0, l:true)
128
- " @vimlint(EVL102, 0, l:false)
129
- " @vimlint(EVL102, 0, l:null)
130
112
131
113
function ! syntastic#preprocess#iconv (errors) abort " {{{2
132
114
return
@@ -152,22 +134,8 @@ function! syntastic#preprocess#perl(errors) abort " {{{2
152
134
return syntastic#util#unique (out)
153
135
endfunction " }}}2
154
136
155
- " @vimlint(EVL102, 1, l:true)
156
- " @vimlint(EVL102, 1, l:false)
157
- " @vimlint(EVL102, 1, l:null)
158
137
function ! syntastic#preprocess#prospector (errors) abort " {{{2
159
- " JSON artifacts
160
- let true = 1
161
- let false = 0
162
- let null = ' '
163
-
164
- " A hat tip to Marc Weber for this trick
165
- " http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
166
- try
167
- let errs = eval (join (a: errors , ' ' ))
168
- catch
169
- let errs = {}
170
- endtry
138
+ let errs = s: _decode_JSON (join (a: errors , ' ' ))
171
139
172
140
let out = []
173
141
if type (errs) == type ({}) && has_key (errs, ' messages' )
@@ -189,26 +157,23 @@ function! syntastic#preprocess#prospector(errors) abort " {{{2
189
157
190
158
call add (out, msg)
191
159
catch /\m^Vim\%((\a\+)\)\=:E716/
192
- call syntastic#log#warn (' checker python/prospector: unknown error format' )
160
+ call syntastic#log#warn (' checker python/prospector: unrecognized error format' )
193
161
let out = []
194
162
break
195
163
endtry
196
164
else
197
- call syntastic#log#warn (' checker python/prospector: unknown error format' )
165
+ call syntastic#log#warn (' checker python/prospector: unrecognized error format' )
198
166
let out = []
199
167
break
200
168
endif
201
169
endfor
202
170
else
203
- call syntastic#log#warn (' checker python/prospector: unknown error format' )
171
+ call syntastic#log#warn (' checker python/prospector: unrecognized error format' )
204
172
endif
205
173
endif
206
174
207
175
return out
208
176
endfunction " }}}2
209
- " @vimlint(EVL102, 0, l:true)
210
- " @vimlint(EVL102, 0, l:false)
211
- " @vimlint(EVL102, 0, l:null)
212
177
213
178
function ! syntastic#preprocess#rparse (errors) abort " {{{2
214
179
let errlist = copy (a: errors )
@@ -268,22 +233,8 @@ function! syntastic#preprocess#validator(errors) abort " {{{2
268
233
return out
269
234
endfunction " }}}2
270
235
271
- " @vimlint(EVL102, 1, l:true)
272
- " @vimlint(EVL102, 1, l:false)
273
- " @vimlint(EVL102, 1, l:null)
274
236
function ! syntastic#preprocess#vint (errors) abort " {{{2
275
- " JSON artifacts
276
- let true = 1
277
- let false = 0
278
- let null = ' '
279
-
280
- " A hat tip to Marc Weber for this trick
281
- " http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
282
- try
283
- let errs = eval (join (a: errors , ' ' ))
284
- catch
285
- let errs = []
286
- endtry
237
+ let errs = s: _decode_JSON (join (a: errors , ' ' ))
287
238
288
239
let out = []
289
240
if type (errs) == type ([])
@@ -300,22 +251,52 @@ function! syntastic#preprocess#vint(errors) abort " {{{2
300
251
301
252
call add (out, msg)
302
253
catch /\m^Vim\%((\a\+)\)\=:E716/
303
- call syntastic#log#warn (' checker vim/vint: unknown error format' )
254
+ call syntastic#log#warn (' checker vim/vint: unrecognized error format' )
304
255
let out = []
305
256
break
306
257
endtry
307
258
else
308
- call syntastic#log#warn (' checker vim/vint: unknown error format' )
259
+ call syntastic#log#warn (' checker vim/vint: unrecognized error format' )
309
260
let out = []
310
261
break
311
262
endif
312
263
endfor
313
264
else
314
- call syntastic#log#warn (' checker vim/vint: unknown error format' )
265
+ call syntastic#log#warn (' checker vim/vint: unrecognized error format' )
315
266
endif
316
267
317
268
return out
318
269
endfunction " }}}2
270
+
271
+ " }}}1
272
+
273
+ " Private functions {{{1
274
+
275
+ " @vimlint(EVL102, 1, l:true)
276
+ " @vimlint(EVL102, 1, l:false)
277
+ " @vimlint(EVL102, 1, l:null)
278
+ function ! s: _decode_JSON (json) abort " {{{2
279
+ " The following is inspired by https://github.com/MarcWeber/vim-addon-manager and
280
+ " http://stackoverflow.com/questions/17751186/iterating-over-a-string-in-vimscript-or-parse-a-json-file/19105763#19105763
281
+ " A hat tip to Marc Weber for this trick
282
+ if substitute (a: json , ' \v\"%(\\.|[^"\\])*\"|true|false|null|[+-]?\d+%(\.\d+%([Ee][+-]?\d+)?)?' , ' ' , ' g' ) !~# " [^,:{}[\\ ] \t ]"
283
+ " JSON artifacts
284
+ let true = 1
285
+ let false = 0
286
+ let null = ' '
287
+
288
+ try
289
+ let object = eval (a: json )
290
+ catch
291
+ " malformed JSON
292
+ let object = ' '
293
+ endtry
294
+ else
295
+ let object = ' '
296
+ endif
297
+
298
+ return object
299
+ endfunction " }}}2
319
300
" @vimlint(EVL102, 0, l:true)
320
301
" @vimlint(EVL102, 0, l:false)
321
302
" @vimlint(EVL102, 0, l:null)
0 commit comments