Skip to content

Breaking: Registration Options require Client Capability during creation #440

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 31 commits into from
Nov 29, 2020

Conversation

david-driscoll
Copy link
Member

Registration Changes

The 3.16 specification defines the SemanticLegend in such a way that the client produces a list of supported tokens and the server must return the tokens it supports and the index order it will use.

Today we get the registration options at registration of a handler, but this is typically before we have started communicating with the server.

This change adds a new interface IRegistrationOptions<TOptions, TCapability> and all interfaces have been updated to implement this interface if they have both a client capability and a server registration option.

Abstract Handlers Registration Options

The abstract base classes by the above change now have a new method that must be implemented.

protected internal abstract TRegistrationOptions CreateRegistrationOptions(TCapability capability);

The base handler then caches the resulting value so this method is only ever called once.

Existing implementations of GetRegistrationOptions can be replaced with CreateRegistrationOptions.

Abstract Handlers

All the abstract handler base classes have been renamed to have a Suffix of "Base" if there was not one there before.

The fix for this is simply to make sure the Base suffix has been applied.

Feature Specific Files

This is not a breaking change, the goal was to make sure that namespaces did not change, if there is a miss let me know.

Any classes related to the Request, Response, Capability and Registration Options have been moved into a XyzFeature.cs file. This will help reduce the number of overall files in the repo, as well as hopefully with discoverabiliy. More importantly this make it easier to create new features, as all the components for a given feature will be in the same file.

TextDocumentSyncRegistrationOptions Added

The IDidXyzTextDocument handlers have been updated to have specific named options, and a master options class TextDocumentSyncRegistrationOptions has been added. You provide the TextDocumentSyncRegistrationOptions and all the other named options can be implicitly created from it.

Source Generation

Source Generation has been refactored to be a little more flexible and better organized (it's not prefect but better).

Some documentation has been added to document the attributes and their usage. These should available to consumers to also use themselves, please let me know of any bugs you might encounter with them.

@github-actions github-actions bot added this to the v0.18.4 milestone Nov 25, 2020
@david-driscoll
Copy link
Member Author

Docs link for this PR: (The above description will be rolled into the release notes).

https://github.com/OmniSharp/csharp-language-server-protocol/blob/feature/2-registration-options/docs/source-generation.md

@david-driscoll david-driscoll added the breaking change This breaks existing behavior label Nov 25, 2020
@codecov
Copy link

codecov bot commented Nov 25, 2020

Codecov Report

Merging #440 (5f62e5a) into master (2b60c71) will decrease coverage by 7.62%.
The diff coverage is 52.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #440      +/-   ##
==========================================
- Coverage   78.17%   70.54%   -7.63%     
==========================================
  Files         237      259      +22     
  Lines        8647    10916    +2269     
  Branches      634      772     +138     
==========================================
+ Hits         6760     7701     +941     
- Misses       1887     3215    +1328     
Impacted Files Coverage Δ
src/Client/LanguageClient.cs 97.22% <ø> (ø)
...rc/Client/LanguageClientWorkspaceFoldersManager.cs 92.42% <ø> (ø)
src/JsonRpc.Generators/Contexts/DapAttributes.cs 0.00% <0.00%> (ø)
...thodGeneratorWithoutRegistrationOptionsStrategy.cs 0.00% <0.00%> (ø)
src/JsonRpc.Testing/JsonRpcTestOptions.cs 25.00% <0.00%> (ø)
src/JsonRpc/CancelParams.cs 100.00% <ø> (ø)
src/JsonRpc/Generation/GenerateHandlerAttribute.cs 0.00% <0.00%> (ø)
...nRpc/Generation/GenerateHandlerMethodsAttribute.cs 0.00% <ø> (ø)
...eMethodGeneratorWithRegistrationOptionsStrategy.cs 1.85% <1.85%> (ø)
...ators/Strategies/TypedDelegatingHandlerStrategy.cs 3.12% <3.12%> (ø)
... and 64 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b60c71...3289b70. Read the comment docs.

@david-driscoll david-driscoll force-pushed the feature/2-registration-options branch from b6ee7b1 to 2c2589b Compare November 26, 2020 21:14
… this but 3 second intellisense times are unbearable
@david-driscoll david-driscoll force-pushed the feature/2-registration-options branch from 2c2589b to dacd031 Compare November 26, 2020 21:15
@david-driscoll david-driscoll merged commit 9f5f49f into master Nov 29, 2020
@david-driscoll david-driscoll deleted the feature/2-registration-options branch November 29, 2020 18:39
@github-actions github-actions bot modified the milestones: v0.18.4, v0.19.0 Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This breaks existing behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant