summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorNĂ©stor Coppi <nestorcoppi@gmail.com>2021-07-04 09:40:12 -0300
committerGitHub <noreply@github.com>2021-07-04 21:40:12 +0900
commit87e079a9b25ebf5818b8451874ce2a8bd614226f (patch)
tree20cdfa060b40d7302d6269398d82034536c17bc9 /ale_linters
parent36fcb01e05979b410da1dcee10979b0f4e610eb6 (diff)
downloadale-87e079a9b25ebf5818b8451874ce2a8bd614226f.zip
Solidity solc linter compatible with 0.6/0.7/0.8 (#3763)
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/solidity/solc.vim42
1 files changed, 30 insertions, 12 deletions
diff --git a/ale_linters/solidity/solc.vim b/ale_linters/solidity/solc.vim
index e4f220ac..28977083 100644
--- a/ale_linters/solidity/solc.vim
+++ b/ale_linters/solidity/solc.vim
@@ -1,34 +1,52 @@
" Author: Karl Bartel <karl42@gmail.com> - http://karl.berlin/
" Description: Report solc compiler errors in Solidity code
+call ale#Set('solidity_solc_executable', 'solc')
call ale#Set('solidity_solc_options', '')
function! ale_linters#solidity#solc#Handle(buffer, lines) abort
" Matches patterns like the following:
- " /path/to/file/file.sol:1:10: Error: Identifier not found or not unique.
- let l:pattern = '\v^[^:]+:(\d+):(\d+): (Error|Warning): (.*)$'
+ " Error: Expected ';' but got '('
+ " --> /path/to/file/file.sol:1:10:)
+ let l:pattern = '\v(Error|Warning): (.*)$'
+ let l:line_and_column_pattern = '\v\.sol:(\d+):(\d+):'
let l:output = []
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
- let l:isError = l:match[3] is? 'error'
- call add(l:output, {
- \ 'lnum': l:match[1] + 0,
- \ 'col': l:match[2] + 0,
- \ 'text': l:match[4],
- \ 'type': l:isError ? 'E' : 'W',
- \})
+ for l:line in a:lines
+ let l:match = matchlist(l:line, l:pattern)
+
+ if len(l:match) == 0
+ let l:match = matchlist(l:line, l:line_and_column_pattern)
+
+ if len(l:match) > 0
+ let l:index = len(l:output) - 1
+ let l:output[l:index]['lnum'] = l:match[1] + 0
+ let l:output[l:index]['col'] = l:match[2] + 0
+ endif
+ else
+ let l:isError = l:match[1] is? 'Error'
+
+ call add(l:output, {
+ \ 'lnum': 0,
+ \ 'col': 0,
+ \ 'text': l:match[2],
+ \ 'type': l:isError ? 'E' : 'W',
+ \})
+ endif
endfor
return l:output
endfunction
function! ale_linters#solidity#solc#GetCommand(buffer) abort
- return 'solc' . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s'
+ let l:executable = ale#Var(a:buffer, 'solidity_solc_executable')
+
+ return l:executable . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s'
endfunction
call ale#linter#Define('solidity', {
\ 'name': 'solc',
-\ 'executable': 'solc',
+\ 'executable': {b -> ale#Var(b, 'solidity_solc_executable')},
\ 'command': function('ale_linters#solidity#solc#GetCommand'),
\ 'callback': 'ale_linters#solidity#solc#Handle',
\ 'output_stream': 'stderr',