summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Zonnenberg <amz@adriaan.xyz>2017-05-17 21:28:29 +0200
committerAdriaan Zonnenberg <amz@adriaan.xyz>2017-05-17 21:28:29 +0200
commit05970e1b28fdac59df04f11b85ccac3b65362bc7 (patch)
tree56c430117fa620d8eadf241ced23ef17b10917b9
parent6299da7bd39790ca996516f46f09482585fb9035 (diff)
downloadale-05970e1b28fdac59df04f11b85ccac3b65362bc7.zip
Add end columns on php linter #538
-rw-r--r--ale_linters/php/php.vim16
-rw-r--r--test/handler/test_php_handler.vader4
2 files changed, 15 insertions, 5 deletions
diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim
index 7c9e8c18..7158c950 100644
--- a/ale_linters/php/php.vim
+++ b/ale_linters/php/php.vim
@@ -4,17 +4,23 @@
function! ale_linters#php#php#Handle(buffer, lines) abort
" Matches patterns like the following:
"
- " PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
+ " Parse error: syntax error, unexpected ';', expecting ']' in - on line 15
let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@<!''.*|.+) in - on line (\d+)'
-
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
- call add(l:output, {
+ let l:col = empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1
+ let l:obj = {
\ 'lnum': l:match[3] + 0,
- \ 'col': empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1,
+ \ 'col': l:col,
\ 'text': l:match[1],
- \})
+ \}
+
+ if l:col != 0
+ let l:obj.end_col = l:col + strlen(l:match[2]) - 1
+ endif
+
+ call add(l:output, l:obj)
endfor
return l:output
diff --git a/test/handler/test_php_handler.vader b/test/handler/test_php_handler.vader
index c4f9944f..0d4d4278 100644
--- a/test/handler/test_php_handler.vader
+++ b/test/handler/test_php_handler.vader
@@ -14,21 +14,25 @@ Execute(The php handler should calculate column numbers):
\ {
\ 'lnum': 1,
\ 'col': 5,
+ \ 'end_col': 5,
\ 'text': "syntax error, unexpected ';', expecting ']'",
\ },
\ {
\ 'lnum': 2,
\ 'col': 13,
+ \ 'end_col': 13,
\ 'text': "syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST)",
\ },
\ {
\ 'lnum': 3,
\ 'col': 5,
+ \ 'end_col': 5,
\ 'text': "syntax error, unexpected ')'",
\ },
\ {
\ 'lnum': 4,
\ 'col': 8,
+ \ 'end_col': 12,
\ 'text': "syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'",
\ },
\ ],