i've managed to add methods and update the editor, however, i have another
question.

When adding AST nodes to the tree, it seems i need to work with nodes from
the package
org.eclipse.php.internal.ast.nodes.

However, when traversing the tree based on an ISourceModule, the
PHPAstVisitor
works with nodes from the package
org.eclipse.php.internal.core.compiler.ast.nodes.

So when i search for a method using the PHPAstVisitor, i'm handling
PHPMethodDeclarations, but
when i need to add a method to a class, i'm handling
org.eclipse.php.internal.ast.nodes.MethodDeclarations.

Is there a way to use a single method class for both search and manipulation
of the AST  ?



regards

-robert



2009/7/6 Robert Gründler <doo...@gmail.com>

> Thanks a lot!
>
>
>
> Am 06.07.2009 um 07:27 schrieb "Roy Ganor" <r...@zend.com>:
>
>  Hi Robert,
>
> You can find full documentation for AST manipulation here:
> <http://www.eclipse.org/pdt/articles/ast/PHP_AST.html>
> http://www.eclipse.org/pdt/articles/ast/PHP_AST.html
>
> take a look at our unit tests to see what is the right way for doing this
> for the different types of elements - <http://bit.ly/Bnl9q>
> http://bit.ly/Bnl9q.
>
>
>
> Regards,
>
> Roy
>
> *From:* pdt-dev-boun...@eclipse.org [mailto:pdt-dev-boun...@eclipse.org] *On
> Behalf Of *Robert Gruendler
> *Sent:* Sunday, July 05, 2009 11:25 PM
> *To:* PDT Developers
> *Subject:* [pdt-dev] add method to class
>
>
>
> Hi all,
>
> could someone give me a hint how i can add a method to a class and make it
> visible in the editor ?
>
> So far, i've tried the following:
>
> sourceModule.becomeWorkingCopy(null, null);
> classDeclaration.getBody.addStatement(myNewMethod); //classDeclaration is
> child of the sourcemodule
> sourceModule.reconcile(true, null, null);
> sourceModule.commitWorkingCopy(true, null);
>
> Do i need to alter the IBuffer of the sourcemodule manually for this to
> work ?
>
>
> thanks !
>
>
> -robert
>
> _______________________________________________
> pdt-dev mailing list
> pdt-dev@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/pdt-dev
>
>
_______________________________________________
pdt-dev mailing list
pdt-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/pdt-dev

Reply via email to