prolog/swipl: simplify with @hsanson's suggestions
https://github.com/dense-analysis/ale/pull/3377#issuecomment-763628447
This commit is contained in:
parent
730222bcd8
commit
6a3d215571
1 changed files with 6 additions and 27 deletions
|
@ -66,13 +66,6 @@ endfunction
|
||||||
|
|
||||||
" This returns [<next line number>, <error message string>]
|
" This returns [<next line number>, <error message string>]
|
||||||
function! s:GetErrMsg(i, lines, text) abort
|
function! s:GetErrMsg(i, lines, text) abort
|
||||||
let l:next_line = get(a:lines, a:i+1, '')
|
|
||||||
let l:matches = matchlist(l:next_line, s:pattern)
|
|
||||||
|
|
||||||
if !empty(l:matches) && empty(l:matches[2])
|
|
||||||
return s:GetContErrMsg(a:i+1, a:lines, a:text.matches[4])
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:text !~# '^\s*$'
|
if a:text !~# '^\s*$'
|
||||||
return [a:i + 1, a:text]
|
return [a:i + 1, a:text]
|
||||||
endif
|
endif
|
||||||
|
@ -80,31 +73,17 @@ function! s:GetErrMsg(i, lines, text) abort
|
||||||
let l:i = a:i + 1
|
let l:i = a:i + 1
|
||||||
let l:text = []
|
let l:text = []
|
||||||
|
|
||||||
while l:i < len(a:lines) && a:lines[l:i] =~# '^\s'
|
let l:pattern = '\v^(ERROR|Warning)?:?(.*)$'
|
||||||
call add(l:text, s:Trim(a:lines[l:i]))
|
|
||||||
let l:i += 1
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
return [l:i, join(l:text, '. ')]
|
while l:i < len(a:lines)
|
||||||
endfunction
|
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||||
|
|
||||||
function! s:GetContErrMsg(i, lines, text) abort
|
if empty(l:match) || empty(l:match[2])
|
||||||
if a:text !~# '^\s*$'
|
let l:i += 1
|
||||||
return [a:i + 1, a:text]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:i = a:i + 1
|
|
||||||
let l:text = []
|
|
||||||
|
|
||||||
while l:i < len(a:lines) && a:lines[l:i] =~# s:pattern
|
|
||||||
let l:matches = matchlist(a:lines[l:i], s:pattern)
|
|
||||||
|
|
||||||
if !empty(l:matches[2])
|
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(l:text, s:Trim(l:matches[4]))
|
call add(l:text, s:Trim(l:match[2]))
|
||||||
|
|
||||||
let l:i += 1
|
let l:i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
|
|
Reference in a new issue