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

Language server not reacting on didChange events when using psalm.phar #6301

Closed
thbley opened this issue Aug 14, 2021 · 1 comment · Fixed by #6302
Closed

Language server not reacting on didChange events when using psalm.phar #6301

thbley opened this issue Aug 14, 2021 · 1 comment · Fixed by #6302

Comments

@thbley
Copy link
Contributor

thbley commented Aug 14, 2021

When using psalm language server as phar-file, the didChange event does not produce publishDiagnostics messages.

Tested with Psalm 4.9.2, PHP 7.4.

For analyzing, I changed:

+++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php
@@ -141,9 +141,11 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
                         /** @psalm-suppress MixedAssignment */
                         $result = yield $dispatched;
                     } catch (AdvancedJsonRpc\Error $e) {
+                        error_log($e->__toString());
                         // If a ResponseError is thrown, send it back in the Response
                         $error = $e;
                     } catch (Throwable $e) {
+                        error_log($e->__toString());
                         // If an unexpected error occurred, send back an INTERNAL_ERROR error response
                         $error = new AdvancedJsonRpc\Error(
                             (string) $e,

and got:

[14-Aug-2021 04:59:04 Europe/Berlin] ReflectionException: Class \LanguageServerProtocol\TextDocumentContentChangeEvent does not exist in phar:///home/administrator/code/psalm/build/psalm.phar/vendor/netresearch/jsonmapper/src/JsonMapper.php:539
Stack trace:
#0 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/netresearch/jsonmapper/src/JsonMapper.php(539): ReflectionClass->__construct()
#1 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/netresearch/jsonmapper/src/JsonMapper.php(368): _HumbugBoxe13a1d0087b5\JsonMapper->createInstance()
#2 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php(146): _HumbugBoxe13a1d0087b5\JsonMapper->mapArray()
#3 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/LanguageServer/LanguageServer.php(118): _HumbugBoxe13a1d0087b5\AdvancedJsonRpc\Dispatcher->dispatch()
#4 [internal function]: Psalm\Internal\LanguageServer\LanguageServer->Psalm\Internal\LanguageServer\{closure}()
#5 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Coroutine.php(53): Generator->current()
#6 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/functions.php(91): _HumbugBoxe13a1d0087b5\Amp\Coroutine->__construct()
#7 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/functions.php(58): _HumbugBoxe13a1d0087b5\Amp\call()
#8 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/LanguageServer/EmitterTrait.php(75): _HumbugBoxe13a1d0087b5\Amp\{closure}()
#9 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php(106): Psalm\Internal\LanguageServer\ProtocolStreamReader->emit()
#10 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php(62): Psalm\Internal\LanguageServer\ProtocolStreamReader->readMessages()
#11 [internal function]: Psalm\Internal\LanguageServer\ProtocolStreamReader->Psalm\Internal\LanguageServer\{closure}()
#12 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Coroutine.php(96): Generator->send()
#13 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Internal/Placeholder.php(125): _HumbugBoxe13a1d0087b5\Amp\Coroutine->_HumbugBoxe13a1d0087b5\Amp\{closure}()
#14 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Deferred.php(49): class@anonymous->resolve()
#15 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/byte-stream/lib/ResourceInputStream.php(76): _HumbugBoxe13a1d0087b5\Amp\Deferred->resolve()
#16 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Loop/NativeDriver.php(265): _HumbugBoxe13a1d0087b5\Amp\ByteStream\ResourceInputStream::_HumbugBoxe13a1d0087b5\Amp\ByteStream\{closure}()
#17 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Loop/NativeDriver.php(97): _HumbugBoxe13a1d0087b5\Amp\Loop\NativeDriver->selectStreams()
#18 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Loop/Driver.php(117): _HumbugBoxe13a1d0087b5\Amp\Loop\NativeDriver->dispatch()
#19 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Loop/Driver.php(61): _HumbugBoxe13a1d0087b5\Amp\Loop\Driver->tick()
#20 phar:///home/administrator/code/psalm/build/psalm.phar/vendor/amphp/amp/lib/Loop.php(87): _HumbugBoxe13a1d0087b5\Amp\Loop\Driver->run()
#21 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(382): _HumbugBoxe13a1d0087b5\Amp\Loop::run()
#22 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/Cli/LanguageServer.php(213): Psalm\Internal\Analyzer\ProjectAnalyzer->server()
#23 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/Cli/Psalm.php(605): Psalm\Internal\Cli\LanguageServer::run()
#24 phar:///home/administrator/code/psalm/build/psalm.phar/src/Psalm/Internal/Cli/Psalm.php(147): Psalm\Internal\Cli\Psalm::forwardCliCall()
#25 phar:///home/administrator/code/psalm/build/psalm.phar/psalm(6): Psalm\Internal\Cli\Psalm::run()
#26 /home/administrator/code/psalm/build/psalm.phar(14): require('phar:///home/ad...')

Here is the test script I used: https://gist.github.com/thomasbley/a657a1046830a7da5e302675dba4ea70

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

Successfully merging a pull request may close this issue.

2 participants