List of usage examples for org.eclipse.jdt.core.dom WhileStatement BODY_PROPERTY
ChildPropertyDescriptor BODY_PROPERTY
To view the source code for org.eclipse.jdt.core.dom WhileStatement BODY_PROPERTY.
Click Source Link
From source file:org.jboss.tools.arquillian.ui.internal.refactoring.AddMissingTypeRefactoring.java
License:Open Source License
private void insertAt(ASTNode target, Statement declaration) { //ASTRewrite rewrite= fCURewrite.getASTRewrite(); //TextEditGroup groupDescription= fCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractTempRefactoring_declare_local_variable); ASTNode parent = target.getParent(); StructuralPropertyDescriptor locationInParent = target.getLocationInParent(); while (locationInParent != Block.STATEMENTS_PROPERTY && locationInParent != SwitchStatement.STATEMENTS_PROPERTY) { if (locationInParent == IfStatement.THEN_STATEMENT_PROPERTY || locationInParent == IfStatement.ELSE_STATEMENT_PROPERTY || locationInParent == ForStatement.BODY_PROPERTY || locationInParent == EnhancedForStatement.BODY_PROPERTY || locationInParent == DoStatement.BODY_PROPERTY || locationInParent == WhileStatement.BODY_PROPERTY) { // create intermediate block if target was the body property of a control statement: Block replacement = rewrite.getAST().newBlock(); ListRewrite replacementRewrite = rewrite.getListRewrite(replacement, Block.STATEMENTS_PROPERTY); replacementRewrite.insertFirst(declaration, null); replacementRewrite.insertLast(rewrite.createMoveTarget(target), null); rewrite.replace(target, replacement, null); return; }/*from ww w . j av a 2s .c o m*/ target = parent; parent = parent.getParent(); locationInParent = target.getLocationInParent(); } ListRewrite lw = rewrite.getListRewrite(parent, (ChildListPropertyDescriptor) locationInParent); lw.insertBefore(declaration, target, null); }