lspeasy / client/src / ClientCapabilityGuard
Class: ClientCapabilityGuard
Defined in: packages/client/src/capability-guard.ts:126
Validates that server-to-client handler registrations are backed by client capabilities declared in the initialize request.
Remarks
Created internally by LSPClient. In non-strict mode violations are logged as warnings; in strict mode they throw.
Never
NEVER register server-to-client handlers for capabilities not declared in the original initialize request — the server may send the corresponding requests, but without the capability declaration the client has no contract to handle them, leading to silent failures or unexpected errors.
Constructors
Constructor
new ClientCapabilityGuard(
capabilities,
logger,
strict?): ClientCapabilityGuard;Defined in: packages/client/src/capability-guard.ts:127
Parameters
| Parameter | Type | Default value |
|---|---|---|
capabilities | ClientCapabilities | undefined |
logger | Logger | undefined |
strict | boolean | false |
Returns
ClientCapabilityGuard
Methods
canRegisterHandler()
canRegisterHandler(method): boolean;Defined in: packages/client/src/capability-guard.ts:144
Returns true if the client has declared the capability required to handle method.
Parameters
| Parameter | Type | Description |
|---|---|---|
method | string | The LSP method string to validate against client capabilities. |
Returns
boolean
true if the client capability is declared; false (non-strict) if missing.
Throws
Error In strict mode, throws if method is unknown or the required client capability was not declared in the initialize request.
See
ClientCapabilityGuard for full class documentation.
getClientCapabilities()
getClientCapabilities(): ClientCapabilities;Defined in: packages/client/src/capability-guard.ts:167
Returns a defensive copy of the client capabilities this guard was built from.
Returns
ClientCapabilities
A shallow copy of the client capabilities object.