To support javaagent on eclipselsp

This commit is contained in:
puritys 2020-03-26 06:40:07 +00:00
parent bbe5153fcb
commit fa19bca80e
3 changed files with 34 additions and 1 deletions

View file

@ -7,6 +7,7 @@ call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls'
call ale#Set('java_eclipselsp_config_path', '') call ale#Set('java_eclipselsp_config_path', '')
call ale#Set('java_eclipselsp_workspace_path', '') call ale#Set('java_eclipselsp_workspace_path', '')
call ale#Set('java_eclipselsp_executable', 'java') call ale#Set('java_eclipselsp_executable', 'java')
call ale#Set('java_eclipselsp_javaagent', '')
function! ale_linters#java#eclipselsp#Executable(buffer) abort function! ale_linters#java#eclipselsp#Executable(buffer) abort
return ale#Var(a:buffer, 'java_eclipselsp_executable') return ale#Var(a:buffer, 'java_eclipselsp_executable')
@ -100,12 +101,28 @@ function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort
return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer)) return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer))
endfunction endfunction
function! ale_linters#java#eclipselsp#Javaagent(buffer) abort
let l:rets = []
let l:raw = ale#Var(a:buffer, 'java_eclipselsp_javaagent')
if empty(l:raw)
return ''
endif
let l:jars = split(l:raw)
for l:jar in l:jars
call add(l:rets, ale#Escape('-javaagent:' . l:jar))
endfor
return join(l:rets, ' ')
endfunction
function! ale_linters#java#eclipselsp#Command(buffer, version) abort function! ale_linters#java#eclipselsp#Command(buffer, version) abort
let l:path = ale#Var(a:buffer, 'java_eclipselsp_path') let l:path = ale#Var(a:buffer, 'java_eclipselsp_path')
let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer)
let l:cmd = [ ale#Escape(l:executable), let l:cmd = [ ale#Escape(l:executable),
\ ale_linters#java#eclipselsp#Javaagent(a:buffer),
\ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Declipse.application=org.eclipse.jdt.ls.core.id1',
\ '-Dosgi.bundles.defaultStartLevel=4', \ '-Dosgi.bundles.defaultStartLevel=4',
\ '-Declipse.product=org.eclipse.jdt.ls.core.product', \ '-Declipse.product=org.eclipse.jdt.ls.core.product',

View file

@ -222,6 +222,17 @@ g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path*
absolute path of the Eclipse workspace. If not set this value will be set to absolute path of the Eclipse workspace. If not set this value will be set to
the parent folder of the project root. the parent folder of the project root.
g:ale_java_eclipselsp_javaagent *g:ale_java_eclipselsp_javaagent*
*b:ale_java_eclipselsp_javaagent*
Type: |String|
Default: `''`
A variable to add java agent for annotation processing such as Lombok.
If you have multiple java agent files, use space to separate them. For example:
>
let g:ale_java_eclipselsp_javaagent='/eclipse/lombok.jar /eclipse/jacoco.jar'
<
=============================================================================== ===============================================================================
uncrustify *ale-java-uncrustify* uncrustify *ale-java-uncrustify*

View file

@ -54,6 +54,7 @@ Execute(VersionCheck should return correct version):
Execute(The eclipselsp callback should return the correct default value): Execute(The eclipselsp callback should return the correct default value):
let cmd = [ ale#Escape('java'), let cmd = [ ale#Escape('java'),
\ '',
\ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Declipse.application=org.eclipse.jdt.ls.core.id1',
\ '-Dosgi.bundles.defaultStartLevel=4', \ '-Dosgi.bundles.defaultStartLevel=4',
\ '-Declipse.product=org.eclipse.jdt.ls.core.product', \ '-Declipse.product=org.eclipse.jdt.ls.core.product',
@ -72,6 +73,7 @@ Execute(The eclipselsp callback should return the correct default value):
Execute(The eclipselsp callback should allow custom executable): Execute(The eclipselsp callback should allow custom executable):
let b:ale_java_eclipselsp_executable='/bin/foobar' let b:ale_java_eclipselsp_executable='/bin/foobar'
let cmd = [ ale#Escape('/bin/foobar'), let cmd = [ ale#Escape('/bin/foobar'),
\ '',
\ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Declipse.application=org.eclipse.jdt.ls.core.id1',
\ '-Dosgi.bundles.defaultStartLevel=4', \ '-Dosgi.bundles.defaultStartLevel=4',
\ '-Declipse.product=org.eclipse.jdt.ls.core.product', \ '-Declipse.product=org.eclipse.jdt.ls.core.product',
@ -87,9 +89,12 @@ Execute(The eclipselsp callback should allow custom executable):
\] \]
AssertLinter '/bin/foobar', join(cmd, ' ') AssertLinter '/bin/foobar', join(cmd, ' ')
Execute(The eclipselsp callback should allow custom configuration path): Execute(The eclipselsp callback should allow custom configuration path and javaagent):
let b:ale_java_eclipselsp_config_path = '/home/config' let b:ale_java_eclipselsp_config_path = '/home/config'
let b:ale_java_eclipselsp_javaagent = '/home/lombok.jar /home/lombok2.jar'
let cmd = [ ale#Escape('java'), let cmd = [ ale#Escape('java'),
\ ale#Escape('-javaagent:/home/lombok.jar'),
\ ale#Escape('-javaagent:/home/lombok2.jar'),
\ '-Declipse.application=org.eclipse.jdt.ls.core.id1', \ '-Declipse.application=org.eclipse.jdt.ls.core.id1',
\ '-Dosgi.bundles.defaultStartLevel=4', \ '-Dosgi.bundles.defaultStartLevel=4',
\ '-Declipse.product=org.eclipse.jdt.ls.core.product', \ '-Declipse.product=org.eclipse.jdt.ls.core.product',