Open come-nc opened 1 year ago
@tm1000 is this something you observed before?
I'd have to see an example repo. The language server is the same code base as psalm itself
This is happening to me on https://github.com/nextcloud/server/ repository The kate configuration is:
"php": {
"command": ["vendor-bin/psalm/vendor/vimeo/psalm/psalm-language-server"],
"rootIndicationFileNames": ["psalm.xml","composer.json"],
"path": ["%{Project:Path}"],
"url": "https://psalm.dev",
"highlightingModeRegex": "^PHP.*$"
},
@come-nc can you please clarify your Psalm/PHP version
> vendor-bin/psalm/vendor/vimeo/psalm/psalm-language-server --version
Psalm 4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69
> php --version
PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies
Please use Psalm 5. Psalm 4 is not supported.
Please use Psalm 5. Psalm 4 is not supported.
I updated:
vendor-bin/psalm/vendor/vimeo/psalm/psalm-language-server --version
Psalm 5.9.0@8b9ad1eb9e8b7d3101f949291da2b9f7767cd163
Still have the same problem. I had it once with psalm, and had to run psalm --clear-cache to get rid of it. But for language-server I do not know how to clear cache.
I also have the problem that it sometimes leave Kate hanging for a long time searching for autocompletion (when I start typing a method name, more than 10 seconds I think), but that is most likely unrelated to current ticket.
The cache is cleared on every boot of language server. I still don't have this issue so nothing much I can do at the moment sorry :(
I'm also seeing this issue. I'm using the VSCode plugin and having enabled the --verbose
flag and set log level to DEBUG
I notice a pattern that it seems that Psalm is unable to populate classes that it tries to locate via reflection.
E.g. In the log when it logs
Using composer to locate file for GuzzleHttp\Promise\PromiseInterface
Then it will later have an entry
Have populated GuzzleHttp\Promise\PromiseInterface
However, when it logs
Using reflection to locate file for Neos\Flow\Tests\UnitTestCase
then there's no corresponding
Have populated Neos\Flow\Tests\UnitTestCase
I'm unsure how and why it tries to locate files using reflection, but the folder structure of our workspace is likely such that it is unable to do so.
Our psalm.xml
configuration has the following extraFiles
element
<extraFiles>
<directory name="Packages/Framework/Neos.Flow/Tests" />
</extraFiles>
which is the path where the Neos\Flow\Tests\UnitTestCase
class is located.
Same problem here...
<extraFiles>
<directory name="vendor"/>
</extraFiles>
@bdovaz putting vendor in extraFiles is going to cause Psalm to quickly run out of memory as it lightly analyzes Composer vendor repos but you are telling it to fully analyze them.
Is there a specific use case we are missing where you feel like you need to add "vendor"
@bdovaz putting vendor in extraFiles is going to cause Psalm to quickly run out of memory as it lightly analyzes Composer vendor repos but you are telling it to fully analyze them.
Is there a specific use case we are missing where you feel like you need to add "vendor"
But isn't that the way it doesn't analyze your code as yours but makes it possible that when analyzing your code it doesn't tell you that it is not able to resolve certain classes?
Maybe I am wrong.
@bdovaz thats not the way it works. It will always traverse the vendor folder
@bdovaz thats not the way it works. It will always traverse the vendor folder
Nextcloud recommends this:
What should I do instead?
That seems to be the source of the problem then, what is the correct way to have psalm load classes from a folder without analysing it if it’s not extraFiles
?
Using the psalm-language-server with Kate, I always see this kind of errors:
But this interface is in
3rdparty/psr/event-dispatcher/src/StoppableEventInterface.php
, and psalm.xml contains:Psalm does find the class, why doesn’t the LSP server?