Change variable type

Hi there. I learn how to write simple plugin for phpstorm.

My new chalenge is next:


/**
*@iterate-object Token
*/
class TokenCollection implements Iterator {

}

class Token {
    public function getId() {
        
    }
}

$it = new TokenCollection();
foreach ($it as $key => $value) {
     $value-><Ctrl+Space>
}


I want to suggest all methods and properties from object Token when i press Ctrl+space on $value->

In other words type of $value is class Object of Token.

At my first step, i try to change $value type in PsiReferenceContributor. Byt i can`t catch it.

I try to suggest it via DefaultCompletionContributor. I fill suggest elements with method names. But name of method does not corespond to class method. So it is wrong step for me.

My questin:
How can i set that  $value is coressponding to Token class?



Attachment(s):
Screenshot from 2013-12-03 11:52:28.png
4 comments
Comment actions Permalink

You need to implement com.intellij.codeInsight.completion.CompletionContributor - check it's documentation first.

0
Comment actions Permalink

Thanks for help.

0
Comment actions Permalink

Using PhpTypeProvider2 i done may task for 98%

What i have done.
file User/Edit.php     contain Site_User_Edit_Controller

I have several html files

file View/UserEdit.html and file View/UserEdit-row.html
In this files $this is instance of Site_User_Edit_Controller. I use PhpTypeProvider2 to make completion of methods and properties of class Site_User_Edit_Controller
All works fine. Plus I use CompletionContributor to suggest $this variable in this files;

But there is one feature I want to do.
When I move mouse to $this and press Ctrl+click IDE does not go to class. it is strange however IDE knows about $this type but naviagtion to class is not available.

Naviagtion is available only if I use phpdoc


  /** @var $this Site_User_Edit_Controller */
  $this->test();

How to avoid writing this phpdoc comments and tell IDE that $this is instance of class Site_User_Edit_Controller?

0
Comment actions Permalink

Answer to my question: implement

com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler
0

Please sign in to leave a comment.