mirror of https://github.com/dense-analysis/ale
cairo support (#4256)
* cairo support * supported languages txt * add cairo to ale.txt
This commit is contained in:
parent
5ef26c32da
commit
0ea53870b6
|
@ -0,0 +1,37 @@
|
|||
" Author: 0xHyoga <0xHyoga@gmx.com>
|
||||
" Description: Report starknet-compile errors in cairo code
|
||||
|
||||
call ale#Set('cairo_starknet_executable', 'starknet-compile')
|
||||
call ale#Set('cairo_starknet_options', '')
|
||||
|
||||
function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
|
||||
" Error always on the first line
|
||||
" e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
|
||||
let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': str2nr(l:match[1]),
|
||||
\ 'col': str2nr(l:match[2]),
|
||||
\ 'type': 'E',
|
||||
\ 'text': l:match[3],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cairo#starknet#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
|
||||
|
||||
return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cairo', {
|
||||
\ 'name': 'starknet',
|
||||
\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
|
||||
\ 'command': function('ale_linters#cairo#starknet#GetCommand'),
|
||||
\ 'callback': 'ale_linters#cairo#starknet#Handle',
|
||||
\ 'output_stream': 'stderr',
|
||||
\})
|
|
@ -0,0 +1,15 @@
|
|||
===============================================================================
|
||||
ALE Cairo Integration *ale-cairo-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
starknet *ale-cairo-starknet*
|
||||
|
||||
g:ale_cairo_starknet_executable *g:ale_cairo_starknet_executable*
|
||||
*b:ale_cairo_starknet_executable*
|
||||
|
||||
Default: `'starknet-compile'`
|
||||
|
||||
Overrides the starknet-compile binary after installing the cairo-language.
|
||||
|
||||
For more information read 'https://starknet.io/docs/quickstart.html'
|
|
@ -95,6 +95,8 @@ Notes:
|
|||
* `flawfinder`
|
||||
* `gcc` (`cc`)
|
||||
* `uncrustify`
|
||||
* Cairo
|
||||
* `starknet`
|
||||
* Chef
|
||||
* `cookstyle`
|
||||
* `foodcritic`!!
|
||||
|
|
|
@ -2775,6 +2775,8 @@ documented in additional help files.
|
|||
cspell................................|ale-c-cspell|
|
||||
flawfinder............................|ale-c-flawfinder|
|
||||
uncrustify............................|ale-c-uncrustify|
|
||||
cairo...................................|ale-cairo-options|
|
||||
starknet..............................|ale-cairo-starknet|
|
||||
chef....................................|ale-chef-options|
|
||||
cookstyle.............................|ale-chef-cookstyle|
|
||||
foodcritic............................|ale-chef-foodcritic|
|
||||
|
|
|
@ -104,6 +104,8 @@ formatting.
|
|||
* [flawfinder](https://www.dwheeler.com/flawfinder/)
|
||||
* [gcc](https://gcc.gnu.org/)
|
||||
* [uncrustify](https://github.com/uncrustify/uncrustify)
|
||||
* Cairo
|
||||
* [starknet](https://starknet.io/docs)
|
||||
* Chef
|
||||
* [cookstyle](https://docs.chef.io/cookstyle.html)
|
||||
* [foodcritic](http://www.foodcritic.io/) :floppy_disk:
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
Before:
|
||||
runtime ale_linters/cairo/starknet.vim
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The starknet handler should handle error messages correctly):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 6,
|
||||
\ 'text': 'Could not find module "starkware.cairo.commo.cairo_builtins". Searched in the following paths:',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#cairo#starknet#Handle(bufnr(''), [
|
||||
\ 'contract.cairo:3:6: Could not find module "starkware.cairo.commo.cairo_builtins". Searched in the following paths:',
|
||||
\ 'from starkware.cairo.commo.cairo_builtins import HashBuiltin',
|
||||
\ ' ^**********************************^',
|
||||
\ ])
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 21,
|
||||
\ 'col': 2,
|
||||
\ 'text': 'Unsupported decorator: "vie".',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#cairo#starknet#Handle(bufnr(''), [
|
||||
\ 'contract.cairo:21:2: Unsupported decorator: "vie".',
|
||||
\ '@vie',
|
||||
\ ' ^*^',
|
||||
\ ])
|
|
@ -0,0 +1,13 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('cairo', 'starknet')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'starknet-compile', 'starknet-compile %s'
|
||||
|
||||
Execute(Extra options should be supported):
|
||||
let g:ale_cairo_starknet_options = '--config'
|
||||
|
||||
AssertLinter 'starknet-compile', 'starknet-compile --config %s'
|
Loading…
Reference in New Issue