From 3f01cc247c200850046f59676b0dfead22986f9b Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Mon, 30 Nov 2020 13:28:04 -0500 Subject: [PATCH 1/2] dafny: add a timeLimit option and message-parsing --- ale_linters/dafny/dafny.vim | 17 ++++++++++++++++- doc/ale-dafny.txt | 16 ++++++++++++++++ doc/ale.txt | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 doc/ale-dafny.txt diff --git a/ale_linters/dafny/dafny.vim b/ale_linters/dafny/dafny.vim index b5b90675..b2060d60 100644 --- a/ale_linters/dafny/dafny.vim +++ b/ale_linters/dafny/dafny.vim @@ -14,13 +14,28 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort \ }) endfor + for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)') + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'col': l:match[3] + 0, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ }) + endfor + return l:output endfunction +function! ale_linters#dafny#dafny#GetCommand(buffer) abort + return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit')) +endfunction + +call ale#Set('dafny_dafny_timelimit', 10) call ale#linter#Define('dafny', { \ 'name': 'dafny', \ 'executable': 'dafny', -\ 'command': 'dafny %s /compile:0', +\ 'command': function('ale_linters#dafny#dafny#GetCommand'), \ 'callback': 'ale_linters#dafny#dafny#Handle', \ 'lint_file': 1, \ }) diff --git a/doc/ale-dafny.txt b/doc/ale-dafny.txt new file mode 100644 index 00000000..005170ad --- /dev/null +++ b/doc/ale-dafny.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Dafny Integration *ale-dafny-options* + + +=============================================================================== +dafny *ale-dafny-dafny* + +g:ale_dafny_dafny_timelimit *g:ale_dafny_dafny_timelimit* + *b:ale_dafny_dafny_timelimit* + Type: |Number| + Default: `10` + + This variable sets the `/timeLimit` used for dafny. + + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 6ef137c1..06fe9ee8 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2571,6 +2571,8 @@ documented in additional help files. dfmt..................................|ale-d-dfmt| dls...................................|ale-d-dls| uncrustify............................|ale-d-uncrustify| + dafny...................................|ale-dafny-options| + dafny.................................|ale-dafny-dafny| dart....................................|ale-dart-options| dartanalyzer..........................|ale-dart-dartanalyzer| dartfmt...............................|ale-dart-dartfmt| From 303b89a6b4ace2ee41818499b958a2f486e8864c Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Mon, 30 Nov 2020 13:40:57 -0500 Subject: [PATCH 2/2] add tests --- test/handler/test_dafny_handler.vader | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/handler/test_dafny_handler.vader b/test/handler/test_dafny_handler.vader index 674f691d..75567414 100644 --- a/test/handler/test_dafny_handler.vader +++ b/test/handler/test_dafny_handler.vader @@ -20,9 +20,17 @@ Execute(The Dafny handler should parse output correctly): \ 'lnum': 678, \ 'text': 'This is the precondition that might not hold.', \ 'type': 'W' - \ } + \ }, + \ { + \ 'bufnr': 0, + \ 'col': 45, + \ 'lnum': 123, + \ 'text': "Verification of 'Impl$$_22_Proof.__default.PutKeepsMapsFull' timed out after 2 seconds", + \ 'type': 'E' + \ }, \ ], \ ale_linters#dafny#dafny#Handle(0, [ \ 'File.dfy(123,45): Error BP5002: A precondition for this call might not hold.', - \ 'File.dfy(678,90): Related location: This is the precondition that might not hold.' + \ 'File.dfy(678,90): Related location: This is the precondition that might not hold.', + \ "File.dfy(123,45): Verification of 'Impl$$_22_Proof.__default.PutKeepsMapsFull' timed out after 2 seconds", \ ])