LanguageClient icon indicating copy to clipboard operation
LanguageClient copied to clipboard

Xcode 16 - Diagnostics request

Open steprescott opened this issue 1 year ago • 11 comments

When setting xcode-select to Xcode 15.4 and request a diagnostics on a document it successfully decodes and items are returned. However When using Xcode 16 the items array is empty. I have turned on SOURCEKIT_LOGGING=3 to see a bit more of what is going on within sourcekit-lsp and it seems to be able to report an error as expected.

I wasn't able to track down an decoding issue as the data seen in the response also shows no items.

image

steprescott avatar Sep 25 '24 16:09 steprescott

Example project seen at https://github.com/user-attachments/files/17016358/Example.zip can be used to replicate this. By switching between 15.4 and 16 can replicate this.

steprescott avatar Sep 25 '24 17:09 steprescott

Ok, great debugging! This is almost certainly failing to decode within https://github.com/ChimeHQ/LanguageServerProtocol. We should be able to use this to figure how what's wrong, capture the issue in a test and the fix there.

mattmassicotte avatar Sep 25 '24 17:09 mattmassicotte

Sure. I'll look into that tomorrow morning. Thanks for pointing me in the right direction.

steprescott avatar Sep 25 '24 20:09 steprescott

Ah, no need to create a new issue, at least now yet. But what would be great is if we could capture the actual JSON-RPC going back and forth. If this is a decoding issue, which I suspect, that's what we need.

Of course, now I need to remember how to do that... I think its possible to hook into the underlying DataChannel to watch traffic going back and forth.

mattmassicotte avatar Sep 25 '24 20:09 mattmassicotte

I'm not sure I am reading the data at the right location as the raw data, before decoding, still has no items.

I'm in JSONRPCSession.swift.

image

steprescott avatar Sep 26 '24 15:09 steprescott

Huh. I think you are.

I also double-checked that the model matching the spec. Sometimes this can be an issue, like with a missing optional. But I didn't find anything.

Now this is looking like maybe the language server is actually sending an empty array?

mattmassicotte avatar Sep 26 '24 16:09 mattmassicotte

Very strange. I can see the post diagnostic from lsp.

steprescott avatar Sep 26 '24 17:09 steprescott

Where can you see it?

mattmassicotte avatar Sep 26 '24 18:09 mattmassicotte

In the screenshots when I gave the log level for sourcekit-lsp set to 3 I can see that it does know there is an error after the diagnostics.

steprescott avatar Sep 26 '24 20:09 steprescott

Ahh ok. So yes, the system seems to want to produce a diagnostic. But does it correctly encode it over the JSON-RPC connection? Maybe we need to check VS code or another LSP client to verify.

mattmassicotte avatar Sep 26 '24 21:09 mattmassicotte

I've not tried setting up VS for Swift but will give that a try too.

steprescott avatar Sep 26 '24 22:09 steprescott