From 5955b08f7fc51885073e2bb2884201c9e7ff25c6 Mon Sep 17 00:00:00 2001 From: Mario Fusco Date: Tue, 30 Dec 2014 16:16:45 +0100 Subject: [PATCH] make materialize returning the created ast node --- .../org/jboss/forge/roaster/model/ASTNode.java | 4 +--- .../forge/roaster/model/impl/BlockImpl.java | 8 +------- .../forge/roaster/model/impl/NodeImpl.java | 12 ++---------- .../model/impl/expressions/ArrayAccessImpl.java | 11 +++++------ .../model/impl/expressions/ArrayImpl.java | 11 +++++------ .../model/impl/expressions/ArrayInitImpl.java | 11 +++++------ .../model/impl/expressions/AssignImpl.java | 11 +++++------ .../impl/expressions/BooleanLiteralImpl.java | 10 ++++------ .../model/impl/expressions/CastImpl.java | 12 +++++------- .../impl/expressions/CharacterLiteralImpl.java | 11 +++++------ .../impl/expressions/ClassLiteralImpl.java | 11 +++++------ .../model/impl/expressions/ConstructorImpl.java | 11 +++++------ .../impl/expressions/DeclareExpressionImpl.java | 11 +++++------ .../model/impl/expressions/DotAccessorImpl.java | 6 ------ .../model/impl/expressions/FieldImpl.java | 11 +++++------ .../model/impl/expressions/GetterImpl.java | 15 +++++++-------- .../model/impl/expressions/InstanceofImpl.java | 11 +++++------ .../impl/expressions/MethodInvokeImpl.java | 17 ++++++++--------- .../model/impl/expressions/NullLiteralImpl.java | 11 +++++------ .../impl/expressions/NumberLiteralImpl.java | 11 +++++------ .../model/impl/expressions/OperatorImpl.java | 11 +++++------ .../model/impl/expressions/ParenImpl.java | 11 +++++------ .../model/impl/expressions/PostFixImpl.java | 11 +++++------ .../impl/expressions/SelfArgumentImpl.java | 11 +++++------ .../model/impl/expressions/SetterImpl.java | 13 ++++++------- .../expressions/StaticClassAccessorImpl.java | 11 +++++------ .../impl/expressions/StringLiteralImpl.java | 11 +++++------ .../model/impl/expressions/SuperFieldImpl.java | 11 +++++------ .../model/impl/expressions/SuperGetterImpl.java | 14 ++++++-------- .../impl/expressions/SuperMethodInvokeImpl.java | 11 +++++------ .../model/impl/expressions/SuperSetterImpl.java | 11 +++++------ .../model/impl/expressions/TernaryImpl.java | 11 +++++------ .../model/impl/expressions/UnaryImpl.java | 11 +++++------ .../model/impl/expressions/VarArgumentImpl.java | 11 +++++------ .../impl/statements/AssertStatementImpl.java | 11 +++++------ .../impl/statements/AssignStatementImpl.java | 11 +++++------ .../impl/statements/BlockStatementImpl.java | 11 ++++++----- .../impl/statements/BreakStatementImpl.java | 11 +++++------ .../impl/statements/ContinueStatementImpl.java | 11 +++++------ .../impl/statements/DeclareStatementImpl.java | 11 +++++------ .../impl/statements/DoWhileStatementImpl.java | 11 +++++------ .../statements/ExpressionStatementImpl.java | 10 ++++------ .../impl/statements/ForEachStatementImpl.java | 11 +++++------ .../model/impl/statements/ForStatementImpl.java | 11 ++++++----- .../model/impl/statements/IfStatementImpl.java | 11 +++++------ .../impl/statements/InvokeStatementImpl.java | 11 +++++------ .../impl/statements/ReturnStatementImpl.java | 11 +++++------ .../impl/statements/SuperStatementImpl.java | 11 +++++------ .../impl/statements/SwitchStatementImpl.java | 11 +++++------ .../impl/statements/SynchStatementImpl.java | 11 +++++------ .../impl/statements/ThisStatementImpl.java | 11 +++++------ .../impl/statements/ThrowStatementImpl.java | 10 +++++----- .../impl/statements/TryCatchStatementImpl.java | 12 +++++------- .../impl/statements/WhileStatementImpl.java | 11 +++++------ .../roaster/spi/ExpressionFactoryImpl.java | 7 +------ 55 files changed, 262 insertions(+), 339 deletions(-) diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/ASTNode.java b/impl/src/main/java/org/jboss/forge/roaster/model/ASTNode.java index 67c253d0..20475359 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/ASTNode.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/ASTNode.java @@ -7,9 +7,7 @@ public interface ASTNode { public AST getAst(); - public J getInternal(); - - public void materialize( AST ast ); + public J materialize( AST ast ); void setAst( AST ast ); } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/BlockImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/BlockImpl.java index 719b622d..3a9ac27a 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/BlockImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/BlockImpl.java @@ -10,7 +10,6 @@ import org.eclipse.jdt.core.dom.AST; import org.jboss.forge.roaster.model.Block; import org.jboss.forge.roaster.model.impl.statements.JdtStatementWrapper; -import org.jboss.forge.roaster.model.impl.statements.StatementImpl; import org.jboss.forge.roaster.model.source.BlockHolder; import org.jboss.forge.roaster.model.source.JavaSource; import org.jboss.forge.roaster.model.statements.BlockStatement; @@ -29,12 +28,7 @@ public void setBlock( BlockStatement body ) { } @Override - public org.eclipse.jdt.core.dom.Block getInternal() { + public org.eclipse.jdt.core.dom.Block materialize( AST ast ) { return block; } - - @Override - public void materialize( AST ast ) { - - } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/NodeImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/NodeImpl.java index 327d25ae..21070b62 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/NodeImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/NodeImpl.java @@ -8,15 +8,9 @@ package org.jboss.forge.roaster.model.impl; import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ArrayInitializer; -import org.eclipse.jdt.core.dom.Expression; import org.jboss.forge.roaster.Origin; import org.jboss.forge.roaster.model.ASTNode; -import org.jboss.forge.roaster.model.expressions.ArrayConstructorExpression; -import org.jboss.forge.roaster.model.expressions.ArrayInit; import org.jboss.forge.roaster.model.expressions.ExpressionSource; -import org.jboss.forge.roaster.model.expressions.Wireable; -import org.jboss.forge.roaster.model.impl.expressions.DotAccessorImpl; import org.jboss.forge.roaster.model.impl.expressions.JdtExpressionWrapper; import org.jboss.forge.roaster.model.impl.statements.JdtStatementWrapper; import org.jboss.forge.roaster.model.source.JavaSource; @@ -50,16 +44,14 @@ public X wireAndGetExpression JdtExpressionWrapper node = (JdtExpressionWrapper) expression; node.setOrigin( parent ); node.setAst( ast ); - node.materialize( ast ); - return node.getInternal(); + return node.materialize( ast ); } public org.eclipse.jdt.core.dom.Statement wireAndGetStatement( Statement statement, P parent, AST ast ) { JdtStatementWrapper node = (JdtStatementWrapper) statement; node.setOrigin( parent ); node.setAst( ast ); - node.materialize( ast ); - return node.getInternal(); + return node.materialize( ast ); } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayAccessImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayAccessImpl.java index 6fa7bc6e..30c75b95 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayAccessImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayAccessImpl.java @@ -27,17 +27,16 @@ public ArrayAccessImpl( Expression> index ) { } @Override - public ArrayAccess getInternal() { - return axx; - } - - @Override - public void materialize( AST ast ) { + public ArrayAccess materialize( AST ast ) { + if (axx != null) { + return axx; + } axx = ast.newArrayAccess(); axx.setIndex( wireAndGetExpression( index, this, ast ) ); if ( target != null ) { axx.setArray( wireAndGetExpression( target, this, ast ) ); } + return axx; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayImpl.java index 215886e9..3fd11b09 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayImpl.java @@ -38,12 +38,10 @@ public ArrayImpl( String type ) { } @Override - public ArrayCreation getInternal() { - return array; - } - - @Override - public void materialize( AST ast ) { + public ArrayCreation materialize( AST ast ) { + if (array != null) { + return array; + } array = ast.newArrayCreation(); array.setType( (ArrayType) JDTHelper.getType( type + new String( new char[ getDimension() ] ).replace( "\0", "[]" ), ast ) ); for ( Expression> dim : dims ) { @@ -52,6 +50,7 @@ public void materialize( AST ast ) { if ( init != null ) { array.setInitializer( (ArrayInitializer) wireAndGetExpression( init, this, ast ) ); } + return array; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayInitImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayInitImpl.java index 32ab9061..adb97bd3 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayInitImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ArrayInitImpl.java @@ -50,15 +50,14 @@ public int size() { } @Override - public ArrayInitializer getInternal() { - return init; - } - - @Override - public void materialize( AST ast ) { + public ArrayInitializer materialize( AST ast ) { + if (init != null) { + return init; + } this.init = ast.newArrayInitializer(); for ( ExpressionSource src : elements ) { this.init.expressions().add( wireAndGetExpression( src, this, ast ) ); } + return init; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/AssignImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/AssignImpl.java index 08488132..78ece502 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/AssignImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/AssignImpl.java @@ -42,12 +42,10 @@ public AssignExpression setRight( Expression right ) { } @Override - public Assignment getInternal() { - return axx; - } - - @Override - public void materialize( AST ast ) { + public Assignment materialize( AST ast ) { + if (axx != null) { + return axx; + } axx = ast.newAssignment(); axx.setOperator( Assignment.Operator.toOperator( op.getOp() ) ); @@ -57,5 +55,6 @@ public void materialize( AST ast ) { if ( right != null ) { axx.setRightHandSide( wireAndGetExpression( right, this, ast ) ); } + return axx; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/BooleanLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/BooleanLiteralImpl.java index 482b1ab3..378c0b26 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/BooleanLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/BooleanLiteralImpl.java @@ -24,12 +24,10 @@ public BooleanLiteralImpl( boolean val ) { } @Override - public BooleanLiteral getInternal() { + public BooleanLiteral materialize( AST ast ) { + if (literal == null) { + literal = ast.newBooleanLiteral(val); + } return literal; } - - @Override - public void materialize( AST ast ) { - literal = ast.newBooleanLiteral( val ); - } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CastImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CastImpl.java index b39377ce..9026452b 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CastImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CastImpl.java @@ -29,14 +29,11 @@ public CastImpl( String klass, Expression> expression ) { this.expression = expression; } - @Override - public org.eclipse.jdt.core.dom.CastExpression getInternal() { - return cast; - } - - @Override - public void materialize( AST ast ) { + public org.eclipse.jdt.core.dom.CastExpression materialize( AST ast ) { + if (cast != null) { + return cast; + } cast = ast.newCastExpression(); cast.setType( JDTHelper.getType( type, ast ) ); if ( expression != null ) { @@ -45,5 +42,6 @@ public void materialize( AST ast ) { paren.setExpression( expr ); cast.setExpression( paren ); } + return cast; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CharacterLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CharacterLiteralImpl.java index 96b5d016..e1595115 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CharacterLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/CharacterLiteralImpl.java @@ -24,13 +24,12 @@ public CharacterLiteralImpl( Character val ) { } @Override - public CharacterLiteral getInternal() { - return literal; - } - - @Override - public void materialize( AST ast ) { + public CharacterLiteral materialize( AST ast ) { + if (literal != null) { + return literal; + } literal = ast.newCharacterLiteral(); literal.setCharValue( val ); + return literal; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ClassLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ClassLiteralImpl.java index 208bb0e0..3756978a 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ClassLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ClassLiteralImpl.java @@ -27,14 +27,13 @@ public ClassLiteralImpl( String val ) { } @Override - public TypeLiteral getInternal() { - return literal; - } - - @Override - public void materialize( AST ast ) { + public TypeLiteral materialize( AST ast ) { + if (literal != null) { + return literal; + } literal = ast.newTypeLiteral(); literal.setType( JDTHelper.getType( val, ast ) ); + return literal; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ConstructorImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ConstructorImpl.java index 17902dc9..c9e5d89e 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ConstructorImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ConstructorImpl.java @@ -43,18 +43,17 @@ public ConstructorExpression addArgument( Argument> arg : arguments ) { constr.arguments().add( wireAndGetExpression( arg, this, ast ) ); } + return constr; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DeclareExpressionImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DeclareExpressionImpl.java index 5ae8f3e1..c24e5b21 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DeclareExpressionImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DeclareExpressionImpl.java @@ -38,12 +38,10 @@ public DeclareExpression init( Expression expr ) { } @Override - public VariableDeclarationExpression getInternal() { - return var; - } - - @Override - public void materialize( AST ast ) { + public VariableDeclarationExpression materialize( AST ast ) { + if (var != null) { + return var; + } VariableDeclarationFragment frag = ast.newVariableDeclarationFragment(); frag.setName( ast.newSimpleName( name ) ); var = ast.newVariableDeclarationExpression( frag ); @@ -52,5 +50,6 @@ public void materialize( AST ast ) { if ( init != null ) { frag.setInitializer( wireAndGetExpression( init, this, ast ) ); } + return var; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DotAccessorImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DotAccessorImpl.java index c5559f03..50cc6cb5 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DotAccessorImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/DotAccessorImpl.java @@ -7,7 +7,6 @@ package org.jboss.forge.roaster.model.impl.expressions; -import org.eclipse.jdt.core.dom.AST; import org.jboss.forge.roaster.model.expressions.AccessBuilder; import org.jboss.forge.roaster.model.expressions.Accessor; import org.jboss.forge.roaster.model.expressions.ArrayIndexer; @@ -88,9 +87,4 @@ private void swap( Expression child, Expression parent ) { sup.wireParent( child ); sub.wireExpression( parent ); } - - @Override - public void materialize( AST ast ) { - super.materialize( ast ); - } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/FieldImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/FieldImpl.java index 4cce94e9..9d80c663 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/FieldImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/FieldImpl.java @@ -28,12 +28,10 @@ public FieldImpl( String fieldName ) { } @Override - public FieldAccess getInternal() { - return fld; - } - - @Override - public void materialize( AST ast ) { + public FieldAccess materialize( AST ast ) { + if (fld != null) { + return fld; + } fld = ast.newFieldAccess(); fld.setName( ast.newSimpleName( fieldName ) ); if ( expression == null ) { @@ -41,6 +39,7 @@ public void materialize( AST ast ) { } else { fld.setExpression( wireAndGetExpression( expression, this, ast ) ); } + return fld; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/GetterImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/GetterImpl.java index 786f9a04..0290696d 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/GetterImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/GetterImpl.java @@ -39,17 +39,16 @@ public InvokeExpression setTarget( Expression> t } @Override - public MethodInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public MethodInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newMethodInvocation(); - getInternal().setName( ast.newSimpleName( method ) ); + invoke.setName(ast.newSimpleName(method)); if ( target != null ) { - getInternal().setExpression( wireAndGetExpression( target, this, ast ) ); + invoke.setExpression(wireAndGetExpression(target, this, ast)); } + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/InstanceofImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/InstanceofImpl.java index e997c8c7..c65d9c4a 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/InstanceofImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/InstanceofImpl.java @@ -29,17 +29,16 @@ public InstanceofImpl( String klass, Expression> e } @Override - public org.eclipse.jdt.core.dom.InstanceofExpression getInternal() { - return isA; - } - - @Override - public void materialize( AST ast ) { + public org.eclipse.jdt.core.dom.InstanceofExpression materialize( AST ast ) { + if (isA != null) { + return isA; + } isA = ast.newInstanceofExpression(); isA.setRightOperand( JDTHelper.getType( type, ast ) ); if ( expression != null ) { org.eclipse.jdt.core.dom.Expression expr = wireAndGetExpression( expression, this, ast ); isA.setLeftOperand( expr ); } + return isA; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/MethodInvokeImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/MethodInvokeImpl.java index 403b2e37..b469aecd 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/MethodInvokeImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/MethodInvokeImpl.java @@ -28,21 +28,20 @@ public MethodInvokeImpl( String method ) { } @Override - public MethodInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public MethodInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newMethodInvocation(); - getInternal().setName( ast.newSimpleName( method ) ); + invoke.setName(ast.newSimpleName(method)); if ( target != null ) { - getInternal().setExpression( wireAndGetExpression( target, this, ast ) ); + invoke.setExpression(wireAndGetExpression(target, this, ast)); } for ( Argument> arg : arguments ) { - getInternal().arguments().add( wireAndGetExpression( arg, this, ast ) ); + invoke.arguments().add( wireAndGetExpression( arg, this, ast ) ); } + return invoke; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NullLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NullLiteralImpl.java index 69105e6f..8bf3db87 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NullLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NullLiteralImpl.java @@ -20,12 +20,11 @@ public class NullLiteralImpl, T extends ExpressionSource public NullLiteralImpl() {} @Override - public NullLiteral getInternal() { - return literal; - } - - @Override - public void materialize( AST ast ) { + public NullLiteral materialize( AST ast ) { + if (literal != null) { + return literal; + } literal = ast.newNullLiteral(); + return literal; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NumberLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NumberLiteralImpl.java index e19931ef..c8bd8fd8 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NumberLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/NumberLiteralImpl.java @@ -24,12 +24,11 @@ public NumberLiteralImpl( Number val ) { } @Override - public NumberLiteral getInternal() { - return literal; - } - - @Override - public void materialize( AST ast ) { + public NumberLiteral materialize( AST ast ) { + if (literal != null) { + return literal; + } literal = ast.newNumberLiteral( val.toString() ); + return literal; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/OperatorImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/OperatorImpl.java index dac5e17f..4984818b 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/OperatorImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/OperatorImpl.java @@ -45,12 +45,10 @@ public OperatorExpression addArgument( Argument> } @Override - public InfixExpression getInternal() { - return expr; - } - - @Override - public void materialize( AST ast ) { + public InfixExpression materialize( AST ast ) { + if (expr != null) { + return expr; + } expr = ast.newInfixExpression(); expr.setOperator( InfixExpression.Operator.toOperator( this.operator.getOp() ) ); @@ -58,6 +56,7 @@ public void materialize( AST ast ) { for ( Argument> arg : argumentList ) { wireArg( arg, ast ); } + return expr; } protected void wireArg( Argument> arg, AST ast ) { diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ParenImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ParenImpl.java index 809d5e1b..edc7e1c6 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ParenImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/ParenImpl.java @@ -27,16 +27,15 @@ public ParenImpl( Expression child ) { } @Override - public ParenthesizedExpression getInternal() { - return paren; - } - - @Override - public void materialize( AST ast ) { + public ParenthesizedExpression materialize( AST ast ) { + if (paren != null) { + return paren; + } paren = ast.newParenthesizedExpression(); if ( inner != null ) { paren.setExpression( wireAndGetExpression( inner, this, ast ) ); } + return paren; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/PostFixImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/PostFixImpl.java index 2cdabe04..c99873ce 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/PostFixImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/PostFixImpl.java @@ -27,17 +27,16 @@ public PostFixImpl( String op, BareArgument arg ) { } @Override - public PostfixExpression getInternal() { - return post; - } - - @Override - public void materialize( AST ast ) { + public PostfixExpression materialize( AST ast ) { + if (post != null) { + return post; + } post = ast.newPostfixExpression(); post.setOperator( PostfixExpression.Operator.toOperator( op ) ); if ( arg != null ) { post.setOperand( wireAndGetExpression( arg, this, ast ) ); } + return post; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SelfArgumentImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SelfArgumentImpl.java index a9ba6ddd..c3b44ebd 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SelfArgumentImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SelfArgumentImpl.java @@ -24,13 +24,12 @@ public SelfArgumentImpl() {} ThisExpression self; @Override - public ThisExpression getInternal() { - return self; - } - - @Override - public void materialize( AST ast ) { + public ThisExpression materialize( AST ast ) { + if (self != null) { + return self; + } self = ast.newThisExpression(); + return self; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SetterImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SetterImpl.java index fc579df8..79c96275 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SetterImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SetterImpl.java @@ -29,16 +29,15 @@ public SetterImpl( String fieldName, String type, Expression> valu } @Override - public MethodInvocation getInternal() { - return setter; - } - - @Override - public void materialize( AST ast ) { - super.materialize( ast ); + public MethodInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } + invoke = super.materialize( ast ); if ( value != null ) { setter.arguments().add( wireAndGetExpression( value, this, ast ) ); } + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StaticClassAccessorImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StaticClassAccessorImpl.java index c6fa8878..d64c2ca3 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StaticClassAccessorImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StaticClassAccessorImpl.java @@ -29,13 +29,12 @@ public StaticClassAccessorImpl( String name ) { } @Override - public Name getInternal() { - return klass; - } - - @Override - public void materialize( AST ast ) { + public Name materialize( AST ast ) { + if (klass != null) { + return klass; + } klass = ast.newName( name ); + return klass; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StringLiteralImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StringLiteralImpl.java index 67ccf153..ff9f1ae9 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StringLiteralImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/StringLiteralImpl.java @@ -26,13 +26,12 @@ public StringLiteralImpl( String val ) { } @Override - public StringLiteral getInternal() { - return literal; - } - - @Override - public void materialize( AST ast ) { + public StringLiteral materialize( AST ast ) { + if (literal != null) { + return literal; + } literal = ast.newStringLiteral(); literal.setLiteralValue( val ); + return literal; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperFieldImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperFieldImpl.java index a57e00ed..18f648e0 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperFieldImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperFieldImpl.java @@ -29,14 +29,13 @@ public SuperFieldImpl( String fieldName ) { } @Override - public SuperFieldAccess getInternal() { - return fld; - } - - @Override - public void materialize( AST ast ) { + public SuperFieldAccess materialize( AST ast ) { + if (fld != null) { + return fld; + } fld = ast.newSuperFieldAccess(); fld.setName( ast.newSimpleName( fieldName ) ); + return fld; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperGetterImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperGetterImpl.java index 980ebd9c..dfc6dded 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperGetterImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperGetterImpl.java @@ -39,14 +39,12 @@ public InvokeExpression setTarget( Expression> t } @Override - public SuperMethodInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public SuperMethodInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newSuperMethodInvocation(); - - getInternal().setName( ast.newSimpleName( method ) ); + invoke.setName( ast.newSimpleName( method ) ); + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperMethodInvokeImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperMethodInvokeImpl.java index fab3cbe0..b8b49d9a 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperMethodInvokeImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperMethodInvokeImpl.java @@ -24,18 +24,17 @@ public SuperMethodInvokeImpl( String method ) { } @Override - public SuperMethodInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public SuperMethodInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newSuperMethodInvocation(); invoke.setName( ast.newSimpleName( method ) ); for ( Argument> arg : arguments ) { invoke.arguments().add( wireAndGetExpression( arg, this, ast ) ); } + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperSetterImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperSetterImpl.java index 65b76f1b..4925ce9c 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperSetterImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/SuperSetterImpl.java @@ -29,17 +29,16 @@ public SuperSetterImpl( String fieldName, String type, Expression setElseExpression( Expression onFalse ) { } @Override - public ConditionalExpression getInternal() { - return ternary; - } - - @Override - public void materialize( AST ast ) { + public ConditionalExpression materialize( AST ast ) { + if (ternary != null) { + return ternary; + } ternary = ast.newConditionalExpression(); if ( condition != null ) { @@ -62,5 +60,6 @@ public void materialize( AST ast ) { if ( onFalse != null ) { ternary.setElseExpression( wireAndGetExpression( onFalse, this, ast ) ); } + return ternary; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/UnaryImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/UnaryImpl.java index f9977882..1e0c0a70 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/UnaryImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/UnaryImpl.java @@ -30,17 +30,16 @@ public UnaryImpl( PrefixOp op, Argument> expr ) { } @Override - public PrefixExpression getInternal() { - return expr; - } - - @Override - public void materialize( AST ast ) { + public PrefixExpression materialize( AST ast ) { + if (expr != null) { + return expr; + } expr = ast.newPrefixExpression(); expr.setOperator( PrefixExpression.Operator.toOperator( op.getOp() ) ); if ( arg != null ) { expr.setOperand( wireAndGetExpression( arg, this, ast ) ); } + return expr; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/VarArgumentImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/VarArgumentImpl.java index b157b8e5..0f64229e 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/VarArgumentImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/expressions/VarArgumentImpl.java @@ -29,13 +29,12 @@ public VarArgumentImpl( String name ) { } @Override - public Name getInternal() { - return var; - } - - @Override - public void materialize( AST ast ) { + public Name materialize( AST ast ) { + if (var != null) { + return var; + } var = ast.newName( name ); + return var; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/AssertStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/AssertStatementImpl.java index 1b314b89..d811e348 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/AssertStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/AssertStatementImpl.java @@ -24,12 +24,10 @@ public class AssertStatementImpl, T extends Block setLeft( Accessor left ) { return this; } - @Override - public ExpressionStatement getInternal() { - return statement; - } - - public void materialize( AST ast ) { + public ExpressionStatement materialize( AST ast ) { + if (statement != null) { + return statement; + } axx = ast.newAssignment(); axx.setOperator( Assignment.Operator.ASSIGN ); statement = ast.newExpressionStatement( axx ); @@ -57,6 +55,7 @@ public void materialize( AST ast ) { if ( right != null ) { axx.setRightHandSide( wireAndGetExpression( right, this, getAst() ) ); } + return statement; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BlockStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BlockStatementImpl.java index 86b5f5ca..9a34df9d 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BlockStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BlockStatementImpl.java @@ -43,17 +43,18 @@ public BlockStatement addStatement( Expression expression ) { } @Override - public org.eclipse.jdt.core.dom.Block getInternal() { - return block; - } + public org.eclipse.jdt.core.dom.Block materialize( AST ast ) { + if (block != null) { + return block; + } - @Override - public void materialize( AST ast ) { block = ast.newBlock(); for ( Statement statement : statements ) { block.statements().add( wireAndGetStatement( statement, this, ast ) ); } + + return block; } public BlockStatement wrap() { diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BreakStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BreakStatementImpl.java index 90696d14..39403591 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BreakStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/BreakStatementImpl.java @@ -24,16 +24,15 @@ public class BreakStatementImpl, T extends Block, T extends Block setCondition( Expression expr ) { } @Override - public DoStatement getInternal() { - return rep; - } - - @Override - public void materialize( AST ast ) { + public DoStatement materialize( AST ast ) { + if (rep != null) { + return rep; + } rep = ast.newDoStatement(); if ( body != null ) { @@ -54,5 +52,6 @@ public void materialize( AST ast ) { if ( condition != null ) { rep.setExpression( wireAndGetExpression( condition, this, ast ) ); } + return rep; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ExpressionStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ExpressionStatementImpl.java index 90298d29..0b47f329 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ExpressionStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ExpressionStatementImpl.java @@ -27,13 +27,11 @@ public ExpressionStatementImpl( Expression expr ) { public ExpressionStatementImpl() { } - @Override - public ExpressionStatement getInternal() { + public ExpressionStatement materialize( AST ast ) { + if (exprStatement == null) { + exprStatement = ast.newExpressionStatement(wireAndGetExpression(expression, this, getAst())); + } return exprStatement; } - public void materialize( AST ast ) { - exprStatement = ast.newExpressionStatement( wireAndGetExpression( expression, this, getAst() ) ); - } - } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForEachStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForEachStatementImpl.java index 3f45f87b..a389fd9a 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForEachStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForEachStatementImpl.java @@ -55,12 +55,10 @@ public ForEachStatement setBody( Statement statement ) { } @Override - public EnhancedForStatement getInternal() { - return iter; - } - - @Override - public void materialize( AST ast ) { + public EnhancedForStatement materialize( AST ast ) { + if (iter != null) { + return iter; + } iter = ast.newEnhancedForStatement(); iter.getParameter().setName( iter.getAST().newSimpleName( name ) ); @@ -72,5 +70,6 @@ public void materialize( AST ast ) { if ( body != null ) { iter.setBody( wireAndGetStatement( body.wrap(), this, ast ) ); } + return iter; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForStatementImpl.java index a9feaad0..7b066301 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ForStatementImpl.java @@ -66,12 +66,11 @@ public ForStatement setBody( Statement statement ) { } @Override - public org.eclipse.jdt.core.dom.ForStatement getInternal() { - return iter; - } + public org.eclipse.jdt.core.dom.ForStatement materialize( AST ast ) { + if (iter != null) { + return iter; + } - @Override - public void materialize( AST ast ) { iter = ast.newForStatement(); for ( DeclareExpression declaration : declarations ) { @@ -97,5 +96,7 @@ public void materialize( AST ast ) { if ( body != null ) { iter.setBody( wireAndGetStatement( body.wrap(), this, ast ) ); } + + return iter; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/IfStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/IfStatementImpl.java index cc2b9a4e..a8e3d78e 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/IfStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/IfStatementImpl.java @@ -47,12 +47,10 @@ public IfStatement setThen( Statement statement ) { } @Override - public org.eclipse.jdt.core.dom.IfStatement getInternal() { - return iff; - } - - @Override - public void materialize( AST ast ) { + public org.eclipse.jdt.core.dom.IfStatement materialize( AST ast ) { + if (iff != null) { + return iff; + } iff = ast.newIfStatement(); if ( condition != null ) { @@ -64,5 +62,6 @@ public void materialize( AST ast ) { if ( elseBody != null ) { iff.setElseStatement( wireAndGetStatement( elseBody.wrap(), this, ast ) ); } + return iff; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/InvokeStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/InvokeStatementImpl.java index 2a0ce7e6..af8c372f 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/InvokeStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/InvokeStatementImpl.java @@ -56,12 +56,10 @@ public InvokeStatement addArgument( Argument argument ) { } @Override - public ExpressionStatement getInternal() { - return statement; - } - - @Override - public void materialize( AST ast ) { + public ExpressionStatement materialize( AST ast ) { + if (statement != null) { + return statement; + } invoke = ast.newMethodInvocation(); statement = ast.newExpressionStatement( invoke ); @@ -74,5 +72,6 @@ public void materialize( AST ast ) { for ( Argument argument : argumentList ) { invoke.arguments().add( wireAndGetExpression( argument, this, ast ) ); } + return statement; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ReturnStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ReturnStatementImpl.java index 2f3bf4d4..7e883542 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ReturnStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ReturnStatementImpl.java @@ -30,16 +30,15 @@ public ReturnStatement setReturn( Expression expression ) { } @Override - public org.eclipse.jdt.core.dom.ReturnStatement getInternal() { - return ret; - } - - @Override - public void materialize( AST ast ) { + public org.eclipse.jdt.core.dom.ReturnStatement materialize( AST ast ) { + if (ret != null) { + return ret; + } ret = ast.newReturnStatement(); if ( result != null ) { ret.setExpression( wireAndGetExpression( result, this, ast ) ); } + return ret; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SuperStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SuperStatementImpl.java index 7c61e466..8bef8cdf 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SuperStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SuperStatementImpl.java @@ -39,16 +39,15 @@ public SuperStatement addArgument( Argument argument ) { } @Override - public SuperConstructorInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public SuperConstructorInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newSuperConstructorInvocation(); for ( Argument argument : argumentList ) { invoke.arguments().add( wireAndGetExpression( argument, this, ast ) ); } + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SwitchStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SwitchStatementImpl.java index 466e5023..38942b58 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SwitchStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SwitchStatementImpl.java @@ -33,12 +33,10 @@ public SwitchStatementImpl() { } @Override - public SwitchStatement getInternal() { - return opts; - } - - @Override - public void materialize( AST ast ) { + public SwitchStatement materialize( AST ast ) { + if (opts != null) { + return opts; + } opts = ast.newSwitchStatement(); opts.setExpression( wireAndGetExpression( expression, this, ast ) ); @@ -56,6 +54,7 @@ public void materialize( AST ast ) { opts.statements().add( wireAndGetStatement( stat, this, ast ) ); } } + return opts; } @Override diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SynchStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SynchStatementImpl.java index e0d0a363..f888cd18 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SynchStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/SynchStatementImpl.java @@ -28,12 +28,10 @@ public class SynchStatementImpl, T extends Block addArgument( Argument argument ) { } @Override - public ConstructorInvocation getInternal() { - return invoke; - } - - @Override - public void materialize( AST ast ) { + public ConstructorInvocation materialize( AST ast ) { + if (invoke != null) { + return invoke; + } invoke = ast.newConstructorInvocation(); for ( Argument argument : argumentList ) { invoke.arguments().add( wireAndGetExpression( argument, this, ast ) ); } + return invoke; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ThrowStatementImpl.java b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ThrowStatementImpl.java index 5393d2f7..1b81d40f 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ThrowStatementImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/model/impl/statements/ThrowStatementImpl.java @@ -24,15 +24,15 @@ public class ThrowStatementImpl, T extends Block, T extends Block setCondition( Expression expr ) { } @Override - public org.eclipse.jdt.core.dom.WhileStatement getInternal() { - return rep; - } - - @Override - public void materialize( AST ast ) { + public org.eclipse.jdt.core.dom.WhileStatement materialize( AST ast ) { + if (rep != null) { + return rep; + } rep = ast.newWhileStatement(); if ( body != null ) { @@ -53,5 +51,6 @@ public void materialize( AST ast ) { if ( condition != null ) { rep.setExpression( wireAndGetExpression( condition, this, ast ) ); } + return rep; } } diff --git a/impl/src/main/java/org/jboss/forge/roaster/spi/ExpressionFactoryImpl.java b/impl/src/main/java/org/jboss/forge/roaster/spi/ExpressionFactoryImpl.java index 07763909..3f93d7bd 100644 --- a/impl/src/main/java/org/jboss/forge/roaster/spi/ExpressionFactoryImpl.java +++ b/impl/src/main/java/org/jboss/forge/roaster/spi/ExpressionFactoryImpl.java @@ -74,12 +74,7 @@ public class ExpressionFactoryImpl, T extends Expression public ExpressionFactoryImpl() { } @Override - public J getInternal() { - throw new UnsupportedOperationException( "Method should not be called directly on this class" ); - } - - @Override - public void materialize( AST ast ) { + public J materialize( AST ast ) { throw new UnsupportedOperationException( "Method should not be called directly on this class" ); }