Skip to content

Fix language server not working with the latest beta #153

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

Merged
merged 2 commits into from
Jul 18, 2019

Conversation

david-driscoll
Copy link
Member

@david-driscoll david-driscoll commented Jul 18, 2019

This contains two fixes.

  1. Fixed the problem where requests were not being routed correctly.
  2. Adds an example folding range, to ensure that it works.
    2019-07-18_10-57-10

Also I've done a small refactor around ITextDocumentIdentifier previously this was only integrated in ITextDocumentSyncHandler, if you didn't register a ITextDocumentSyncHandler we would never catch any file registrations, because we would have way to identify a file.

I have left ITextDocumentIdentifier as a member of the ITextDocumentSyncHandler interface but I have added the ability to add your own ITextDocumentIdentifier instances, which will then be used when trying to identify files by Uri.

@david-driscoll david-driscoll changed the title Fix/folding not working Fix language server not working with the latest beta Jul 18, 2019
private readonly IEnumerable<IHandlerMatcher> _handlerMatchers;

public LspRequestRouter(
IEnumerable<ILspHandlerDescriptor> collection,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was why descriptors could not be found with the latest beta... I need to add an integration test with the LanguageServer for this at somepoint.

CancellationToken cancellationToken)
{
return Task.FromResult(new Container<FoldingRange>(new FoldingRange() {
StartLine = 10,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the folding range in the gif attached.

@david-driscoll
Copy link
Member Author

cc @mholo65 @TylerLeonhardt @tintoy

@david-driscoll
Copy link
Member Author

Here are a few logs reference, you should see folding range in there.

Initialize should not return any static features

[Trace - 10:53:38 AM] Received response 'initialize - (0)' in 3991ms.
Result: {
    "capabilities": {
        "textDocumentSync": 0,
        "hoverProvider": false,
        "definitionProvider": false,
        "referencesProvider": false,
        "documentHighlightProvider": false,
        "documentSymbolProvider": false,
        "workspaceSymbolProvider": false,
        "documentFormattingProvider": false,
        "documentRangeFormattingProvider": false,
        "experimental": {}
    }
}

Registration (this should contain the folding range registration)

[Info  - 10:53:39 AM] Converting params for Notification initialized to OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializedParams
[Trace - 10:53:39 AM] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "fa8256a9-3f00-410f-b940-d7aee4303371",
            "method": "textDocument/didChange",
            "registerOptions": {
                "syncKind": 1,
                "documentSelector": [
                    {
                        "pattern": "**/*.cs"
                    }
                ]
            }
        },
        {
            "id": "aa17d766-aeb5-4fd5-999d-1ef9f23e54bd",
            "method": "textDocument/didOpen",
            "registerOptions": {
                "documentSelector": [
                    {
                        "pattern": "**/*.cs"
                    }
                ]
            }
        },
        {
            "id": "6bb59ea1-11ca-4b49-8317-5f77baa62d05",
            "method": "textDocument/didClose",
            "registerOptions": {
                "documentSelector": [
                    {
                        "pattern": "**/*.cs"
                    }
                ]
            }
        },
        {
            "id": "4c884630-fa8e-4e30-8449-68230c54da52",
            "method": "textDocument/didSave",
            "registerOptions": {
                "includeText": true,
                "documentSelector": [
                    {
                        "pattern": "**/*.cs"
                    }
                ]
            }
        },
        {
            "id": "8fff9ed8-80e4-49d3-ae81-eef813b91a8c",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {}
        },
        {
            "id": "972a811e-4df5-4bcc-943f-e86345d08d37",
            "method": "textDocument/foldingRange",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "csharp"
                    }
                ]
            }
        }
    ]
}

then you should see some folding range content in the logs later


[Info  - 10:53:50 AM] Handler Selected: SampleServer.FoldingRangeHandler via (null) (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRangeRequestParam, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]], OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Trace - 10:53:50 AM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Starting: Routing Request (2) textDocument/foldingRange"
}


[Info  - 10:53:50 AM] Starting: Routing Request (2) textDocument/foldingRange
[Trace - 10:53:50 AM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Converting params for Request (2) textDocument/foldingRange to OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRangeRequestParam"
}


[Info  - 10:53:50 AM] Converting params for Request (2) textDocument/foldingRange to OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRangeRequestParam
[Trace - 10:53:50 AM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]], OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"
}


[Info  - 10:53:50 AM] Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]], OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
[Trace - 10:53:50 AM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"
}


[Info  - 10:53:50 AM] Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.0.9.9, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
[Trace - 10:53:50 AM] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Finished: Routing Request (2) textDocument/foldingRange in 0ms"
}


[Info  - 10:53:50 AM] Finished: Routing Request (2) textDocument/foldingRange in 0ms
[Trace - 10:53:50 AM] Received response 'textDocument/foldingRange - (2)' in 4ms.
Result: [
    {
        "startLine": 10,
        "startCharacter": 0,
        "endLine": 20,
        "endCharacter": 0,
        "kind": 2
    }
]

@TylerLeonhardt
Copy link
Collaborator

💯👌 Nice!

@david-driscoll david-driscoll merged commit af789e0 into master Jul 18, 2019
@david-driscoll david-driscoll deleted the fix/folding-not-working branch July 18, 2019 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants