summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-24 10:40:11 +0900
committerGitHub <noreply@github.com>2021-01-24 10:40:11 +0900
commit580271b510b3a6b91aa5581aa8476465f1dc5ce4 (patch)
tree1198a97028e8b9bbf8021aed0a13a06ffbc9f402
parent9fd9435cd525b1d3c4470db0d514f72ed31cfece (diff)
parent2c1c5b06d9554592370f0ad651c21b61334123e4 (diff)
downloadale-580271b510b3a6b91aa5581aa8476465f1dc5ce4.zip
Merge pull request #3377 from benknoble/fix-swipl
prolog/swipl: update error format for new version
-rw-r--r--ale_linters/prolog/swipl.vim16
-rw-r--r--test/handler/test_swipl_handler.vader60
2 files changed, 73 insertions, 3 deletions
diff --git a/ale_linters/prolog/swipl.vim b/ale_linters/prolog/swipl.vim
index 5c601c40..82859eb0 100644
--- a/ale_linters/prolog/swipl.vim
+++ b/ale_linters/prolog/swipl.vim
@@ -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
diff --git a/test/handler/test_swipl_handler.vader b/test/handler/test_swipl_handler.vader
index 9e425cf6..81b8b9e5 100644
--- a/test/handler/test_swipl_handler.vader
+++ b/test/handler/test_swipl_handler.vader
@@ -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