summaryrefslogtreecommitdiff
path: root/ale_linters/solidity/solc.vim
diff options
context:
space:
mode:
authorKarl Bartel <karl42@gmail.com>2019-09-19 20:40:00 +0200
committerw0rp <w0rp@users.noreply.github.com>2019-09-19 19:40:00 +0100
commitdc42c0f948d378557894fa09160d231b795dfca4 (patch)
tree24272669afde852252d220d912a178d410467a23 /ale_linters/solidity/solc.vim
parent41ed10be4e67c1daf2772d8d59ad338d6d43ce90 (diff)
downloadale-dc42c0f948d378557894fa09160d231b795dfca4.zip
Add support for `solc` Solidity compiler (#2648)
* Add support for `solc` Solidity compiler * Set default value for `solidity_solc_options` * Add test for solc handler
Diffstat (limited to 'ale_linters/solidity/solc.vim')
-rw-r--r--ale_linters/solidity/solc.vim35
1 files changed, 35 insertions, 0 deletions
diff --git a/ale_linters/solidity/solc.vim b/ale_linters/solidity/solc.vim
new file mode 100644
index 00000000..e4f220ac
--- /dev/null
+++ b/ale_linters/solidity/solc.vim
@@ -0,0 +1,35 @@
+" Author: Karl Bartel <karl42@gmail.com> - http://karl.berlin/
+" Description: Report solc compiler errors in Solidity code
+
+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): (.*)$'
+ 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',
+ \})
+ 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'
+endfunction
+
+call ale#linter#Define('solidity', {
+\ 'name': 'solc',
+\ 'executable': 'solc',
+\ 'command': function('ale_linters#solidity#solc#GetCommand'),
+\ 'callback': 'ale_linters#solidity#solc#Handle',
+\ 'output_stream': 'stderr',
+\})