diff options
author | Grégoire Paris <postmaster@greg0ire.fr> | 2021-07-09 16:59:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 23:59:36 +0900 |
commit | 2a5a7baffc3b5530a2f167d241b87a3f09ed12e6 (patch) | |
tree | 42a8313e07e3549533feee8beff37e23811aa3f5 /ale_linters/php | |
parent | 774ab4b4f060cc9958df8314c428ec20cfee5e4e (diff) | |
download | ale-2a5a7baffc3b5530a2f167d241b87a3f09ed12e6.zip |
Add support for multiline messages (#3686)
This is achieved by switching to JSON, which makes it much easier to
avoid confusion between an error message and the next one. It also
spares us from having to deal with regular expressions, and eliminates
some edge cases that no longer need to be tested.
Diffstat (limited to 'ale_linters/php')
-rw-r--r-- | ale_linters/php/phpstan.vim | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ale_linters/php/phpstan.vim b/ale_linters/php/phpstan.vim index 5e231a3b..7a37d194 100644 --- a/ale_linters/php/phpstan.vim +++ b/ale_linters/php/phpstan.vim @@ -32,8 +32,8 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort \ : '' let l:error_format = ale#semver#GTE(a:version, [0, 10, 3]) - \ ? ' --error-format raw' - \ : ' --errorFormat raw' + \ ? ' --error-format json' + \ : ' --errorFormat json' return '%e analyze --no-progress' \ . l:error_format @@ -44,17 +44,17 @@ function! ale_linters#php#phpstan#GetCommand(buffer, version) abort endfunction function! ale_linters#php#phpstan#Handle(buffer, lines) abort - " Matches against lines like the following: - " - " filename.php:15:message - " C:\folder\filename.php:15:message - let l:pattern = '^\([a-zA-Z]:\)\?[^:]\+:\(\d\+\):\(.*\)$' + let l:res = ale#util#FuzzyJSONDecode(a:lines, {'files': []}) let l:output = [] - for l:match in ale#util#GetMatches(a:lines, l:pattern) + if type(l:res.files) is v:t_list + return l:output + endif + + for l:err in l:res.files[expand('#' . a:buffer .':p')].messages call add(l:output, { - \ 'lnum': l:match[2] + 0, - \ 'text': l:match[3], + \ 'lnum': l:err.line, + \ 'text': l:err.message, \ 'type': 'E', \}) endfor |