[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[pdt-dev] Provide type-hints for variables declared in different SourceModule
|
Hi,
a lot of PHP Frameworks implement the MVC pattern, and i'm wondering
what's the
best way to provide codeassist for PHP variables in files that have been
declared
in other SourceModules.
Let's say you have the class UserController with the method showUser()
(in /UserController.php)
... class declaration
public function showUser() {
$user = UserDAO::retrieveUserByID($id);
return array('showUser.php', array('user' => $user'))
}
The framework then renders the file 'showUser.php' and passes in the
$user object
as a variable named $user.
What i have done right now is the following:
1. In the SourceElementRequestor extension i visit the ReturnStatements
of methods in Controller
classes.
2. I detect the variables returned by that method and store it in some
custom Singleton.
3. Register a completionContext/Strategy which retrieves the correct
variables for the current php file from the Singleton.
This approach works, though it doesn't feel properly integrated into the
DLTK/PDT model, as
1. I'm simply storing the ViewVariable in-memory in my singleton, so
after Eclipse relaunches, the whole project needs to be rebuilt for
completion to work.
2. I'm getting ConcurrentModificationExceptions in my Singleton class
during the BuildPhase as apparently the SourceParsing
takes place in multiple threads.
So my question is, is there a way to contribute those Variables which
are being passed to the View-Templates properly to the DLTK/PDT model ?
regards,
-robert