All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Martino Pilia <martino.pilia@gmail.com>
2 " Description: Lint Ada files with GCC
4 call ale#Set('ada_gcc_executable', 'gcc')
6 " -gnatwa: activate most optional warnings
7 " -gnatq: try semantic analysis even if syntax errors have been found
8 call ale#Set('ada_gcc_options', '-gnatwa -gnatq')
10 function! ale_linters#ada#gcc#GetCommand(buffer) abort
11 " Build a suitable output file name. The output file is specified because
12 " the .ali file may be created even if no code generation is attempted.
13 " The output file name must match the source file name (except for the
14 " extension), so here we cannot use the null file as output.
15 let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p')
16 let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o'
18 " -gnatc: Check syntax and semantics only (no code generation attempted)
19 return '%e -x ada -c -gnatc'
20 \ . ' -o ' . ale#Escape(l:out_file)
22 \ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options'))
26 " For the message format please refer to:
27 " https://gcc.gnu.org/onlinedocs/gnat_ugn/Output-and-Error-Message-Control.html
28 " https://gcc.gnu.org/onlinedocs/gnat_ugn/Warning-Message-Control.html
29 function! ale_linters#ada#gcc#Handle(buffer, lines) abort
30 " Error format: <filename>:<lnum>:<col>: <text>
31 " Warning format: <filename>:<lnum>:<col>: warning: <text>
32 let l:re = '\v(.+):([0-9]+):([0-9]+):\s+(warning:)?\s*(.+)\s*'
35 for l:match in ale#util#GetMatches(a:lines, l:re)
38 \ 'lnum': str2nr(l:match[2]),
39 \ 'col': str2nr(l:match[3]),
40 \ 'type': l:match[4] is# 'warning:' ? 'W' : 'E',
48 call ale#linter#Define('ada', {
50 \ 'output_stream': 'stderr',
51 \ 'executable': {b -> ale#Var(b, 'ada_gcc_executable')},
52 \ 'command': function('ale_linters#ada#gcc#GetCommand'),
53 \ 'callback': 'ale_linters#ada#gcc#Handle',