sobota, 18 lipca 2009

Eclipse PDT "No completions available"

At the beginning make sure you have successfully added appropriate libraries directory in Project Properties (right click on project root -> Properties -> PHP Include Path (Libraries)). Eg. in case of Zend Framework assuming you extract archive to zf directory, the actual libraries(those in Zend directory) are in "library" subdirectory, thus that is exactly what we need to add to Libraries pane (should be displayed as follows: [path_toextracted_archive]/zf/library).

Sometimes even though you have properly added all libraries, auto-completion still seems does not work. What is the reason? I found that auto-completion tool is quite smart, and basically analyse the context the cursor is in. Context describes where precisely we are (inside class, inside method, just inside tags, etc. The completion engine works in computed context delivered to the user only available in that very context proposals.

Another important issue is that PHP as dynamic language is taught to deliver completion mechanism, especially for code written in "more dynamic" way. In many cases type of the expression can be known at runtime, thus not possible for IDE to know the type without deep analysis of entire application. PDT comes with support from PHPDoc blocks, where user can be told of the this particular method return type.