summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--ale_linters/ispc/ispc.vim45
-rw-r--r--doc/ale-ispc.txt24
-rw-r--r--doc/ale.txt3
-rw-r--r--test/command_callback/test_ispc_ispc_command_callbacks.vader20
-rw-r--r--test/handler/test_ispc_ispc_handler.vader90
6 files changed, 183 insertions, 0 deletions
diff --git a/README.md b/README.md
index 976742ae..4136ae81 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,7 @@ formatting.
| HCL | [terraform-fmt](https://github.com/hashicorp/terraform) |
| HTML | [alex](https://github.com/wooorm/alex) !!, [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/), [prettier](https://github.com/prettier/prettier), [write-good](https://github.com/btford/write-good) |
| Idris | [idris](http://www.idris-lang.org/) |
+| ISPC | [ispc](https://ispc.github.io/) !! |
| Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html), [google-java-format](https://github.com/google/google-java-format), [PMD](https://pmd.github.io/), [javalsp](https://github.com/georgewfraser/vscode-javac), [uncrustify](https://github.com/uncrustify/uncrustify) |
| JavaScript | [eslint](http://eslint.org/), [flow](https://flowtype.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/), [prettier](https://github.com/prettier/prettier), [prettier-eslint](https://github.com/prettier/prettier-eslint-cli), [prettier-standard](https://github.com/sheerun/prettier-standard), [standard](http://standardjs.com/), [xo](https://github.com/sindresorhus/xo)
| JSON | [fixjson](https://github.com/rhysd/fixjson), [jsonlint](http://zaa.ch/jsonlint/), [jq](https://stedolan.github.io/jq/), [prettier](https://github.com/prettier/prettier) |
diff --git a/ale_linters/ispc/ispc.vim b/ale_linters/ispc/ispc.vim
new file mode 100644
index 00000000..de7ceafa
--- /dev/null
+++ b/ale_linters/ispc/ispc.vim
@@ -0,0 +1,45 @@
+" Author: Martino Pilia <martino.pilia@gmail.com>
+" Description: Lint ispc files with the Intel(R) SPMD Program Compiler
+
+call ale#Set('ispc_ispc_executable', 'ispc')
+call ale#Set('ispc_ispc_options', '')
+
+function! ale_linters#ispc#ispc#GetCommand(buffer) abort
+ " --nowrap: do not wrap message lines
+ return '%e --nowrap'
+ \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)))
+ \ . ale#Pad(ale#Var(a:buffer, 'ispc_ispc_options'))
+ \ . ' %s'
+endfunction
+
+" Note that we ignore the two warnings in the beginning of the compiler output
+" ('no output file specified' and 'no --target specified'), since they have
+" nothing to do with linting.
+function! ale_linters#ispc#ispc#Handle(buffer, lines) abort
+ " Message format: <filename>:<lnum>:<col> <type>: <text>
+ " As far as I know, <type> can be any of:
+ " 'error', 'Error', 'fatal error', 'Warning', 'Performance Warning'
+ let l:re = '\v.+:([0-9]+):([0-9]+):\s+([^:]+):\s+(.+)'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:re)
+ call add(l:output, {
+ \ 'bufnr': a:buffer,
+ \ 'lnum': str2nr(l:match[1]),
+ \ 'col': str2nr(l:match[2]),
+ \ 'type': l:match[3] =~? 'error' ? 'E' : 'W',
+ \ 'text': l:match[4],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('ispc', {
+\ 'name': 'ispc',
+\ 'output_stream': 'stderr',
+\ 'executable_callback': ale#VarFunc('ispc_ispc_executable'),
+\ 'command_callback': 'ale_linters#ispc#ispc#GetCommand',
+\ 'callback': 'ale_linters#ispc#ispc#Handle',
+\ 'lint_file': 1,
+\})
diff --git a/doc/ale-ispc.txt b/doc/ale-ispc.txt
new file mode 100644
index 00000000..bf30e8e3
--- /dev/null
+++ b/doc/ale-ispc.txt
@@ -0,0 +1,24 @@
+===============================================================================
+ALE ISPC Integration *ale-ispc-options*
+
+
+===============================================================================
+ispc *ale-ispc-ispc*
+
+g:ale_ispc_ispc_executable *g:ale_ispc_ispc_executable*
+ *b:ale_ispc_ispc_executable*
+ Type: |String|
+ Default: `'ispc'`
+
+ This variable can be changed to use a different executable for ispc.
+
+
+g:ale_ispc_ispc_options *g:ale_ispc_ispc_options*
+ *b:ale_ispc_ispc_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be changed to modify flags given to ispc.
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index d438f70f..1a37f73f 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -147,6 +147,8 @@ CONTENTS *ale-contents*
write-good..........................|ale-html-write-good|
idris.................................|ale-idris-options|
idris...............................|ale-idris-idris|
+ ispc..................................|ale-ispc-options|
+ ispc................................|ale-ispc-ispc|
java..................................|ale-java-options|
checkstyle..........................|ale-java-checkstyle|
javac...............................|ale-java-javac|
@@ -438,6 +440,7 @@ Notes:
* HCL: `terraform-fmt`
* HTML: `alex`!!, `HTMLHint`, `proselint`, `tidy`, `prettier`, `write-good`
* Idris: `idris`
+* ISPC: `ispc`!!
* Java: `checkstyle`, `javac`, `google-java-format`, `PMD`, `javalsp`, `uncrustify`
* JavaScript: `eslint`, `flow`, `jscs`, `jshint`, `prettier`, `prettier-eslint`, `prettier-standard`, `standard`, `xo`
* JSON: `fixjson`, `jsonlint`, `jq`, `prettier`
diff --git a/test/command_callback/test_ispc_ispc_command_callbacks.vader b/test/command_callback/test_ispc_ispc_command_callbacks.vader
new file mode 100644
index 00000000..f1aeb2f8
--- /dev/null
+++ b/test/command_callback/test_ispc_ispc_command_callbacks.vader
@@ -0,0 +1,20 @@
+Before:
+ call ale#assert#SetUpLinterTest('ispc', 'ispc')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The executable should be configurable):
+ AssertLinter 'ispc',
+ \ ale#Escape('ispc') . ' --nowrap %s'
+
+ let b:ale_ispc_ispc_executable = 'foo'
+
+ AssertLinter 'foo',
+ \ ale#Escape('foo') . ' --nowrap %s'
+
+Execute(The options should be configurable):
+ let g:ale_ispc_ispc_options = '--foo'
+
+ AssertLinter 'ispc',
+ \ ale#Escape('ispc') . ' --nowrap --foo' . ' %s'
diff --git a/test/handler/test_ispc_ispc_handler.vader b/test/handler/test_ispc_ispc_handler.vader
new file mode 100644
index 00000000..619773fe
--- /dev/null
+++ b/test/handler/test_ispc_ispc_handler.vader
@@ -0,0 +1,90 @@
+Before:
+ runtime ale_linters/ispc/ispc.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The ispc handler should parse input correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 33,
+ \ 'col': 14,
+ \ 'type': 'E',
+ \ 'text': 'syntax error, unexpected ''int'', expecting '','' or '';''.',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 36,
+ \ 'col': 5,
+ \ 'type': 'E',
+ \ 'text': 'syntax error, unexpected ''for''.',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 51,
+ \ 'col': 9,
+ \ 'type': 'E',
+ \ 'text': '''foobar.h'' file not found',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 79,
+ \ 'col': 52,
+ \ 'type': 'W',
+ \ 'text': 'Modulus operator with varying types is very inefficient.',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 85,
+ \ 'col': 13,
+ \ 'type': 'W',
+ \ 'text': 'Undefined behavior: all program instances are writing to the same location!',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 93,
+ \ 'col': 19,
+ \ 'type': 'W',
+ \ 'text': 'Gather required to load value.',
+ \ },
+ \ {
+ \ 'bufnr': 0,
+ \ 'lnum': 93,
+ \ 'col': 9,
+ \ 'type': 'W',
+ \ 'text': 'Scatter required to store value.',
+ \ },
+ \ ],
+ \ ale_linters#ispc#ispc#Handle(0, [
+ \ 'Warning: No output file or header file name specified. Program will be compiled and warnings/errors will be issued, but no output will be generated. ',
+ \ 'Warning: No --target specified on command-line. Using default system target "avx2-i32x8".',
+ \ 'mandelbrot.ispc:33:14: Error: syntax error, unexpected ''int'', expecting '','' or '';''.',
+ \ 'static iline int mandel(float c_re, float c_im, int count) {',
+ \ ' ^^^',
+ \ '',
+ \ 'mandelbrot.ispc:36:5: Error: syntax error, unexpected ''for''.',
+ \ ' for (i = 0; i < count; ++i) {',
+ \ ' ^^^',
+ \ '',
+ \ 'mandelbrot.ispc:51:9: fatal error: ''foobar.h'' file not found',
+ \ '#include<foobar.h>',
+ \ ' ^~~~~~~~~~',
+ \ 'mandelbrot.ispc:79:52: Performance Warning: Modulus operator with varying types is very inefficient.',
+ \ ' double x = x0 + i * (dx + epsilon*(k%2)*delta);',
+ \ ' ^^^',
+ \ '',
+ \ 'mandelbrot.ispc:85:13: Warning: Undefined behavior: all program instances are writing to the same location!',
+ \ ' output[index] = (NNN) / sample_size;',
+ \ ' ^^^^^^^^^^^^^',
+ \ '',
+ \ 'mandelbrot.ispc:93:19: Performance Warning: Gather required to load value.',
+ \ ' A[i*8] *= A[i*8];',
+ \ ' ^^^^^^',
+ \ '',
+ \ 'mandelbrot.ispc:93:9: Performance Warning: Scatter required to store value.',
+ \ ' A[i*8] *= A[i*8];',
+ \ ' ^^^^^^',
+ \ '',
+ \ ])