summaryrefslogtreecommitdiff
path: root/ale_linters/perl6
diff options
context:
space:
mode:
authorTravis Gibson <TGib.Travis@protonmail.com>2018-10-03 14:13:34 -0700
committerTravis Gibson <TGib.Travis@protonmail.com>2018-10-03 14:13:34 -0700
commitadad9a21ab3fa16b115c044de3c46d98b577f72b (patch)
treed64b64b4cb765dec5ecc225c2b998425ad9108dc /ale_linters/perl6
parent2b2e766dc6df4d05e58c106f51b5444be4efbcea (diff)
downloadale-adad9a21ab3fa16b115c044de3c46d98b577f72b.zip
Fix crashes with incomplete errors
Diffstat (limited to 'ale_linters/perl6')
-rw-r--r--ale_linters/perl6/perl6.vim55
1 files changed, 37 insertions, 18 deletions
diff --git a/ale_linters/perl6/perl6.vim b/ale_linters/perl6/perl6.vim
index 326850a2..b33a0c51 100644
--- a/ale_linters/perl6/perl6.vim
+++ b/ale_linters/perl6/perl6.vim
@@ -21,9 +21,9 @@ function! ale_linters#perl6#perl6#GetCommand(buffer) abort
\ . ' %t'
endfunction
-function! ale_linters#perl6#perl6#ExtractError(dict, item, type) abort
+function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort
let l:file = ''
- let l:line = ''
+ let l:line = 1
let l:column = ''
let l:text = ''
let l:pre = ''
@@ -32,26 +32,26 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type) abort
let l:linepatternmessage = 'at\s\+line\s\+\(\d\+\)'
if has_key(a:dict[a:item], 'filename') && !empty(a:dict[a:item]['filename'])
- let l:file .= a:dict[a:item]['filename']
+ let l:file = a:dict[a:item]['filename']
endif
if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line'])
- let l:line .= a:dict[a:item]['line']
+ let l:line = a:dict[a:item]['line']
let l:counter -= 1
endif
if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column'])
- let l:column .= a:dict[a:item]['column']
+ let l:column = a:dict[a:item]['column']
endif
if has_key(a:dict[a:item], 'message') && !empty(a:dict[a:item]['message'])
- let l:text .= substitute(a:dict[a:item]['message'], '\s*\n\s*', ' ', 'g')
+ let l:text = substitute(a:dict[a:item]['message'], '\s*\n\s*', ' ', 'g')
let l:counter -= 1
endif
if has_key(a:dict[a:item], 'line-real') && !empty(a:dict[a:item]['line-real'])
let l:end_line = l:line
- let l:line .= a:dict[a:item]['line-real']
+ let l:line = a:dict[a:item]['line-real']
endif
for l:match in ale#util#GetMatches(l:text, l:linepatternmessage)
@@ -59,9 +59,11 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type) abort
let l:counter -= 1
endfor
- if l:counter < 1
+" Currently, filenames and line numbers are not always given in the error output
+ if l:counter < 2
+ \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' )
return {
- \ 'lnum': l:line,
+ \ 'lnum': '' . l:line,
\ 'text': l:text,
\ 'type': a:type,
\ 'col': l:column,
@@ -69,6 +71,8 @@ function! ale_linters#perl6#perl6#ExtractError(dict, item, type) abort
\ 'code': a:item,
\}
endif
+
+ return ''
endfunction
function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
@@ -102,13 +106,17 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
if !empty(l:json[l:key]['sorrows'])
for l:dictionary in get(l:json[l:key], 'sorrows')
for l:item in keys(l:dictionary)
- call add(l:output,
+ let l:result =
\ ale_linters#perl6#perl6#ExtractError(
\ l:dictionary,
\ l:item,
- \ 'E'
+ \ 'E',
+ \ a:buffer,
\ )
- \ )
+
+ if l:result isnot# ''
+ call add(l:output, l:result)
+ endif
endfor
endfor
endif
@@ -116,20 +124,31 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
if !empty(l:json[l:key]['worries'])
for l:dictionary in get(l:json[l:key], 'worries')
for l:item in keys(l:dictionary)
- call add(l:output,
+ let l:result =
\ ale_linters#perl6#perl6#ExtractError(
\ l:dictionary,
\ l:item,
- \ 'W'
+ \ 'W',
+ \ a:buffer,
\ )
- \ )
+
+ if l:result isnot# ''
+ call add(l:output, l:result)
+ endif
endfor
endfor
endif
else
- call add(l:output,
- \ ale_linters#perl6#perl6#ExtractError(l:json, l:key, 'E')
- \ )
+ let l:result = ale_linters#perl6#perl6#ExtractError(
+ \ l:json,
+ \ l:key,
+ \ 'E',
+ \ a:buffer,
+ \ )
+
+ if l:result isnot# ''
+ call add(l:output, l:result)
+ endif
endif
endfor
endif