mirror of
https://github.com/dense-analysis/ale
synced 2024-12-19 21:02:02 +00:00
Merge pull request #3377 from benknoble/fix-swipl
prolog/swipl: update error format for new version
This commit is contained in:
commit
580271b510
@ -35,10 +35,11 @@ function! s:Subst(format, vars) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#prolog#swipl#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$'
|
||||
let l:output = []
|
||||
let l:i = 0
|
||||
|
||||
let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$'
|
||||
|
||||
while l:i < len(a:lines)
|
||||
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||
|
||||
@ -72,8 +73,17 @@ function! s:GetErrMsg(i, lines, text) abort
|
||||
let l:i = a:i + 1
|
||||
let l:text = []
|
||||
|
||||
while l:i < len(a:lines) && a:lines[l:i] =~# '^\s'
|
||||
call add(l:text, s:Trim(a:lines[l:i]))
|
||||
let l:pattern = '\v^(ERROR|Warning)?:?(.*)$'
|
||||
|
||||
while l:i < len(a:lines)
|
||||
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||
|
||||
if empty(l:match) || empty(l:match[2])
|
||||
let l:i += 1
|
||||
break
|
||||
endif
|
||||
|
||||
call add(l:text, s:Trim(l:match[2]))
|
||||
let l:i += 1
|
||||
endwhile
|
||||
|
||||
|
@ -35,6 +35,22 @@ Execute (The swipl handler should handle a warning / error of two lines):
|
||||
\ ' Singleton variables: [M]',
|
||||
\ ])
|
||||
|
||||
Execute (The swipl handler should handle a warning / error of two lines in the new format):
|
||||
call ale#test#SetFilename('test.pl')
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 9,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'Singleton variables: [M]',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#prolog#swipl#Handle(bufnr(''), [
|
||||
\ 'Warning: /path/to/test.pl:9:',
|
||||
\ 'Warning: Singleton variables: [M]',
|
||||
\ ])
|
||||
|
||||
Execute (The swipl handler should join three or more lines with '. '):
|
||||
call ale#test#SetFilename('test.pl')
|
||||
AssertEqual
|
||||
@ -79,6 +95,50 @@ Execute (The swipl handler should ignore warnings / errors 'No permission to cal
|
||||
\ ' vimscript: (multifile A)',
|
||||
\ ])
|
||||
|
||||
Execute (The swipl handler should join three or more lines with '. ' on latest swipl):
|
||||
call ale#test#SetFilename('test.pl')
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'Clauses of fib/2 are not together in the source-file. Earlier definition at /path/to/test.pl:7. Current predicate: f/0. Use :- discontiguous fib/2. to suppress this message',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#prolog#swipl#Handle(bufnr(''), [
|
||||
\ 'Warning: /path/to/test.pl:10:',
|
||||
\ 'Warning: Clauses of fib/2 are not together in the source-file',
|
||||
\ 'Warning: Earlier definition at /path/to/test.pl:7',
|
||||
\ 'Warning: Current predicate: f/0',
|
||||
\ 'Warning: Use :- discontiguous fib/2. to suppress this message',
|
||||
\ ])
|
||||
|
||||
Execute (The swipl handler should ignore warnings / errors 'No permission to call sandboxed with latest swpl...'):
|
||||
call ale#test#SetFilename('test.pl')
|
||||
AssertEqual
|
||||
\ [],
|
||||
\ ale_linters#prolog#swipl#Handle(bufnr(''), [
|
||||
\ 'ERROR: /path/to/test.pl:11:',
|
||||
\ 'ERROR: No permission to call sandboxed `''$set_predicate_attribute''(_G3416:_G3417,_G3413,_G3414)''',
|
||||
\ 'ERROR: Reachable from:',
|
||||
\ 'ERROR: system:''$set_pattr''(A,B,C,D)',
|
||||
\ 'ERROR: system:''$set_pattr''(vimscript:A,B,C)',
|
||||
\ 'ERROR: vimscript: (multifile A)',
|
||||
\ 'ERROR: /path/to/test.pl:12:',
|
||||
\ 'ERROR: No permission to call sandboxed `''$set_predicate_attribute''(_G205:_G206,_G202,_G203)''',
|
||||
\ 'ERROR: Reachable from:',
|
||||
\ 'ERROR: system:''$set_pattr''(A,B,C,D)',
|
||||
\ 'ERROR: system:''$set_pattr''(vimscript:A,B,C)',
|
||||
\ 'ERROR: vimscript: (multifile A)',
|
||||
\ 'ERROR: /path/to/test.pl:13:',
|
||||
\ 'ERROR: No permission to call sandboxed `''$set_predicate_attribute''(_G1808:_G1809,_G1805,_G1806)''',
|
||||
\ 'ERROR: Reachable from:',
|
||||
\ 'ERROR: system:''$set_pattr''(A,B,C,D)',
|
||||
\ 'ERROR: system:''$set_pattr''(vimscript:A,B,C)',
|
||||
\ 'ERROR: vimscript: (multifile A)',
|
||||
\ ])
|
||||
|
||||
Execute (The swipl handler should handle a warning / error with no line number):
|
||||
call ale#test#SetFilename('test.pl')
|
||||
AssertEqual
|
||||
|
Loading…
Reference in New Issue
Block a user