Modify to be able to use phan_client without g:ale_php_phan_executable
This commit is contained in:
parent
8cee39c614
commit
eb3ab87569
@ -1,4 +1,4 @@
|
|||||||
" Author: diegoholiveira <https://github.com/diegoholiveira>, haginaga
|
" Author: diegoholiveira <https://github.com/diegoholiveira>, haginaga <https://github.com/haginaga>
|
||||||
" Description: static analyzer for PHP
|
" Description: static analyzer for PHP
|
||||||
|
|
||||||
" Define the minimum severity
|
" Define the minimum severity
|
||||||
@ -8,12 +8,16 @@ let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan')
|
|||||||
let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
|
let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0)
|
||||||
|
|
||||||
function! ale_linters#php#phan#GetExecutable(buffer) abort
|
function! ale_linters#php#phan#GetExecutable(buffer) abort
|
||||||
return ale#Var(a:buffer, 'php_phan_executable')
|
let l:executable = ale#Var(a:buffer, 'php_phan_executable')
|
||||||
|
if g:ale_php_phan_use_client == 1 && l:executable == 'phan'
|
||||||
|
let l:executable = 'phan_client'
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:executable
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#php#phan#GetCommand(buffer) abort
|
function! ale_linters#php#phan#GetCommand(buffer) abort
|
||||||
let l:use_client = ale#Var(a:buffer, 'php_phan_use_client')
|
if g:ale_php_phan_use_client == 1
|
||||||
if l:use_client == 1
|
|
||||||
let l:args = '-l '
|
let l:args = '-l '
|
||||||
\ . ' %s'
|
\ . ' %s'
|
||||||
else
|
else
|
||||||
@ -28,10 +32,8 @@ function! ale_linters#php#phan#GetCommand(buffer) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#php#phan#Handle(buffer, lines) abort
|
function! ale_linters#php#phan#Handle(buffer, lines) abort
|
||||||
let l:use_client = ale#Var(a:buffer, 'php_phan_use_client')
|
|
||||||
|
|
||||||
" Matches against lines like the following:
|
" Matches against lines like the following:
|
||||||
if l:use_client == 1
|
if g:ale_php_phan_use_client == 1
|
||||||
" Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
|
" Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn
|
||||||
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
|
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
|
||||||
else
|
else
|
||||||
@ -41,7 +43,7 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort
|
|||||||
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
if l:use_client == 1
|
if g:ale_php_phan_use_client == 1
|
||||||
let l:dict = {
|
let l:dict = {
|
||||||
\ 'lnum': l:match[4] + 0,
|
\ 'lnum': l:match[4] + 0,
|
||||||
\ 'text': l:match[2],
|
\ 'text': l:match[2],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user