Merge branch 'master' into gcc_refactor

This commit is contained in:
LCD 47 2013-06-01 07:45:54 +03:00
commit 67ec6ae4f2
7 changed files with 45 additions and 28 deletions

View File

@ -57,14 +57,14 @@ if !exists("g:syntastic_filetype_map")
endif endif
let s:registry = g:SyntasticRegistry.Instance() let s:registry = g:SyntasticRegistry.Instance()
let s:notifiers = g:SyntasticNotifiers.New() let s:notifiers = g:SyntasticNotifiers.Instance()
let s:modemap = g:SyntasticModeMap.Instance() let s:modemap = g:SyntasticModeMap.Instance()
function! s:CompleteCheckerName(argLead, cmdLine, cursorPos) function! s:CompleteCheckerName(argLead, cmdLine, cursorPos)
let checker_names = [] let checker_names = []
for ft in s:CurrentFiletypes() for ft in s:CurrentFiletypes()
for checker in s:registry.availableCheckersFor(ft) for checker in s:registry.availableCheckersFor(ft)
call add(checker_names, checker.name()) call add(checker_names, checker.getName())
endfor endfor
endfor endfor
return join(checker_names, "\n") return join(checker_names, "\n")
@ -172,7 +172,7 @@ function! s:CacheErrors(...)
endif endif
for checker in checkers for checker in checkers
call syntastic#util#debug("CacheErrors: Invoking checker: " . checker.name()) call syntastic#util#debug("CacheErrors: Invoking checker: " . checker.getName())
let loclist = checker.getLocList() let loclist = checker.getLocList()
@ -258,7 +258,7 @@ endfunction
function! SyntasticStatuslineFlag() function! SyntasticStatuslineFlag()
let loclist = g:SyntasticLoclist.current() let loclist = g:SyntasticLoclist.current()
let issues = loclist.filteredRaw() let issues = loclist.filteredRaw()
let num_issues = loclist.length() let num_issues = loclist.getLength()
if loclist.hasErrorsOrWarningsToDisplay() if loclist.hasErrorsOrWarningsToDisplay()
let errors = loclist.errors() let errors = loclist.errors()
let warnings = loclist.warnings() let warnings = loclist.warnings()

View File

@ -27,11 +27,11 @@ function! g:SyntasticChecker.New(args)
return newObj return newObj
endfunction endfunction
function! g:SyntasticChecker.filetype() function! g:SyntasticChecker.getFiletype()
return self._filetype return self._filetype
endfunction endfunction
function! g:SyntasticChecker.name() function! g:SyntasticChecker.getName()
return self._name return self._name
endfunction endfunction

View File

@ -55,7 +55,7 @@ function! g:SyntasticLoclist.isEmpty()
return empty(self._rawLoclist) return empty(self._rawLoclist)
endfunction endfunction
function! g:SyntasticLoclist.length() function! g:SyntasticLoclist.getLength()
return len(self._rawLoclist) return len(self._rawLoclist)
endfunction endfunction

View File

