HvyIndustries / crane

PHP Intellisense/code-completion for VS Code
https://hvy.io/crane
Other
240 stars 25 forks source link

Methods from classes static instance doesn't work (not linking correctly) #372

Open ignacruiz opened 6 years ago

ignacruiz commented 6 years ago

Hope explain correctly, example at bottom. New [new x();] instanced objects works ok, if you CTRL + mouse over the method, you have the click auto-open option and go to the class-method concrete line. The same but using static instace [x::method()] just open the class never goes to the method.

Example: one.php:

<?php
class MyClass {
    public function test() {

    }
}

two.php

<?php
require_once("one.php");

$demo = new MyClass();
$demo->test();

MyClass::test();

If you CTRL+click on "->test();" from "$demo->test();" line, file one.php is opened and focused on "public function test()" line.

If you do the same on "::test();" it just open one.php but no focus on the method, just the class declaration.

The silly example is a short class, but long classes (for example adding some string property with long value could be proof for testing) doesn't locate you on the file and could be nice, cause some frameworks (and me) combine static instances with object instances. Ty!

nevadascout commented 6 years ago

Hey, thanks for reporting this but Crane doesn't support go-to-definition on methods yet -- only classes. Are you using another PHP code completion plugin?

nachazo commented 6 years ago

I'm confused! I was totally sure that ctrl+click feature was from your extension. I have "PHP Extension Pack". I don't know if this add the ctrl+click go-to method feature, but it's working for "$a = new a(); $a->hello();", not for "a::hello()". Sorry then, maybe not issue, a feature request :)