OmniSharp/csharp-language-server-protocol

IntelliJ Support - Gets a Exception in the SemanticTokensHandler.CreateRegistrationOptions

Simonl9l opened this issue · 0 comments

Firstly thanks for maintain this repo, it's a godsend when your underlying DLS tools are implemented in .Net!

It seems that JetBrains now has limited support for LSP Servers based on the IntelliJ platform - albeit the subscription based versions of their tools "ultimate", not community.

Im still very much learning the ropes of the OmniSharp LSP framework, so if Im not connecting dots apologies in advance.

As it stands InteliJ's LSP client implementation does not support syntax highlighting, and my Handler based on SemanticTokensHandlerBase shows an exception when I set up the Legend in the SemanticTokenRegistrationOptions when it tries to access the capability.TokenTypes and capability.TokenModifiers with a System.NullReferenceException.

Am I even doing this correctly, I kinds stole this code from the bicep implementation if I remember?
Is it correct that the InteliJ client should broadcast its capabilities to the LPS server and only supported hander be initialized?
If a client does not do this correctly how do we safely handle these scenarios?

protected override SemanticTokensRegistrationOptions CreateRegistrationOptions(
            SemanticTokensCapability capability, 
            ClientCapabilities clientCapabilities
        )
        {
            return new SemanticTokensRegistrationOptions
            {
                DocumentSelector = TextDocumentSelector.ForLanguage("<my language>"),
                Legend = new SemanticTokensLegend
                {
                    TokenModifiers = capability.TokenModifiers,
                    TokenTypes = capability.TokenTypes
                },
                Full = new SemanticTokensCapabilityRequestFull
                {
                    Delta = false
                },
                Range = true
            };
        }