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

Provide FileOperationRegistrationOptions class #826

Closed
angelozerr opened this issue Apr 6, 2024 · 4 comments
Closed

Provide FileOperationRegistrationOptions class #826

angelozerr opened this issue Apr 6, 2024 · 4 comments

Comments

@angelozerr
Copy link

The LSP specification defines the FileOperationRegistrationOptions which is helpful to support dynamic registration for file operations.

It would be nice if LSP4J could provide it.

Thanks!

@pisv
Copy link
Contributor

pisv commented Apr 6, 2024

Looks like LSP4J already provides it:

/**
* The options for file operations.
* <p>
* Since 3.16.0
*/
@JsonRpcData
class FileOperationOptions {
/**
* The actual filters.
*/
@NonNull
List<FileOperationFilter> filters = new ArrayList
new() {
}
new(@NonNull List<FileOperationFilter> filters) {
this.filters = Preconditions.checkNotNull(filters, 'filters')
}
}

@angelozerr
Copy link
Author

Thanks @pisv!

I wonder why FileOperationOptions name is used instead of FileOperationRegistrationOptions which respects the spec?

@pisv
Copy link
Contributor

pisv commented Apr 8, 2024

I wonder why FileOperationOptions name is used instead of FileOperationRegistrationOptions which respects the spec?

Good question :-)

The following is my educated guess...

There are some inconsistencies regarding registration options in the spec. But usually there is a basic *Options interface, and there is a corresponding *RegistrationOptions interface the extends the basic *Options interface and also extends StaticRegistrationOptions and/or TextDocumentRegistrationOptions.

For example, there is SemanticTokensOptions, and there is SemanticTokensRegistrationOptions, which extends SemanticTokensOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions.

The corresponding server capability semanticTokensProvider is typed as SemanticTokensOptions | SemanticTokensRegistrationOptions to allow for static registration of SemanticTokensRegistrationOptions in response to the initialize request.

SemanticTokensRegistrationOptions can also be used for dynamic registration of the textDocument/semanticTokens feature via the client/registerCapability request.

Clearly, FileOperationRegistrationOptions does not match this pattern. According to the spec, there are no dynamic registration options supported for WillCreateFiles and similar requests/notifications. There is no FileOperationOptions that FileOperationRegistrationOptions would extend, and FileOperationRegistrationOptions also does not extend StaticRegistrationOptions.

So, despite its name, FileOperationRegistrationOptions has nothing to do with static or dynamic registration options, as it now stands.

Also, while type names don't mean much in TypeScript with its structural typing, changing a type name in Java would be a breaking change.

Therefore, I guess it was decided to reserve the name FileOperationRegistrationOptions in LSP4J to be able to differentiate between FileOperationOptions and FileOperationRegistrationOptions according to the usual pattern for registration options, when/if such a need arises.

@jonahgraham
Copy link
Contributor

Thank you @pisv for providing such a detailed analysis. I don't think there is anything left to do here so I am closing this issue. Please comment/reopen if I have missed something.

@jonahgraham jonahgraham closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
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

No branches or pull requests

3 participants