padawan-php / padawan.php

php intelligent code completion http server
http://mkusher.name/padawan/
MIT License
253 stars 30 forks source link

Add proper static method/property completion for self and static #84

Closed halftan closed 10 months ago

halftan commented 7 years ago

Test included

jludwig commented 7 years ago

Great work, but it seems like sometimes $workingNode isn't being set properly. Here's the code:

        /** @var \PhpParser\Node\Name $workingNode */
        list($fqcn, $isThis, $_, $workingNode) = $context->getData();

Here's the error I get:

PHP Fatal error:  Uncaught Error: Call to undefined method PhpParser\Node\Expr\ClassConstFetch::getLast() in /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/Completer/StaticCompleter.php:28
Stack trace:
#0 /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/CompleteEngine.php(84): Complete\Completer\StaticCompleter->getEntries(Object(Entity\Project), Object(Entity\Completion\Context))
#1 /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/CompleteEngine.php(61): Complete\CompleteEngine->findEntries(Object(Entity\Project), Object(Entity\Completion\Scope), 'parent::default...', '26')
#2 /home/cyberlard/d8/vendor/mkusher/padawan/src/Command/CompleteCommand.php(19): Complete\CompleteEngine->createCompletion(Object(Entity\Project), '<?php\n\nnamespac...', '118', '26', '/web/modules/cu...')
#3 /home/cyberlard/d8/vendor/mkusher/padawan/src/Application/BaseApplication.php(34): Command\CompleteCommand->run(Array)
#4 /home/cyberlard/d8/vendor/mkusher/padawan/src/Application/HTTP/App.php(23): Applicat in /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/Completer/StaticCompleter.php on line 28

Fatal error: Uncaught Error: Call to undefined method PhpParser\Node\Expr\ClassConstFetch::getLast() in /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/Completer/StaticCompleter.php on line 28

Error: Call to undefined method PhpParser\Node\Expr\ClassConstFetch::getLast() in /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/Completer/StaticCompleter.php on line 28

Call Stack:
    0.0001     390048   1. {main}() /home/cyberlard/d8/vendor/mkusher/padawan/bin/padawan-server:0
    0.0104    2095816   2. React\EventLoop\StreamSelectLoop->run() /home/cyberlard/d8/vendor/mkusher/padawan/bin/padawan-server:85
   81.9960  325388472   3. React\EventLoop\StreamSelectLoop->waitForStreamActivity() /home/cyberlard/d8/vendor/react/event-loop/src/StreamSelectLoop.php:201
   81.9960  325388952   4. call_user_func:{/home/cyberlard/d8/vendor/react/event-loop/src/StreamSelectLoop.php:232}() /home/cyberlard/d8/vendor/react/event-loop/src/StreamSelectLoop.php:232
   81.9960  325388952   5. React\Stream\Stream->handleData() /home/cyberlard/d8/vendor/react/event-loop/src/StreamSelectLoop.php:232
   81.9961  325458984   6. Evenement\EventEmitter->emit() /home/cyberlard/d8/vendor/react/stream/src/Stream.php:173
   81.9961  325458984   7. call_user_func_array:{/home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64}() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9961  325459392   8. React\Http\RequestHeaderParser->feed() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9961  325488064   9. React\Http\RequestHeaderParser->parseAndEmitRequest() /home/cyberlard/d8/vendor/react/http/src/RequestHeaderParser.php:38
   81.9962  325518968  10. Evenement\EventEmitter->emit() /home/cyberlard/d8/vendor/react/http/src/RequestHeaderParser.php:49
   81.9962  325518968  11. call_user_func_array:{/home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64}() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9962  325519376  12. React\Http\Server->React\Http\{closure}() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9962  325521296  13. React\Http\Server->handleRequest() /home/cyberlard/d8/vendor/react/http/src/Server.php:33
   81.9963  325527664  14. Evenement\EventEmitter->emit() /home/cyberlard/d8/vendor/react/http/src/Server.php:68
   81.9963  325527664  15. call_user_func_array:{/home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64}() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9963  325528056  16. {closure:/home/cyberlard/d8/vendor/mkusher/padawan/bin/padawan-server:59-72}() /home/cyberlard/d8/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php:64
   81.9963  325556728  17. Application\HTTP\App->handle() /home/cyberlard/d8/vendor/mkusher/padawan/bin/padawan-server:69
   81.9963  325556728  18. Application\BaseApplication->handle() /home/cyberlard/d8/vendor/mkusher/padawan/src/Application/HTTP/App.php:23
   81.9964  325585832  19. Command\CompleteCommand->run() /home/cyberlard/d8/vendor/mkusher/padawan/src/Application/BaseApplication.php:34
   81.9965  325585832  20. Complete\CompleteEngine->createCompletion() /home/cyberlard/d8/vendor/mkusher/padawan/src/Command/CompleteCommand.php:19
   81.9968  325659448  21. Complete\CompleteEngine->findEntries() /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/CompleteEngine.php:61
   81.9976  325501784  22. Complete\Completer\StaticCompleter->getEntries() /home/cyberlard/d8/vendor/mkusher/padawan/src/Complete/CompleteEngine.php:84
halftan commented 7 years ago

@jludwig Hi, thanks for your feedback!

In what situation may this happen? Please provide some code contexts like the following.

<?php

class TestCase {}

function main() {
    TestCase::<cursor>
jludwig commented 7 years ago

@halftan I can't prioritize this until next week, but I reminder to myself to provide some additional info.

halftan commented 7 years ago

@jludwig The latest commit can prevent fatal error. Although not resolving the issue, it'll be more stable in production.