diff --git a/src/Psalm/Internal/LanguageServer/ClientConfiguration.php b/src/Psalm/Internal/LanguageServer/ClientConfiguration.php index 1684287ec..902f9f661 100644 --- a/src/Psalm/Internal/LanguageServer/ClientConfiguration.php +++ b/src/Psalm/Internal/LanguageServer/ClientConfiguration.php @@ -45,7 +45,7 @@ class ClientConfiguration /** * Provide Hover Requests or not */ - public ?bool $provideHover= null; + public ?bool $provideHover = null; /** * Provide Signature Help or not diff --git a/src/Psalm/Internal/LanguageServer/LanguageClient.php b/src/Psalm/Internal/LanguageServer/LanguageClient.php index e6225f1bd..f5d70e773 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageClient.php +++ b/src/Psalm/Internal/LanguageServer/LanguageClient.php @@ -11,6 +11,8 @@ use Psalm\Internal\LanguageServer\Client\TextDocument as ClientTextDocument; use Psalm\Internal\LanguageServer\Client\Workspace as ClientWorkspace; use function is_null; +use function json_decode; +use function json_encode; /** * @internal @@ -144,8 +146,39 @@ class LanguageClient return; } - if (!is_null($this->clientConfiguration->provideCompletion)) { - //$this->server->project_analyzer->provide_completion = $this->clientConfiguration->provideCompletion; + /** @var array */ + $array = json_decode(json_encode($config), true); + + if (isset($array['hideWarnings'])) { + $this->clientConfiguration->hideWarnings = (bool) $array['hideWarnings']; + } + + if (isset($array['provideCompletion'])) { + $this->clientConfiguration->provideCompletion = (bool) $array['provideCompletion']; + } + + if (isset($array['provideDefinition'])) { + $this->clientConfiguration->provideDefinition = (bool) $array['provideDefinition']; + } + + if (isset($array['provideHover'])) { + $this->clientConfiguration->provideHover = (bool) $array['provideHover']; + } + + if (isset($array['provideSignatureHelp'])) { + $this->clientConfiguration->provideSignatureHelp = (bool) $array['provideSignatureHelp']; + } + + if (isset($array['provideCodeActions'])) { + $this->clientConfiguration->provideCodeActions = (bool) $array['provideCodeActions']; + } + + if (isset($array['provideDiagnostics'])) { + $this->clientConfiguration->provideDiagnostics = (bool) $array['provideDiagnostics']; + } + + if (isset($array['findUnusedVariables'])) { + $this->clientConfiguration->findUnusedVariables = (bool) $array['findUnusedVariables']; } } } diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index 8c318c79a..3d5aeaa6a 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -109,6 +109,8 @@ class LanguageServer extends Dispatcher */ public ?ServerWorkspace $workspace = null; + public ?ClientInfo $clientInfo = null; + protected ProtocolReader $protocolReader; protected ProtocolWriter $protocolWriter; @@ -426,6 +428,7 @@ class LanguageServer extends Dispatcher ?string $trace = null //?array $workspaceFolders = null //error in json-dispatcher ): Promise { + $this->clientInfo = $clientInfo; $this->clientCapabilities = $capabilities; $this->trace = $trace; return call(