diff options
author | w0rp <devw0rp@gmail.com> | 2017-04-18 00:35:53 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-04-18 00:35:53 +0100 |
commit | bdad25eefd6526f8130f97edbe25a1179e27aadc (patch) | |
tree | c2e563e959121e77f6d96a256583849f6851f0a4 /ale_linters/php | |
parent | e237add9fdec64c80ed57f383e2b73464fb4b43d (diff) | |
download | ale-bdad25eefd6526f8130f97edbe25a1179e27aadc.zip |
Add a function for getting matches, and use it to simplify a lot of code
Diffstat (limited to 'ale_linters/php')
-rw-r--r-- | ale_linters/php/hack.vim | 12 | ||||
-rw-r--r-- | ale_linters/php/php.vim | 10 | ||||
-rw-r--r-- | ale_linters/php/phpcs.vim | 9 | ||||
-rw-r--r-- | ale_linters/php/phpmd.vim | 10 |
4 files changed, 5 insertions, 36 deletions
diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim index 762486b4..77d3a588 100644 --- a/ale_linters/php/hack.vim +++ b/ale_linters/php/hack.vim @@ -5,23 +5,15 @@ function! ale_linters#php#hack#Handle(buffer, lines) abort let l:pattern = '^\(.*\):\(\d\+\):\(\d\+\),\(\d\+\): \(.\+])\)$' let l:output = [] - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - + for l:match in ale#util#GetMatches(a:lines, l:pattern) if a:buffer != bufnr(l:match[1]) - continue + continue endif call add(l:output, { - \ 'bufnr': a:buffer, \ 'lnum': l:match[2] + 0, \ 'col': l:match[3] + 0, \ 'text': l:match[5], - \ 'type': 'E', \}) endfor diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index 3f354de5..6d151686 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -9,19 +9,11 @@ function! ale_linters#php#php#Handle(buffer, lines) abort let l:output = [] - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - + for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'bufnr': a:buffer, \ 'lnum': l:match[3] + 0, \ 'col': empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1, \ 'text': l:match[1], - \ 'type': 'E', \}) endfor diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 15e1457a..94c887c4 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -19,18 +19,11 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) \(\(.\+\)\)$' let l:output = [] - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - + for l:match in ale#util#GetMatches(a:lines, l:pattern) let l:text = l:match[4] let l:type = l:match[3] call add(l:output, { - \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, \ 'col': l:match[2] + 0, \ 'text': l:text, diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim index 02b98306..29d8103a 100644 --- a/ale_linters/php/phpmd.vim +++ b/ale_linters/php/phpmd.vim @@ -17,17 +17,9 @@ function! ale_linters#php#phpmd#Handle(buffer, lines) abort let l:pattern = '^.*:\(\d\+\)\t\(.\+\)$' let l:output = [] - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - + for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'bufnr': a:buffer, \ 'lnum': l:match[1] + 0, - \ 'col': 0, \ 'text': l:match[2], \ 'type': 'W', \}) |