Cleanup related to the HighlightRegex() functions.

This commit is contained in:
LCD 47 2013-11-07 18:24:10 +02:00
parent b7ba0c0899
commit 1a5bf0118a
2 changed files with 13 additions and 17 deletions

View File

@ -48,11 +48,7 @@ function! g:SyntasticChecker.getLocList()
endfunction
function! g:SyntasticChecker.getHighlightRegexFor(error)
if empty(self._highlightRegexFunc)
return []
endif
return self._highlightRegexFunc(error)
return empty(self._highlightRegexFunc) ? [] : self._highlightRegexFunc(a:error)
endfunction
function! g:SyntasticChecker.isAvailable()
@ -61,14 +57,14 @@ endfunction
" Private methods {{{1
function! g:SyntasticChecker._populateHighlightRegexes(list)
let list = a:list
function! g:SyntasticChecker._populateHighlightRegexes(errors)
let list = a:errors
if !empty(self._highlightRegexFunc)
for i in range(0, len(list)-1)
if list[i]['valid']
let term = self._highlightRegexFunc(list[i])
for e in list
if e['valid']
let term = self._highlightRegexFunc(e)
if len(term) > 0
let list[i]['hl'] = term
let e['hl'] = term
endif
endif
endfor

View File

@ -23,12 +23,12 @@ function! SyntaxCheckers_javascript_jslint_IsAvailable()
return executable('jslint')
endfunction
function! SyntaxCheckers_javascript_jslint_HighlightTerm(error)
let unexpected = matchstr(a:error['text'], '\mExpected.*and instead saw \'\zs.*\ze\'')
if len(unexpected) < 1i
return ''
function! SyntaxCheckers_javascript_jslint_GetHighlightRegex(item)
let term = matchstr(a:item['text'], '\mExpected .* and instead saw ''\zs.*\ze''')
if term != ''
let term = '\V' . term
endif
return '\V'.split(unexpected, "'")[1]
return term
endfunction
function! SyntaxCheckers_javascript_jslint_GetLocList()