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: Jon Parise <jon@indelible.org>
3 call ale#Set('thrift_thrift_executable', 'thrift')
4 call ale#Set('thrift_thrift_generators', ['cpp'])
5 call ale#Set('thrift_thrift_includes', ['.'])
6 call ale#Set('thrift_thrift_options', '-strict')
8 function! ale_linters#thrift#thrift#GetCommand(buffer) abort
9 let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators')
10 let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes')
12 " The thrift compiler requires at least one generator. If none are set,
13 " fall back to our default value to avoid silently failing. We could also
14 " `throw` here, but that seems even less helpful.
15 if empty(l:generators)
16 let l:generators = ['cpp']
19 let l:output_dir = ale#command#CreateDirectory(a:buffer)
22 \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val")))
23 \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val")))
24 \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options'))
25 \ . ' -out ' . ale#Escape(l:output_dir)
29 function! ale_linters#thrift#thrift#Handle(buffer, lines) abort
30 " Matches lines like the following:
32 " [SEVERITY:/path/filename.thrift:31] Message text
33 " [ERROR:/path/filename.thrift:31] (last token was ';')
34 let l:pattern = '\v^\[(\u+):(.*):(\d+)\] (.*)$'
39 " Roll our own output-matching loop instead of using ale#util#GetMatches
40 " because we need to support error messages that span multiple lines.
41 while l:index < len(a:lines)
42 let l:line = a:lines[l:index]
44 let l:match = matchlist(l:line, l:pattern)
51 let l:severity = l:match[1]
53 if l:severity is# 'WARNING'
59 " If our text looks like "(last token was ';')", the *next* line
60 " should contain a more descriptive error message.
61 let l:text = l:match[4]
63 if l:text =~# '\(last token was .*\)'
65 let l:text = get(a:lines, l:index, 'Unknown error ' . l:text)
69 \ 'lnum': l:match[3] + 0,
81 call ale#linter#Define('thrift', {
83 \ 'output_stream': 'both',
84 \ 'executable': {b -> ale#Var(b, 'thrift_thrift_executable')},
85 \ 'command': function('ale_linters#thrift#thrift#GetCommand'),
86 \ 'callback': 'ale_linters#thrift#thrift#Handle',