[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pdt-dev] Provide type-hints for variables declared in different SourceModule

hi,

yes,I just want to make a patch like yours for you:)

2011/6/27 Robert GrÃndler <r.gruendler@xxxxxxxxx>
Hi,

yes, i've tried that, but the extensions array in the PHPIndexingVisitor is private,
so i can't simply override the constructor and cast them to my own Extensions.

This is the plugin.xml of my current implementation:

https://github.com/pulse00/Symfony-2-Eclipse-Plugin/blob/master/org.eclipse.symfony.core/plugin.xml#L63

I've created a patch though to pass the requestor over to the PhpIndexingVisitorExtension (attached).

Couldn't find another way to actually add elements to the Sql Index.

Am i missing something?


-robert





On 6/27/11 8:52 AM, èåä wrote:
hi Robert ,

Do you implement your own IndexingVisitor?
btw,does it make sense if we pass requestor(IIndexingRequestor) to PhpIndexingVisitorExtension ?


2011/6/25 Robert GrÃndler <r.gruendler@xxxxxxxxx>
sorry for spamming the list, but there's really not much information in the net available concerning PDT indexing.

I've followed the "contributing to index" chapter in the wiki http://wiki.eclipse.org/Extending_PDT_2.2#Contributing_to_index
but i'm not sure if this is still up-to-date, because when i contribute additional fields to a TypeDeclaration,
nothing appears in code assist for $this-> in that class.

What confuses me is that a PDT Indexing Extension needs to subclass PhpIndexingVisitorExtension
and provide declarationinfos using modifyDeclaration() calls.

However, the modifyDeclaration() method in the PhpIndexingVisitorExtension is completely empty,
as apposed to the PhpIndexingVisitor which calls requestor.addDeclaration(info) in this method.

The requestor is not available to extensions though.

My IndexingVisitor does basically the same like the one in the Wiki (inside the endVisit(TypeDeclaration) method):

ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ DeclarationInfo info = new DeclarationInfo(IModelElement.FIELD,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ Modifiers.AccPublic, start, length, start, length, name,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ null, null, namespace.getName(), currentClass.getName());ÂÂÂ ÂÂÂ
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂ
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ modifyDeclaration(field, info);

Do i need to specify an implementation for the modifyDeclaration() method in my indexer as well?


thanks!

-robert





2011/6/24 Robert GrÃndler <r.gruendler@xxxxxxxxx>
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





_______________________________________________
pdt-dev mailing list
pdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/pdt-dev




--

Thanks!

Best Regards!

Zhao
_______________________________________________ pdt-dev mailing list pdt-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/pdt-dev


_______________________________________________
pdt-dev mailing list
pdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/pdt-dev




--

Thanks!

Best Regards!

Zhao