refactor(lsp): replace _provider_value_get with _provider_foreach

Introduce _provider_foreach to iterate over all matching provider
capabilities for a given LSP method, handling both static and dynamic
registrations. Update diagnostic logic and tests to use the new
iteration approach, simplifying capability access and improving
consistency across features.
This commit is contained in:
tris203
2026-02-23 23:03:40 +00:00
parent 06befe1e34
commit c8d9ade16a
4 changed files with 51 additions and 25 deletions

View File

@@ -538,16 +538,16 @@ function M._workspace_diagnostics(opts)
end
for _, client in ipairs(clients) do
local identifiers = client:_provider_value_get('workspace/diagnostic', 'identifier')
for _, id in ipairs(identifiers) do
---@param cap lsp.DiagnosticRegistrationOptions
client:_provider_foreach('workspace/diagnostic', function(cap)
--- @type lsp.WorkspaceDiagnosticParams
local params = {
identifier = type(id) == 'string' and id or nil,
identifier = cap.identifier,
previousResultIds = previous_result_ids(client.id),
}
client:request('workspace/diagnostic', params, handler)
end
end)
end
end