Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make parsing more robust (fixes #19) #21

Merged
merged 1 commit into from
Dec 11, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions autoload/ghcmod.vim
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ function! ghcmod#parse_make(lines, basedir)"{{{
for l:output in a:lines
let l:qf = {}
let l:m = matchlist(l:output, '^\(\f\+\):\(\d\+\):\(\d\+\):\s*\(.*\)$')
if len(l:m) < 4
let l:qf.bufnr = 0
let l:qf.type = 'E'
let l:qf.text = 'parse error in ghcmod! Could not parse the following ghc-mod output:' . l:output
call add(l:qflist, l:qf)
break
end
let [l:qf.filename, l:qf.lnum, l:qf.col, l:rest] = l:m[1 : 4]
let l:qf.filename = s:join_path(a:basedir, l:qf.filename)
if l:rest =~# '^Warning:'
Expand All @@ -168,12 +175,24 @@ function! ghcmod#parse_make(lines, basedir)"{{{
let l:qf.type = 'E'
endif
let l:texts = split(l:rest, '\n')
let l:qf.text = l:texts[0]
call add(l:qflist, l:qf)

for l:text in l:texts[1 :]
call add(l:qflist, {'text': l:text})
endfor
if len(l:texts) > 0
let l:qf.text = l:texts[0]
call add(l:qflist, l:qf)
for l:text in l:texts[1 :]
call add(l:qflist, {'text': l:text})
endfor
else
let l:qf.filename = ''
let l:errortext = join(a:lines, "\n")
let l:qf.bufnr = 0
let l:qf.type = 'E'
let l:qf.text = 'parse error in ghcmod! Could not parse the following ghc-mod output:'
call add(l:qflist, l:qf)
for l:text in a:lines
call add(l:qflist, {'text': l:text})
endfor
break
endif
endfor
return l:qflist
endfunction"}}}
Expand Down