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

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

View File

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