dont allow checkers with duplicate names for the same filetype

This commit is contained in:
Martin Grenfell 2013-02-01 15:01:31 +00:00
parent c97951b601
commit 0b0dbc56e6
2 changed files with 12 additions and 4 deletions

View File

@ -111,9 +111,7 @@ function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
let checker_names = []
for ft in s:CurrentFiletypes()
for checker in s:registry.availableCheckersFor(ft)
if index(checker_names, checker.name()) == -1
call add(checker_names, checker.name())
endif
endfor
endfor
return join(checker_names, "\n")

View File

@ -31,13 +31,15 @@ function! g:SyntasticRegistry.CreateAndRegisterChecker(args)
call registry.registerChecker(checker)
endfunction
function! g:SyntasticRegistry.registerChecker(checker)
function! g:SyntasticRegistry.registerChecker(checker) abort
let ft = a:checker.filetype()
if !has_key(self._checkerMap, ft)
let self._checkerMap[ft] = []
endif
call self._validateUniqueName(a:checker)
call add(self._checkerMap[ft], a:checker)
endfunction
@ -133,4 +135,12 @@ function! g:SyntasticRegistry._userHasFiletypeSettings(filetype)
return exists("g:syntastic_" . a:filetype . "_checkers")
endfunction
function! g:SyntasticRegistry._validateUniqueName(checker) abort
for checker in self._allCheckersFor(a:checker.filetype())
if checker.name() == a:checker.name()
throw "Syntastic: Duplicate syntax checker name for: " . a:checker.name()
endif
endfor
endfunction
" vim: set sw=4 sts=4 et fdm=marker: