[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pdt-dev] Generate PHP code

one more question regarding the ast-rewriting. I've implemented a getter/setter generation for class fields,
but the indentation is not set properly.

Here's the PHP code generated by the TextEdit / rewrite operation:

    public function getController(){
return $this->controller;

    public function setController(Controller $controller){

Note that only the first line of each method is indented correctly.

This is how i'm setting up the options for the program.rewrite() call:

options = new HashMap(PHPCorePlugin.getOptions());

        IScopeContext[] contents = new IScopeContext[] {
                new ProjectScope(type
                        InstanceScope.INSTANCE, DefaultScope.INSTANCE };

        for (int i = 0; i < contents.length; i++) {

IScopeContext scopeContext = contents[i];
IEclipsePreferences inode = scopeContext.getNode(PHPCorePlugin.ID);

            if (inode != null) {

if (!options.containsKey(PHPCoreConstants.FORMATTER_USE_TABS)) {

String useTabs = inode.get(PHPCoreConstants.FORMATTER_USE_TABS,null);
if (useTabs != null) {
options.put(PHPCoreConstants.FORMATTER_USE_TABS, useTabs);

if (!options.containsKey(PHPCoreConstants.FORMATTER_INDENTATION_SIZE)) {

String size = inode.get(PHPCoreConstants.FORMATTER_INDENTATION_SIZE,null);

if (size != null) {

Has anyone a hint why the other lines are not intented?



On 9/18/11 1:03 PM, Roy Ganor wrote:
Yep, I recommend using the ASTRewriter functionality.

See org.eclipse.php.core.tests.dom_ast.rewrite.ASTRewriteTests

-----Original Message-----
From: pdt-dev-bounces@xxxxxxxxxxx [mailto:pdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Robert Gruendler
Sent: Friday, September 16, 2011 1:57 PM
To: PDT Developers
Subject: [pdt-dev] Generate PHP code


i'm wondering what's the best way to generate PHP code from within a PDT extension. Is it possible to manually create an AST and
"dump" it to a file somewhere?

Or should i simply use template files and fill them with variables?


-robert _______________________________________________ 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