3

New to eclipse (from intellij).

In Eclipse + Java, there seems to be robust support for ctrl+click on a member then jump to its implementation (Classes, interfaces, methods, member vars, etc). I've got a PHP PDT project running and I'm noticing that I can't jump to things like I'd hope.

some examples:

Given:

class Foo extends Foos_Dad {

private $fooHelperObject; 

public function __contstruct(){
parent::__construct(); 
$this->foooHelperObject = new fooHelperObject(); 
}

public function doFooStuff(){
return $this->fooHelperObject->doHelperStuff(); 
}

}

When pressing ctrl and hovering over Foos_Dad, parent::, $this->fooHelperObject and doHelperStuff(), I cannot jump to their implementations if they are outside the specific file i'm currently viewing. That sucks. I can do most of this in Java so I'm suspicious of my own config issues within eclipse. Can anyone with more Eclipse Ninja-foo lend a hand?

Thanks

Brad
  • 6,106
  • 4
  • 31
  • 43
  • for some methods of $this it works, for some not, as i also noticed. – Aris Jun 19 '13 at 18:28
  • @Aris - so, is there some action step you'd suggest? – Brad Jun 19 '13 at 18:46
  • I don't know either. for example: $this->connection->prepare($sql) finds method prepare, but $this->statement->bindValue doesn't. – Aris Jun 19 '13 at 19:18
  • it mostly depends on how you included class source. If class file is included dynamically or indirectly from another script, Eclipse cant (yet) figure it out. Netbeans IDE is little better in such situations for PHP. – Satish Gadhave Jun 24 '13 at 08:05
  • that's at least that's in the right direction. Its a legacy project based on codeigniter. Most of the objects are members that are initialized in the constructor and most of the functions are inherited for parents. Can you give me an example of a way to modify the relationships such that I can give eclipse more knowledge of the classes? – Brad Jun 24 '13 at 15:46

4 Answers4

1

As you have java projects, are you in PHP perspective or not ? If you have opened a PHP project and you are in Java perspective, a lot of features won't work.

enter image description here

Have you set a PHP executable ? If I remember it is not mandatory for Eclipse, but it is useful for the feature you want.

Menu > Window > Preferences > PHP > PHP Executables

Check this link if you have imported an old project : Ctrl+click (PHP Code Hyperlink Detector) and Content Assist do not work in PHP Project. (Create a new workspace where you copy your project).

Have you checked if your project is present in PHP build path ?

Right-Click on your project > Properties > Php build path
kmas
  • 6,401
  • 13
  • 40
  • 62
  • I'm in php view and I've set the executable. – Brad Jun 28 '13 at 15:31
  • In my case, I had to do yet another additional thing: I initially had an Eclipse distribution without the PHP Development Tools (PDT) and had created a workspace with it. Then I installed PDT. Then I imported a composer project. PHP Content Assist did not work. I followed the steps in this answer AND **additionally created a fresh new workspace**. Importing my composer project into this new workspace finally gives me PHP Content Assist. – Abdull Mar 08 '19 at 17:39
0

I can do that with my eclipse...

But I've got an idea:
If your code completion does not work eather it might be a wrong or missing entry in the .buildpath or .project file.
It might have something to do with that.

Go to your projectfolder (with the explorer, eclipse wont show these files) and open the .project file.
The important part is unter the <natures> Node if there is no such subnode as <nature>org.eclipse.php.core.PHPNature</nature> add it, restart your eclipse and try again.
In case that file is completely missing just add it, here is how mine looks:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>PROJECT NAME</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.wst.common.project.facet.core.builder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.dltk.core.scriptbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.php.core.PHPNature</nature>
        <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    </natures>
</projectDescription>


If that didn't help open the .buildpath file, it should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
    <buildpathentry kind="src" path=""/>
    <buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
</buildpath>

Again restart eclipse and try again.

I hope that helped.

Ch33f
  • 609
  • 8
  • 17
0

I fixed the problem installing the plugin PDT:

Help -> Install New Software -> http://downloads.zend.com/pdt

I hoped that I could have helped you.

josele
  • 1
0

This answer provided by Kepler may resolve the issue.

According to this external article, removing files under workspace/.metadata/.plugins/org.eclipse.dltk.core.index.sql.h2 will reset the database that stored the jump information.

Community
  • 1
  • 1
Reuben
  • 4,136
  • 2
  • 48
  • 57