From 5ce97f8cdb285b86a4891fde6dcd14283bc2756f Mon Sep 17 00:00:00 2001 From: Horacio Sanson Date: Wed, 5 Jun 2019 00:31:56 +0900 Subject: [PATCH 1/2] Fix javalsp command callback. The command used to invoke the language server is missing some options to include additional java modules. Without these modules the server was not working properly. The correct command can be found in a `launcher` script on the same directory the `java` executable for the language server is found. This commit changes the docs to prefer the launcher script over the java executable. For backward compatibility it also fixes the command invocation in case the java executable is configured. --- ale_linters/java/javalsp.vim | 22 +++++++++++++++++-- doc/ale-java.txt | 11 ++++++---- .../test_javalsp_command_callback.vader | 21 ++++++++++++++++-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim index a327363d..eea3f48b 100644 --- a/ale_linters/java/javalsp.vim +++ b/ale_linters/java/javalsp.vim @@ -1,7 +1,7 @@ " Author: Horacio Sanson " Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac -call ale#Set('java_javalsp_executable', 'java') +call ale#Set('java_javalsp_executable', 'launcher') function! ale_linters#java#javalsp#Executable(buffer) abort return ale#Var(a:buffer, 'java_javalsp_executable') @@ -10,7 +10,25 @@ endfunction function! ale_linters#java#javalsp#Command(buffer) abort let l:executable = ale_linters#java#javalsp#Executable(a:buffer) - return ale#Escape(l:executable) . ' -Xverify:none -m javacs/org.javacs.Main' + if fnamemodify(l:executable, ':t') is# 'java' + " For backward compatibility. + let l:cmd = [ + \ ale#Escape(l:executable), + \ '--add-exports jdk.compiler/com.sun.tools.javac.api=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.code=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.comp=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.main=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.tree=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.model=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.util=javacs', + \ '--add-opens jdk.compiler/com.sun.tools.javac.api=javacs', + \ '-m javacs/org.javacs.Main', + \] + + return join(l:cmd, ' ') + else + return ale#Escape(l:executable) + endif endfunction call ale#linter#Define('java', { diff --git a/doc/ale-java.txt b/doc/ale-java.txt index 65d2299b..a563f1fb 100644 --- a/doc/ale-java.txt +++ b/doc/ale-java.txt @@ -117,16 +117,19 @@ or This generates a dist/mac or dist/windows directory that contains the language server. To let ALE use this language server you need to set the -g:ale_java_javalsp_executable variable to the absolute path of the java +g:ale_java_javalsp_executable variable to the absolute path of the launcher executable in this directory. g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* *b:ale_java_javalsp_executable* Type: |String| - Default: `'java'` - -This variable can be changed to use a different executable for java. + Default: `'launcher'` +This variable must be set to the absolute path of the language server launcher +executable. For example: +> + let g:ale_java_javalsp_executable=/java-language-server/dist/mac/bin/launcher +< =============================================================================== eclipselsp *ale-java-eclipselsp* diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader index 8bfaa8ee..aaaceb45 100644 --- a/test/command_callback/test_javalsp_command_callback.vader +++ b/test/command_callback/test_javalsp_command_callback.vader @@ -6,9 +6,26 @@ After: call ale#assert#TearDownLinterTest() Execute(The javalsp callback should return the correct default value): - AssertLinter 'java', ale#Escape('java') . ' -Xverify:none -m javacs/org.javacs.Main' + AssertLinter 'launcher', ale#Escape('launcher') Execute(The javalsp java executable should be configurable): let b:ale_java_javalsp_executable = '/bin/foobar' - AssertLinter '/bin/foobar', ale#Escape('/bin/foobar') . ' -Xverify:none -m javacs/org.javacs.Main' + AssertLinter '/bin/foobar', ale#Escape('/bin/foobar') + +Execute(The javalsp callback should return backward compatible value): + let b:ale_java_javalsp_executable = '/bin/java' + let cmd = [ + \ ale#Escape('/bin/java'), + \ '--add-exports jdk.compiler/com.sun.tools.javac.api=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.code=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.comp=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.main=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.tree=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.model=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.util=javacs', + \ '--add-opens jdk.compiler/com.sun.tools.javac.api=javacs', + \ '-m javacs/org.javacs.Main', + \] + AssertLinter '/bin/java', join(cmd, ' ') + From e84c9b300b521134ed3d37b8d59beff8b83ae61e Mon Sep 17 00:00:00 2001 From: Horacio Sanson Date: Sun, 9 Jun 2019 14:02:50 +0900 Subject: [PATCH 2/2] Do not set default binary. The default binary "launcher" is too generic and can get mixed with other tools. To use this linter user must explicitly set the absolute path of the launcher path. --- ale_linters/java/javalsp.vim | 2 +- test/command_callback/test_javalsp_command_callback.vader | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ale_linters/java/javalsp.vim b/ale_linters/java/javalsp.vim index eea3f48b..f56675d6 100644 --- a/ale_linters/java/javalsp.vim +++ b/ale_linters/java/javalsp.vim @@ -1,7 +1,7 @@ " Author: Horacio Sanson " Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac -call ale#Set('java_javalsp_executable', 'launcher') +call ale#Set('java_javalsp_executable', '') function! ale_linters#java#javalsp#Executable(buffer) abort return ale#Var(a:buffer, 'java_javalsp_executable') diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader index aaaceb45..ca7388c0 100644 --- a/test/command_callback/test_javalsp_command_callback.vader +++ b/test/command_callback/test_javalsp_command_callback.vader @@ -6,7 +6,7 @@ After: call ale#assert#TearDownLinterTest() Execute(The javalsp callback should return the correct default value): - AssertLinter 'launcher', ale#Escape('launcher') + AssertLinter '', ale#Escape('') Execute(The javalsp java executable should be configurable): let b:ale_java_javalsp_executable = '/bin/foobar'