Re: [pdt-dev] 'unparsing' the AST
While those two examples were immensely helpful, I am still trying to figure out how to use the org.eclipse.php.internal.core.format package. For example, I'm a bit confused as to how the class PhpFormatter actually works (or rather, how it is intended to be used, the documentation is a little sparse). Its constructor requires a start and length parameter, which - I assume - is so one can selectively format parts of a document. The format() function then requires an org.w3c.dom.Node, which is presumably the root of the AST? Why is it then, that it does not accept org.eclipse.php.internal.core.ast.nodes.ASTNode? Do I need to convert the AST to DOM? Or am I missing something entirely here? Also, what's the point of implementing the strategy pattern when all indentation strategies are hard-coded into private final members? Basically all I want to do is read a PHP file, fiddle with the AST and then pretty-print it back out. Is PhpFormatter the wrong way to go here? regards raph ___ pdt-dev mailing list pdt-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/pdt-dev
Re: [pdt-dev] 'unparsing' the AST
Thanks a ton William, this is exactly what I was looking for. regards Raphael ___ pdt-dev mailing list pdt-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/pdt-dev
Re: [pdt-dev] 'unparsing' the AST
Hello, A cool example of AST transformation and then back to source code can be found here: http://code.google.com/p/jspde/source/browse/trunk/examples/eu.tl1.examples/src/eu/tl1/examples/refactoring/GlobalVariableWrapper.java and here: http://code.google.com/p/apdt/source/browse/trunk/org.phpaspect.apdt.core/src/org/phpaspect/apdt/internal/core/visitor/WeaverVisitor.java. It is all based from this article: http://www.eclipse.org/pdt/articles/ast/PHP_AST.html. There is also some slides about extending pdt on slideshare: http://www.slideshare.net/spektom/php-development-tools-20-success-story http://www.slideshare.net/wcandillon/extending-and-scripting-pdt Best regards, William On Sat, Dec 5, 2009 at 10:00 AM, Roy Ganor wrote: > I would probably start in > org.eclipse.php.internal.core.ast.rewrite.ASTRewrite (see the comments > in this class) > > Roy > -Original Message- > From: pdt-dev-boun...@eclipse.org [mailto:pdt-dev-boun...@eclipse.org] > On Behalf Of Raphael Pigulla > Sent: Friday, December 04, 2009 12:06 PM > To: pdt-dev@eclipse.org > Subject: [pdt-dev] 'unparsing' the AST > > Hi everyone, > > I'm looking for a way to 'unparse' the AST of a PHP program back into > source code. I've looked around the source and found the > org.eclipse.php.internal.core.format package which is probably what I > need to use, but I haven't figured out yet how to wire everything up. > > Any help is appreciated. > > Thanks a lot in advance > Raphael > ___ > 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 > ___ pdt-dev mailing list pdt-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/pdt-dev
RE: [pdt-dev] 'unparsing' the AST
I would probably start in org.eclipse.php.internal.core.ast.rewrite.ASTRewrite (see the comments in this class) Roy -Original Message- From: pdt-dev-boun...@eclipse.org [mailto:pdt-dev-boun...@eclipse.org] On Behalf Of Raphael Pigulla Sent: Friday, December 04, 2009 12:06 PM To: pdt-dev@eclipse.org Subject: [pdt-dev] 'unparsing' the AST Hi everyone, I'm looking for a way to 'unparse' the AST of a PHP program back into source code. I've looked around the source and found the org.eclipse.php.internal.core.format package which is probably what I need to use, but I haven't figured out yet how to wire everything up. Any help is appreciated. Thanks a lot in advance Raphael ___ 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
[pdt-dev] 'unparsing' the AST
Hi everyone, I'm looking for a way to 'unparse' the AST of a PHP program back into source code. I've looked around the source and found the org.eclipse.php.internal.core.format package which is probably what I need to use, but I haven't figured out yet how to wire everything up. Any help is appreciated. Thanks a lot in advance Raphael ___ pdt-dev mailing list pdt-dev@eclipse.org https://dev.eclipse.org/mailman/listinfo/pdt-dev