PHP: Make parser work with more error messages
This commit is contained in:
parent
a18e172a96
commit
cca0222cf1
@ -5,7 +5,7 @@ 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
|
||||
let l:pattern = ':\s\+\(.\+unexpected ''\(.\{-}\)''.*\) in - on line \(\d\+\)'
|
||||
let l:pattern = 'Parse error:\s\+\(.\{-}unexpected ''\(.\{-}\)''.\{-}\|.*\) in - on line \(\d\+\)'
|
||||
|
||||
let l:output = []
|
||||
|
||||
@ -21,7 +21,7 @@ function! ale_linters#php#php#Handle(buffer, lines) abort
|
||||
\ 'bufnr': a:buffer,
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': match(getline(l:match[3]), l:match[2]) + 1,
|
||||
\ 'col': empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1,
|
||||
\ 'text': l:match[1],
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
|
@ -30,13 +30,32 @@ Execute(The php handler should parse lines correctly):
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 5,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': 0,
|
||||
\ 'text': "Invalid numeric literal",
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 21,
|
||||
\ 'vcol': 0,
|
||||
\ 'col': 0,
|
||||
\ 'text': "syntax error, unexpected end of file",
|
||||
\ 'type': 'E',
|
||||
\ 'nr': -1,
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#php#php#Handle(347, [
|
||||
\ 'This line should be ignored completely',
|
||||
\ "PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 47",
|
||||
\ "PHP Parse error: syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST) in - on line 56",
|
||||
\ 'This line should be ignored completely',
|
||||
\ "PHP Parse error: syntax error, unexpected ')' in - on line 13",
|
||||
\ 'PHP Parse error: Invalid numeric literal in - on line 5',
|
||||
\ 'PHP Parse error: syntax error, unexpected end of file in - on line 21',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
|
Loading…
Reference in New Issue
Block a user