summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-20 16:42:43 +0000
committerw0rp <devw0rp@gmail.com>2017-11-20 18:54:57 +0000
commitc9e203e6204314b55aed76c49f57aaf8ab826c90 (patch)
tree1b42e5306429ef6015558f1f626a66cf0e2cbee2 /ale_linters
parentf20e5a4cf0e56c3c89ef7be4730924be377e5f61 (diff)
downloadale-c9e203e6204314b55aed76c49f57aaf8ab826c90.zip
Fix #859 Include test and jaxb Java source paths when available
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/java/javac.vim26
1 files changed, 25 insertions, 1 deletions
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index f7da560b..73e84147 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -41,9 +41,33 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths) abort
" Find the src directory, for files in this project.
let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java')
+ let l:sp_dirs = []
if !empty(l:src_dir)
- let l:sp_option = '-sourcepath ' . ale#Escape(l:src_dir)
+ call add(l:sp_dirs, l:src_dir)
+
+ " Automatically include the jaxb directory too, if it's there.
+ let l:jaxb_dir = fnamemodify(l:src_dir, ':h:h')
+ \ . (has('win32') ? '\jaxb\' : '/jaxb/')
+
+ if isdirectory(l:jaxb_dir)
+ call add(l:sp_dirs, l:jaxb_dir)
+ endif
+
+ " Automatically include the test directory, but only for test code.
+ if expand('#' . a:buffer . ':p') =~? '\vsrc[/\\]test[/\\]java'
+ let l:test_dir = fnamemodify(l:src_dir, ':h:h:h')
+ \ . (has('win32') ? '\test\java\' : '/test/java/')
+
+ if isdirectory(l:test_dir)
+ call add(l:sp_dirs, l:test_dir)
+ endif
+ endif
+ endif
+
+ if !empty(l:sp_dirs)
+ let l:sp_option = '-sourcepath '
+ \ . ale#Escape(join(l:sp_dirs, s:classpath_sep))
endif
" Create .class files in a temporary directory, which we will delete later.