summaryrefslogtreecommitdiff
path: root/ale_linters/prolog
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2021-01-20 11:59:24 -0500
committerD. Ben Knoble <ben.knoble+github@gmail.com>2021-01-20 12:07:26 -0500
commit6a3d215571662bfc97d2d415dfbec4bc217eda62 (patch)
tree7b42e2251797a32855fe06a28990c3be85757a87 /ale_linters/prolog
parent730222bcd815acdb2b090afc81573a54f79395d2 (diff)
downloadale-6a3d215571662bfc97d2d415dfbec4bc217eda62.zip
prolog/swipl: simplify with @hsanson's suggestions
https://github.com/dense-analysis/ale/pull/3377#issuecomment-763628447
Diffstat (limited to 'ale_linters/prolog')
-rw-r--r--ale_linters/prolog/swipl.vim33
1 files changed, 6 insertions, 27 deletions
diff --git a/ale_linters/prolog/swipl.vim b/ale_linters/prolog/swipl.vim
index 878a2cbf..e5a42e52 100644
--- a/ale_linters/prolog/swipl.vim
+++ b/ale_linters/prolog/swipl.vim
@@ -66,13 +66,6 @@ endfunction
" This returns [<next line number>, <error message string>]
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*$'
return [a:i + 1, a:text]
endif
@@ -80,31 +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:i += 1
- endwhile
-
- return [l:i, join(l:text, '. ')]
-endfunction
-
-function! s:GetContErrMsg(i, lines, text) abort
- if a:text !~# '^\s*$'
- return [a:i + 1, a:text]
- endif
+ let l:pattern = '\v^(ERROR|Warning)?:?(.*)$'
- 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)
+ while l:i < len(a:lines)
+ let l:match = matchlist(a:lines[l:i], l:pattern)
- if !empty(l:matches[2])
+ if empty(l:match) || empty(l:match[2])
+ let l:i += 1
break
endif
- call add(l:text, s:Trim(l:matches[4]))
-
+ call add(l:text, s:Trim(l:match[2]))
let l:i += 1
endwhile