@ -5,6 +5,8 @@ let g:loaded_syntastic_modemap = 1
let g:SyntasticModeMap = {} let g:SyntasticModeMap = {}
" Public methods {{{1
function! g:SyntasticModeMap.Instance() function! g:SyntasticModeMap.Instance()
if !exists('s:SyntasticModeMapInstance') if !exists('s:SyntasticModeMapInstance')
let s:SyntasticModeMapInstance = copy(self) let s:SyntasticModeMapInstance = copy(self)
@ -40,6 +42,8 @@ function! g:SyntasticModeMap.echoMode()
echo "Syntastic: " . self._mode . " mode enabled" echo "Syntastic: " . self._mode . " mode enabled"
endfunction endfunction
" Private methods {{{1
function! g:SyntasticModeMap._initModeMapFromGlobalOpts() function! g:SyntasticModeMap._initModeMapFromGlobalOpts()
let self._mode = "active" let self._mode = "active"
let self._activeFiletypes = [] let self._activeFiletypes = []
@ -60,3 +64,4 @@ function! g:SyntasticModeMap._noFiletypesArePassive(filetypes)
return empty(filter(a:filetypes, 'index(self._passiveFiletypes, v:val) != -1')) return empty(filter(a:filetypes, 'index(self._passiveFiletypes, v:val) != -1'))
endfunction endfunction
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -9,18 +9,13 @@ let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autolocl
" Public methods {{{1 " Public methods {{{1
function! g:SyntasticNotifiers.New() function! g:SyntasticNotifiers.Instance()
let newObj = copy(self) if !exists('s:SyntasticNotifiersInstance')
let s:SyntasticNotifiersInstance = copy(self)
call s:SyntasticNotifiersInstance._initNotifiers()
endif
let newObj._notifier = {} return s:SyntasticNotifiersInstance
for type in s:notifier_types
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
let newObj._notifier[type] = g:{class}.New()
endfor
let newObj._enabled_types = copy(s:notifier_types)
return newObj
endfunction endfunction
function! g:SyntasticNotifiers.refresh(loclist) function! g:SyntasticNotifiers.refresh(loclist)
@ -41,4 +36,16 @@ function! g:SyntasticNotifiers.reset(loclist)
endfor endfor
endfunction endfunction
" Private methods {{{1
function! g:SyntasticNotifiers._initNotifiers()
let self._notifier = {}
for type in s:notifier_types
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
let self._notifier[type] = g:{class}.New()
endfor
let self._enabled_types = copy(s:notifier_types)
endfunction
" vim: set sw=4 sts=4 et fdm=marker: " vim: set sw=4 sts=4 et fdm=marker:

View File

@ -47,7 +47,7 @@ function! g:SyntasticRegistry.CreateAndRegisterChecker(args)
endfunction endfunction
function! g:SyntasticRegistry.registerChecker(checker) abort function! g:SyntasticRegistry.registerChecker(checker) abort
let ft = a:checker.filetype() let ft = a:checker.getFiletype()
if !has_key(self._checkerMap, ft) if !has_key(self._checkerMap, ft)
let self._checkerMap[ft] = [] let self._checkerMap[ft] = []
@ -85,7 +85,7 @@ endfunction
function! g:SyntasticRegistry.getChecker(ftalias, name) function! g:SyntasticRegistry.getChecker(ftalias, name)
for checker in self.availableCheckersFor(a:ftalias) for checker in self.availableCheckersFor(a:ftalias)
if checker.name() == a:name if checker.getName() == a:name
return checker return checker
endif endif
endfor endfor
@ -109,8 +109,8 @@ function! g:SyntasticRegistry.echoInfoFor(ftalias_list)
call extend(active, self.getActiveCheckers(ftalias)) call extend(active, self.getActiveCheckers(ftalias))
endfor endfor
echomsg "Available checkers: " . join(syntastic#util#unique(map(available, "v:val.name()"))) echomsg "Available checkers: " . join(syntastic#util#unique(map(available, "v:val.getName()")))
echomsg "Currently active checker(s): " . join(syntastic#util#unique(map(active, "v:val.name()"))) echomsg "Currently active checker(s): " . join(syntastic#util#unique(map(active, "v:val.getName()")))
endfunction endfunction
" Private methods {{{1 " Private methods {{{1
@ -127,7 +127,7 @@ endfunction
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype) function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
if has_key(s:defaultCheckers, a:filetype) if has_key(s:defaultCheckers, a:filetype)
let whitelist = s:defaultCheckers[a:filetype] let whitelist = s:defaultCheckers[a:filetype]
return filter(a:checkers, "index(whitelist, v:val.name()) != -1") return filter(a:checkers, "index(whitelist, v:val.getName()) != -1")
endif endif
return a:checkers return a:checkers
@ -139,7 +139,7 @@ function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
else else
let whitelist = g:syntastic_{a:filetype}_checkers let whitelist = g:syntastic_{a:filetype}_checkers
endif endif
return filter(a:checkers, "index(whitelist, v:val.name()) != -1") return filter(a:checkers, "index(whitelist, v:val.getName()) != -1")
endfunction endfunction
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers) function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
@ -171,9 +171,9 @@ function! g:SyntasticRegistry._userHasFiletypeSettings(filetype)
endfunction endfunction
function! g:SyntasticRegistry._validateUniqueName(checker) abort function! g:SyntasticRegistry._validateUniqueName(checker) abort
for checker in self._allCheckersFor(a:checker.filetype()) for checker in self._allCheckersFor(a:checker.getFiletype())
if checker.name() == a:checker.name() if checker.getName() == a:checker.getName()
throw "Syntastic: Duplicate syntax checker name for: " . a:checker.name() throw "Syntastic: Duplicate syntax checker name for: " . a:checker.getName()
endif endif
endfor endfor
endfunction endfunction

View File

@ -20,7 +20,12 @@ function! SyntaxCheckers_text_atdtool_IsAvailable()
endfunction endfunction
function! SyntaxCheckers_text_atdtool_GetHighlightRegex(item) function! SyntaxCheckers_text_atdtool_GetHighlightRegex(item)
return matchstr(a:item['text'], '\m "\zs[^"]\+\ze"\($\| | suggestions:\)') let term = matchstr(a:item['text'], '\m "\zs[^"]\+\ze"\($\| | suggestions:\)')
if term != ''
let col = get(a:item, 'col', 0)
let term = (col != 0 ? '\%' . col . 'c' : '') . '\V' . term
endif
return term
endfunction endfunction
function! SyntaxCheckers_text_atdtool_GetLocList() function! SyntaxCheckers_text_atdtool_GetLocList()