From 6a3d215571662bfc97d2d415dfbec4bc217eda62 Mon Sep 17 00:00:00 2001 From: Horacio Sanson Date: Wed, 20 Jan 2021 11:59:24 -0500 Subject: [PATCH] prolog/swipl: simplify with @hsanson's suggestions https://github.com/dense-analysis/ale/pull/3377#issuecomment-763628447 --- ale_linters/prolog/swipl.vim | 33 ++++++--------------------------- 1 file 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 [, ] 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 + let l:pattern = '\v^(ERROR|Warning)?:?(.*)$' - return [l:i, join(l:text, '. ')] -endfunction + while l:i < len(a:lines) + let l:match = matchlist(a:lines[l:i], l:pattern) -function! s:GetContErrMsg(i, lines, text) abort - if a:text !~# '^\s*$' - 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]) + 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