Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project wide LSP problems should not appear in the current buffer. #2521

Closed
hsanson opened this issue May 21, 2019 · 2 comments
Closed

Project wide LSP problems should not appear in the current buffer. #2521

hsanson opened this issue May 21, 2019 · 2 comments
Labels

Comments

@hsanson
Copy link
Contributor

hsanson commented May 21, 2019

Using eclipselsp linter in a very small project we can see the following communication between ALE and the LSP:

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/ryujin/Projects/gradle-simple/src/main/java/Hello.java","diagnostics":[{"range":{"start":{"line":9,"character":18},"end":{"line":9,"character":33}},"severity":1,"code":"33554506","source":"Java","message":"Cannot make a static reference to the non-static field World.WORLD_STR"}]}}'
  9.377725 : looking for messages on channels
  9.377753 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.378889 RECV on 1: 'Content-Length: 123

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2019/05/21 13:11:07 Validated 1. Took 286 ms"}}'
  9.394634 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.396934 RECV on 1: 'Content-Length: 131

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2019/05/21 13:11:07 \u003e\u003e build jobs finished"}}'
  9.408564 : looking for messages on channels
  9.409045 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.410353 RECV on 1: 'Content-Length: 419

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/ryujin/Projects/gradle-simple","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"severity":2,"code":"0","source":"Java","message":"Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment. "}]}}'
  9.410358 : looking for messages on channels
  9.410382 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.413103 RECV on 1: 'Content-Length: 343

{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/ryujin/Projects/gradle-simple/src/main/java/World.java","diagnostics":[{"range":{"start":{"line":2,"character":7},"end":{"line":2,"character":24}},"severity":2,"code":"268435844","source":"Java","message":"The import java.util.HashSet is never used"}]}}Content-Length: 171

The fourth entry in the list of problems shows a project-wide error regarding missing JRE installation. The uri does not match the current buffer file Hello.java, instead it is the project root path "uri":"file:///home/username/Projects/gradle-simple".

This error appears in the current buffer in line 0, column 0 which makes no sense. Even worse, all other errors that do belong to the file in the current buffer are not shown.

By contrast, in VSCode, the project-wide error regarding JRE is shown in the log window of the editor while the other errors are shown correctly in the editor buffer.

These project-wide errors should better be shown in the ALEInfo output instead of the buffer. Maybe checking if the "uri" parameter matches the current buffer or the project root is a way to determine if the error should be shown in the ALEInfo output or the buffer.

In addition the ecipselsp provides a lot of log information as below:

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2019/05/21 13:11:07 1 problems reported for /Hello.java"}}'
  9.369829 : looking for messages on channels
  9.369839 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.377717 RECV on 1: 'Content-Length: 371

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2019/05/21 13:11:07 Validated 1. Took 286 ms"}}'
  9.394634 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.396934 RECV on 1: 'Content-Length: 131

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2019/05/21 13:11:07 \u003e\u003e build jobs finished"}}'
  9.408564 : looking for messages on channels
  9.409045 on 1: Invoking channel callback <SNR>95_VimOutputCallback
  9.410353 RECV on 1: 'Content-Length: 419

Maybe showing these messages in the output of ALEInfo can be beneficial. These messages allowed me to find the problem and fix #2520 .

@w0rp
Copy link
Member

w0rp commented May 21, 2019

I plan to eventually add logging of all messages. See #2137.

I'm not sure why diagnostics wouldn't appear or would appear in the wrong place. That shouldn't happen. Have a look at s:HandleLSPDiagnostics in autoload/ale/lsp_linter.vim and see if you can find out what's going wrong there.

@w0rp w0rp added triage bug and removed triage labels May 21, 2019
@w0rp
Copy link
Member

w0rp commented May 24, 2019

Fixed in #2524.

@w0rp w0rp closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants