fix(lsp): support nested workspace registrations #39574

Problem:
Nested workspace capabilities like workspace.fileOperations.didCreate and
workspace.textDocumentContent are not handled consistently for dynamic and
static registration provider lookup.

Solution:
Generate explicit registration-provider mappings from the LSP metadata and use
them when registering and querying capabilities. Add coverage for dynamic and
static nested workspace registrations.
This commit is contained in:
Tristan Knight
2026-05-05 21:36:02 +01:00
committed by GitHub
parent 264fbc0ace
commit ed194b99ac
4 changed files with 348 additions and 50 deletions

View File

@@ -1175,7 +1175,6 @@ protocol.Methods = {
-- stylua: ignore start
-- Generated by gen_lsp.lua, keep at end of file.
--- Maps method names to the required client capability
---TODO: also has workspace/* items because spec lacks a top-level "workspaceProvider"
protocol._provider_to_client_registration = {
['callHierarchyProvider'] = { 'textDocument', 'callHierarchy' },
['codeActionProvider'] = { 'textDocument', 'codeAction' },
@@ -1208,19 +1207,121 @@ protocol._provider_to_client_registration = {
['textDocumentSync'] = { 'textDocument', 'synchronization' },
['typeDefinitionProvider'] = { 'textDocument', 'typeDefinition' },
['typeHierarchyProvider'] = { 'textDocument', 'typeHierarchy' },
['workspace.fileOperations.didCreate'] = { 'workspace', 'fileOperations', 'didCreate' },
['workspace.fileOperations.didDelete'] = { 'workspace', 'fileOperations', 'didDelete' },
['workspace.fileOperations.didRename'] = { 'workspace', 'fileOperations', 'didRename' },
['workspace.fileOperations.willCreate'] = { 'workspace', 'fileOperations', 'willCreate' },
['workspace.fileOperations.willDelete'] = { 'workspace', 'fileOperations', 'willDelete' },
['workspace.fileOperations.willRename'] = { 'workspace', 'fileOperations', 'willRename' },
['workspace.textDocumentContent'] = { 'workspace', 'textDocumentContent' },
['workspace/didChangeConfiguration'] = { 'workspace', 'didChangeConfiguration' },
['workspace/didChangeWatchedFiles'] = { 'workspace', 'didChangeWatchedFiles' },
['workspace/didCreateFiles'] = { 'workspace', 'fileOperations', 'didCreate' },
['workspace/didDeleteFiles'] = { 'workspace', 'fileOperations', 'didDelete' },
['workspace/didRenameFiles'] = { 'workspace', 'fileOperations', 'didRename' },
['workspace/textDocumentContent'] = { 'workspace', 'textDocumentContent' },
['workspace/willCreateFiles'] = { 'workspace', 'fileOperations', 'willCreate' },
['workspace/willDeleteFiles'] = { 'workspace', 'fileOperations', 'willDelete' },
['workspace/willRenameFiles'] = { 'workspace', 'fileOperations', 'willRename' },
['workspaceSymbolProvider'] = { 'workspace', 'symbol' },
}
-- stylua: ignore end
-- stylua: ignore start
-- Generated by gen_lsp.lua, keep at end of file.
--- Maps method names to dynamic/static registration providers
protocol._request_name_to_registration_provider = {
['callHierarchy/incomingCalls'] = 'callHierarchyProvider',
['callHierarchy/outgoingCalls'] = 'callHierarchyProvider',
['client/registerCapability'] = 'client/registerCapability',
['client/unregisterCapability'] = 'client/unregisterCapability',
['codeAction/resolve'] = 'codeActionProvider',
['codeLens/resolve'] = 'codeLensProvider',
['completionItem/resolve'] = 'completionProvider',
['documentLink/resolve'] = 'documentLinkProvider',
['$/cancelRequest'] = '$/cancelRequest',
['$/logTrace'] = '$/logTrace',
['$/progress'] = '$/progress',
['$/setTrace'] = '$/setTrace',
['exit'] = 'exit',
['initialize'] = 'initialize',
['initialized'] = 'initialized',
['inlayHint/resolve'] = 'inlayHintProvider',
['notebookDocument/didChange'] = 'notebookDocument/didChange',
['notebookDocument/didClose'] = 'notebookDocument/didClose',
['notebookDocument/didOpen'] = 'notebookDocument/didOpen',
['notebookDocument/didSave'] = 'notebookDocument/didSave',
['shutdown'] = 'shutdown',
['telemetry/event'] = 'telemetry/event',
['textDocument/codeAction'] = 'codeActionProvider',
['textDocument/codeLens'] = 'codeLensProvider',
['textDocument/colorPresentation'] = 'colorProvider',
['textDocument/completion'] = 'completionProvider',
['textDocument/declaration'] = 'declarationProvider',
['textDocument/definition'] = 'definitionProvider',
['textDocument/diagnostic'] = 'diagnosticProvider',
['textDocument/didChange'] = 'textDocumentSync',
['textDocument/didClose'] = 'textDocumentSync',
['textDocument/didOpen'] = 'textDocumentSync',
['textDocument/didSave'] = 'textDocumentSync',
['textDocument/documentColor'] = 'colorProvider',
['textDocument/documentHighlight'] = 'documentHighlightProvider',
['textDocument/documentLink'] = 'documentLinkProvider',
['textDocument/documentSymbol'] = 'documentSymbolProvider',
['textDocument/foldingRange'] = 'foldingRangeProvider',
['textDocument/formatting'] = 'documentFormattingProvider',
['textDocument/hover'] = 'hoverProvider',
['textDocument/implementation'] = 'implementationProvider',
['textDocument/inlayHint'] = 'inlayHintProvider',
['textDocument/inlineCompletion'] = 'inlineCompletionProvider',
['textDocument/inlineValue'] = 'inlineValueProvider',
['textDocument/linkedEditingRange'] = 'linkedEditingRangeProvider',
['textDocument/moniker'] = 'monikerProvider',
['textDocument/onTypeFormatting'] = 'documentOnTypeFormattingProvider',
['textDocument/prepareCallHierarchy'] = 'callHierarchyProvider',
['textDocument/prepareRename'] = 'renameProvider',
['textDocument/prepareTypeHierarchy'] = 'typeHierarchyProvider',
['textDocument/publishDiagnostics'] = 'textDocument/publishDiagnostics',
['textDocument/rangeFormatting'] = 'documentRangeFormattingProvider',
['textDocument/rangesFormatting'] = 'documentRangeFormattingProvider',
['textDocument/references'] = 'referencesProvider',
['textDocument/rename'] = 'renameProvider',
['textDocument/selectionRange'] = 'selectionRangeProvider',
['textDocument/semanticTokens/full'] = 'semanticTokensProvider',
['textDocument/semanticTokens/full/delta'] = 'semanticTokensProvider',
['textDocument/semanticTokens/range'] = 'semanticTokensProvider',
['textDocument/signatureHelp'] = 'signatureHelpProvider',
['textDocument/typeDefinition'] = 'typeDefinitionProvider',
['textDocument/willSave'] = 'textDocumentSync',
['textDocument/willSaveWaitUntil'] = 'textDocumentSync',
['typeHierarchy/subtypes'] = 'typeHierarchy/subtypes',
['typeHierarchy/supertypes'] = 'typeHierarchy/supertypes',
['window/logMessage'] = 'window/logMessage',
['window/showDocument'] = 'window/showDocument',
['window/showMessage'] = 'window/showMessage',
['window/showMessageRequest'] = 'window/showMessageRequest',
['window/workDoneProgress/cancel'] = 'window/workDoneProgress/cancel',
['window/workDoneProgress/create'] = 'window/workDoneProgress/create',
['workspaceSymbol/resolve'] = 'workspaceSymbolProvider',
['workspace/applyEdit'] = 'workspace/applyEdit',
['workspace/codeLens/refresh'] = 'workspace/codeLens/refresh',
['workspace/configuration'] = 'workspace/configuration',
['workspace/diagnostic'] = 'diagnosticProvider',
['workspace/diagnostic/refresh'] = 'workspace/diagnostic/refresh',
['workspace/didChangeConfiguration'] = 'workspace/didChangeConfiguration',
['workspace/didChangeWatchedFiles'] = 'workspace/didChangeWatchedFiles',
['workspace/didChangeWorkspaceFolders'] = 'workspace.workspaceFolders.changeNotifications',
['workspace/didCreateFiles'] = 'workspace.fileOperations.didCreate',
['workspace/didDeleteFiles'] = 'workspace.fileOperations.didDelete',
['workspace/didRenameFiles'] = 'workspace.fileOperations.didRename',
['workspace/executeCommand'] = 'executeCommandProvider',
['workspace/foldingRange/refresh'] = 'workspace/foldingRange/refresh',
['workspace/inlayHint/refresh'] = 'workspace/inlayHint/refresh',
['workspace/inlineValue/refresh'] = 'workspace/inlineValue/refresh',
['workspace/semanticTokens/refresh'] = 'workspace/semanticTokens/refresh',
['workspace/symbol'] = 'workspaceSymbolProvider',
['workspace/textDocumentContent'] = 'workspace.textDocumentContent',
['workspace/textDocumentContent/refresh'] = 'workspace/textDocumentContent/refresh',
['workspace/willCreateFiles'] = 'workspace.fileOperations.willCreate',
['workspace/willDeleteFiles'] = 'workspace.fileOperations.willDelete',
['workspace/willRenameFiles'] = 'workspace.fileOperations.willRename',
['workspace/workspaceFolders'] = 'workspace.workspaceFolders',
}
-- stylua: ignore end
-- stylua: ignore start
-- Generated by gen_lsp.lua, keep at end of file.
--- Maps method names to the required server capability
@@ -1389,39 +1490,25 @@ protocol._method_supports_dynamic_registration = {
-- stylua: ignore start
-- Generated by gen_lsp.lua, keep at end of file.
protocol._method_supports_static_registration = {
['textDocument/codeAction'] = true,
['textDocument/codeLens'] = true,
['callHierarchy/incomingCalls'] = true,
['callHierarchy/outgoingCalls'] = true,
['textDocument/colorPresentation'] = true,
['textDocument/completion'] = true,
['textDocument/declaration'] = true,
['textDocument/definition'] = true,
['textDocument/diagnostic'] = true,
['textDocument/didChange'] = true,
['textDocument/documentColor'] = true,
['textDocument/documentHighlight'] = true,
['textDocument/documentLink'] = true,
['textDocument/documentSymbol'] = true,
['textDocument/foldingRange'] = true,
['textDocument/formatting'] = true,
['textDocument/hover'] = true,
['textDocument/implementation'] = true,
['textDocument/inlayHint'] = true,
['textDocument/inlineCompletion'] = true,
['textDocument/inlineValue'] = true,
['textDocument/linkedEditingRange'] = true,
['textDocument/moniker'] = true,
['textDocument/onTypeFormatting'] = true,
['textDocument/prepareCallHierarchy'] = true,
['textDocument/prepareTypeHierarchy'] = true,
['textDocument/rangeFormatting'] = true,
['textDocument/references'] = true,
['textDocument/rename'] = true,
['textDocument/selectionRange'] = true,
['textDocument/semanticTokens/full'] = true,
['textDocument/signatureHelp'] = true,
['textDocument/semanticTokens/full/delta'] = true,
['textDocument/typeDefinition'] = true,
['workspace/executeCommand'] = true,
['workspace/symbol'] = true,
['workspace/textDocumentContent'] = true,
}
-- stylua: ignore end