Example usage for org.eclipse.jdt.core.dom PostfixExpression setOperand

List of usage examples for org.eclipse.jdt.core.dom PostfixExpression setOperand

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom PostfixExpression setOperand.

Prototype

public void setOperand(Expression expression) 

Source Link

Document

Sets the operand of this postfix expression.

Usage

From source file:com.google.devtools.j2objc.translate.ASTFactory.java

License:Apache License

public static PostfixExpression newPostfixExpression(AST ast, IVariableBinding var,
        PostfixExpression.Operator op) {
    PostfixExpression expr = ast.newPostfixExpression();
    expr.setOperator(op);/* ww  w . ja  v a2 s.co  m*/
    expr.setOperand(newSimpleName(ast, var));
    Types.addBinding(expr, var.getType());
    return expr;
}

From source file:java5totext.input.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(org.eclipse.jdt.core.dom.PostfixExpression node) {
    PostfixExpression element = (PostfixExpression) this.binding.get(node);
    this.initializeNode(element, node);
    element.setOperator(node.getOperator().toString());

    if (this.binding.get(node.getOperand()) != null)
        element.setOperand((Expression) this.binding.get(node.getOperand()));
}

From source file:org.decojer.cavaj.utils.Expressions.java

License:Open Source License

/**
 * New postfix expression.//w  ww . j a  v  a2  s  .c  o m
 *
 * @param operator
 *            postfix expression operator
 * @param operand
 *            operand expression
 * @param op
 *            originating operation
 * @return expression
 */
@Nonnull
public static PostfixExpression newPostfixExpression(@Nullable final PostfixExpression.Operator operator,
        @Nonnull final Expression operand, @Nonnull final Op op) {
    final PostfixExpression postfixExpression = setOp(operand.getAST().newPostfixExpression(), op);
    postfixExpression.setOperator(operator);
    postfixExpression.setOperand(wrap(operand, Priority.priority(postfixExpression)));
    return postfixExpression;
}

From source file:org.eclipse.jdt.core.dom.ASTConverter.java

License:Open Source License

public PostfixExpression convert(org.eclipse.jdt.internal.compiler.ast.PostfixExpression expression) {
    final PostfixExpression postfixExpression = new PostfixExpression(this.ast);
    if (this.resolveBindings) {
        recordNodes(postfixExpression, expression);
    }/*  w w  w  . j  a  va2 s.co m*/
    postfixExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
    postfixExpression.setOperand(convert(expression.lhs));
    switch (expression.operator) {
    case org.eclipse.jdt.internal.compiler.ast.OperatorIds.PLUS:
        postfixExpression.setOperator(PostfixExpression.Operator.INCREMENT);
        break;
    case org.eclipse.jdt.internal.compiler.ast.OperatorIds.MINUS:
        postfixExpression.setOperator(PostfixExpression.Operator.DECREMENT);
        break;
    }
    return postfixExpression;
}

From source file:org.eclipse.modisco.java.discoverer.internal.io.java.JDTVisitor.java

License:Open Source License

@Override
public void endVisit(final org.eclipse.jdt.core.dom.PostfixExpression node) {
    PostfixExpression element = (PostfixExpression) this.binding.get(node);
    initializeNode(element, node);//w  w w .  j a va2s  . com

    element.setOperator(PostfixExpressionKind.get(node.getOperator().toString()));

    if (this.binding.get(node.getOperand()) != null) {
        element.setOperand(JDTVisitorUtils.completeExpression(this.binding.get(node.getOperand()), this));
    }
}

From source file:org.mpi.vasco.sieve.staticanalysis.templatecreator.DatabaseTableClassCreator.java

License:Open Source License

/**
 * Creates the is contained function./*from w  ww . jav  a 2s.c o  m*/
 *
 * @return the method declaration
 */
public MethodDeclaration createIsContainedFunction() {
    String methodName = "isContained";
    MethodDeclaration methodDeclaration = super.createMethodDeclaration(PrimitiveType.BOOLEAN, methodName,
            ModifierKeyword.PUBLIC_KEYWORD);
    String recordName = tableInstance.get_Table_Name() + DatabaseRecordClassCreator.RECORDSTRING;
    SingleVariableDeclaration varDecl = super.createVariableDeclaration(recordName, recordName.toLowerCase(),
            false);
    methodDeclaration.parameters().add(varDecl);
    org.eclipse.jdt.core.dom.Block block = super.getASTNode().newBlock();
    //add the index variable
    String indexVar = "i";
    VariableDeclarationStatement varDeclStmt = super.createVariableDeclarationStatement(PrimitiveType.INT,
            indexVar, false, null);
    block.statements().add(varDeclStmt);

    //put a for loop here
    ForStatement forStmt = super.getASTNode().newForStatement();
    //set initializer
    Assignment assignExpr = super.getASTNode().newAssignment();
    assignExpr.setOperator(Assignment.Operator.ASSIGN);
    assignExpr.setLeftHandSide(super.getASTNode().newSimpleName(indexVar));
    NumberLiteral initializedValue = super.getASTNode().newNumberLiteral("0");
    assignExpr.setRightHandSide(initializedValue);
    forStmt.initializers().add(assignExpr);

    //set condition expression

    InfixExpression infixExpr = super.getASTNode().newInfixExpression();
    infixExpr.setOperator(InfixExpression.Operator.LESS);
    infixExpr.setLeftOperand(super.getASTNode().newSimpleName(indexVar));

    FieldAccess fieldA = super.getASTNode().newFieldAccess();
    fieldA.setExpression(super.getASTNode().newThisExpression());
    fieldA.setName(super.getASTNode().newSimpleName("size"));
    infixExpr.setRightOperand(fieldA);

    forStmt.setExpression(infixExpr);

    //set update
    PostfixExpression updateExpr = super.getASTNode().newPostfixExpression();
    updateExpr.setOperator(PostfixExpression.Operator.INCREMENT);
    updateExpr.setOperand(super.getASTNode().newSimpleName(indexVar));

    forStmt.updaters().add(updateExpr);

    //set for loop body
    org.eclipse.jdt.core.dom.Block forLoopBlock = super.getASTNode().newBlock();

    //add a if statement

    IfStatement ifStmt = super.getASTNode().newIfStatement();

    //set if condition
    InfixExpression ifCondExp = super.getASTNode().newInfixExpression();
    //left expr is in the form: this.table[i]
    ArrayAccess arrayA = super.getASTNode().newArrayAccess();
    FieldAccess tableFieldA = super.getASTNode().newFieldAccess();
    tableFieldA.setExpression(super.getASTNode().newThisExpression());
    tableFieldA.setName(super.getASTNode().newSimpleName("table"));
    arrayA.setArray(tableFieldA);
    arrayA.setIndex(super.getASTNode().newSimpleName(indexVar));
    ifCondExp.setLeftOperand(arrayA);
    //equal operator
    ifCondExp.setOperator(InfixExpression.Operator.EQUALS);
    //right expr
    ifCondExp.setRightOperand(super.getASTNode().newSimpleName(recordName.toLowerCase()));

    ifStmt.setExpression(ifCondExp);
    //add block for ifStmt
    org.eclipse.jdt.core.dom.Block ifBlock = super.getASTNode().newBlock();

    ReturnStatement trueReturnStmt = super.getASTNode().newReturnStatement();
    BooleanLiteral trueValue = super.getASTNode().newBooleanLiteral(true);
    trueReturnStmt.setExpression(trueValue);

    ifBlock.statements().add(trueReturnStmt);
    ifStmt.setThenStatement(ifBlock);
    forLoopBlock.statements().add(ifStmt);
    forStmt.setBody(forLoopBlock);

    block.statements().add(forStmt);

    //return false
    ReturnStatement falseReturnStmt = super.getASTNode().newReturnStatement();
    BooleanLiteral falseValue = super.getASTNode().newBooleanLiteral(false);
    falseReturnStmt.setExpression(falseValue);
    block.statements().add(falseReturnStmt);

    methodDeclaration.setBody(block);
    return methodDeclaration;
}

From source file:org.mpi.vasco.sieve.staticanalysis.templatecreator.DatabaseTableClassCreator.java

License:Open Source License

/**
 * Creates the get index function.//from  w w  w . j  a v  a2 s. c om
 *
 * @return the method declaration
 */
public MethodDeclaration createGetIndexFunction() {
    String methodName = "getIndex";
    MethodDeclaration methodDeclaration = super.createMethodDeclaration(PrimitiveType.INT, methodName,
            ModifierKeyword.PUBLIC_KEYWORD);
    String recordName = tableInstance.get_Table_Name() + DatabaseRecordClassCreator.RECORDSTRING;
    SingleVariableDeclaration varDecl = super.createVariableDeclaration(recordName, recordName.toLowerCase(),
            false);
    methodDeclaration.parameters().add(varDecl);
    org.eclipse.jdt.core.dom.Block block = super.getASTNode().newBlock();
    //add the index variable
    String indexVar = "i";
    VariableDeclarationStatement varDeclStmt = super.createVariableDeclarationStatement(PrimitiveType.INT,
            indexVar, false, null);
    block.statements().add(varDeclStmt);

    //put a for loop here
    ForStatement forStmt = super.getASTNode().newForStatement();
    //set initializer
    Assignment assignExpr = super.getASTNode().newAssignment();
    assignExpr.setOperator(Assignment.Operator.ASSIGN);
    assignExpr.setLeftHandSide(super.getASTNode().newSimpleName(indexVar));
    NumberLiteral initializedValue = super.getASTNode().newNumberLiteral("0");
    assignExpr.setRightHandSide(initializedValue);
    forStmt.initializers().add(assignExpr);

    //set condition expression

    InfixExpression infixExpr = super.getASTNode().newInfixExpression();
    infixExpr.setOperator(InfixExpression.Operator.LESS);
    infixExpr.setLeftOperand(super.getASTNode().newSimpleName(indexVar));

    FieldAccess fieldA = super.getASTNode().newFieldAccess();
    fieldA.setExpression(super.getASTNode().newThisExpression());
    fieldA.setName(super.getASTNode().newSimpleName("size"));
    infixExpr.setRightOperand(fieldA);

    forStmt.setExpression(infixExpr);

    //set update
    PostfixExpression updateExpr = super.getASTNode().newPostfixExpression();
    updateExpr.setOperator(PostfixExpression.Operator.INCREMENT);
    updateExpr.setOperand(super.getASTNode().newSimpleName(indexVar));

    forStmt.updaters().add(updateExpr);

    //set for loop body
    org.eclipse.jdt.core.dom.Block forLoopBlock = super.getASTNode().newBlock();

    //add a if statement

    IfStatement ifStmt = super.getASTNode().newIfStatement();

    //set if condition
    InfixExpression ifCondExp = super.getASTNode().newInfixExpression();
    //left expr is in the form: this.table[i]
    ArrayAccess arrayA = super.getASTNode().newArrayAccess();
    FieldAccess tableFieldA = super.getASTNode().newFieldAccess();
    tableFieldA.setExpression(super.getASTNode().newThisExpression());
    tableFieldA.setName(super.getASTNode().newSimpleName("table"));
    arrayA.setArray(tableFieldA);
    arrayA.setIndex(super.getASTNode().newSimpleName(indexVar));
    ifCondExp.setLeftOperand(arrayA);
    //equal operator
    ifCondExp.setOperator(InfixExpression.Operator.EQUALS);
    //right expr
    ifCondExp.setRightOperand(super.getASTNode().newSimpleName(recordName.toLowerCase()));

    ifStmt.setExpression(ifCondExp);
    //add block for ifStmt
    org.eclipse.jdt.core.dom.Block ifBlock = super.getASTNode().newBlock();

    ReturnStatement indexReturnStmt = super.getASTNode().newReturnStatement();
    indexReturnStmt.setExpression(super.getASTNode().newSimpleName(indexVar));

    ifBlock.statements().add(indexReturnStmt);
    ifStmt.setThenStatement(ifBlock);
    forLoopBlock.statements().add(ifStmt);
    forStmt.setBody(forLoopBlock);

    block.statements().add(forStmt);

    //return false
    ReturnStatement noIndexReturnStmt = super.getASTNode().newReturnStatement();
    NumberLiteral noIndexValue = super.getASTNode().newNumberLiteral("-1");
    noIndexReturnStmt.setExpression(noIndexValue);
    block.statements().add(noIndexReturnStmt);

    methodDeclaration.setBody(block);
    return methodDeclaration;
}

From source file:ptolemy.backtrack.eclipse.ast.transform.AssignmentTransformer.java

License:Open Source License

/** Create the body of an assignment method, which backs up the field
 *  before a new value is assigned to it.
 *
 *  @param ast The {@link AST} object.//  ww  w.  j a va  2 s .  c  om
 *  @param state The current state of the type analyzer.
 *  @param fieldName The name of the field.
 *  @param fieldType The type of the left-hand side (with <tt>indices</tt>
 *   dimensions less than the original field type).
 *  @param indices The number of indices.
 *  @param special Whether to handle special assign operators.
 *  @return The body of the assignment method.
 */
private Block _createAssignmentBlock(AST ast, TypeAnalyzerState state, String fieldName, Type fieldType,
        int indices, boolean special) {
    Block block = ast.newBlock();

    // Test if the checkpoint object is not null.
    IfStatement ifStatement = ast.newIfStatement();
    InfixExpression testExpression = ast.newInfixExpression();

    InfixExpression condition1 = ast.newInfixExpression();
    condition1.setLeftOperand(ast.newSimpleName(CHECKPOINT_NAME));
    condition1.setOperator(InfixExpression.Operator.NOT_EQUALS);
    condition1.setRightOperand(ast.newNullLiteral());

    InfixExpression condition2 = ast.newInfixExpression();
    MethodInvocation getTimestamp = ast.newMethodInvocation();
    getTimestamp.setExpression(ast.newSimpleName(CHECKPOINT_NAME));
    getTimestamp.setName(ast.newSimpleName("getTimestamp"));
    condition2.setLeftOperand(getTimestamp);
    condition2.setOperator(InfixExpression.Operator.GREATER);
    condition2.setRightOperand(ast.newNumberLiteral("0"));

    testExpression.setLeftOperand(condition1);
    testExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
    testExpression.setRightOperand(condition2);
    ifStatement.setExpression(testExpression);

    // The "then" branch.
    Block thenBranch = ast.newBlock();

    // Method call to store old value.
    MethodInvocation recordInvocation = ast.newMethodInvocation();
    recordInvocation.setExpression(ast.newSimpleName(_getRecordName(fieldName)));
    recordInvocation.setName(ast.newSimpleName("add"));

    // If there are indices, create an integer array of those indices,
    // and add it as an argument.
    if (indices == 0) {
        recordInvocation.arguments().add(ast.newNullLiteral());
    } else {
        ArrayCreation arrayCreation = ast.newArrayCreation();
        ArrayType arrayType = ast.newArrayType(ast.newPrimitiveType(PrimitiveType.INT));
        ArrayInitializer initializer = ast.newArrayInitializer();

        for (int i = 0; i < indices; i++) {
            initializer.expressions().add(ast.newSimpleName("index" + i));
        }

        arrayCreation.setType(arrayType);
        arrayCreation.setInitializer(initializer);
        recordInvocation.arguments().add(arrayCreation);
    }

    // If there are indices, add them ("index0", "index1", ...) after the
    // field.
    Expression field = ast.newSimpleName(fieldName);

    if (indices > 0) {
        for (int i = 0; i < indices; i++) {
            ArrayAccess arrayAccess = ast.newArrayAccess();
            arrayAccess.setArray(field);
            arrayAccess.setIndex(ast.newSimpleName("index" + i));
            field = arrayAccess;
        }
    }

    // Set the field as the next argument.
    recordInvocation.arguments().add(field);

    // Get current timestamp from the checkpoint object.
    MethodInvocation timestampGetter = ast.newMethodInvocation();
    timestampGetter.setExpression(ast.newSimpleName(CHECKPOINT_NAME));
    timestampGetter.setName(ast.newSimpleName("getTimestamp"));

    // Set the timestamp as the next argument.
    recordInvocation.arguments().add(timestampGetter);

    // The statement of the method call.
    ExpressionStatement recordStatement = ast.newExpressionStatement(recordInvocation);
    thenBranch.statements().add(recordStatement);

    ifStatement.setThenStatement(thenBranch);
    block.statements().add(ifStatement);

    // Finally, assign the new value to the field.
    Assignment assignment = ast.newAssignment();
    assignment.setLeftHandSide((Expression) ASTNode.copySubtree(ast, field));
    assignment.setRightHandSide(ast.newSimpleName("newValue"));
    assignment.setOperator(Assignment.Operator.ASSIGN);

    // Set the checkpoint object of the new value, if necessary.
    Class c;

    try {
        c = fieldType.toClass(state.getClassLoader());
    } catch (ClassNotFoundException e) {
        throw new ASTClassNotFoundException(fieldType.getName());
    }

    if (hasMethod(c, _getSetCheckpointMethodName(false), new Class[] { Checkpoint.class })
            || state.getCrossAnalyzedTypes().contains(c.getName())) {
        block.statements().add(_createSetCheckpointInvocation(ast));
    } else {
        addToLists(_fixSetCheckpoint, c.getName(), block);
    }

    // Return the result of the assignment.
    if (special && _assignOperators.containsKey(fieldType.getName())) {
        String[] operators = _assignOperators.get(fieldType.getName());

        SwitchStatement switchStatement = ast.newSwitchStatement();
        switchStatement.setExpression(ast.newSimpleName("operator"));

        boolean isPostfix = true;

        for (int i = 0; i < operators.length; i++) {
            String operator = operators[i];

            SwitchCase switchCase = ast.newSwitchCase();
            switchCase.setExpression(ast.newNumberLiteral(Integer.toString(i)));
            switchStatement.statements().add(switchCase);

            ReturnStatement returnStatement = ast.newReturnStatement();

            if (operator.equals("=")) {
                Assignment newAssignment = (Assignment) ASTNode.copySubtree(ast, assignment);
                returnStatement.setExpression(newAssignment);
            } else if (operator.equals("++") || operator.equals("--")) {
                Expression expression;

                if (isPostfix) {
                    PostfixExpression postfix = ast.newPostfixExpression();
                    postfix.setOperand((Expression) ASTNode.copySubtree(ast, assignment.getLeftHandSide()));
                    postfix.setOperator(PostfixExpression.Operator.toOperator(operator));
                    expression = postfix;

                    // Produce prefix operators next time.
                    if (operator.equals("--")) {
                        isPostfix = false;
                    }
                } else {
                    PrefixExpression prefix = ast.newPrefixExpression();
                    prefix.setOperand((Expression) ASTNode.copySubtree(ast, assignment.getLeftHandSide()));
                    prefix.setOperator(PrefixExpression.Operator.toOperator(operator));
                    expression = prefix;
                }

                returnStatement.setExpression(expression);
            } else {
                Assignment newAssignment = (Assignment) ASTNode.copySubtree(ast, assignment);
                newAssignment.setOperator(Assignment.Operator.toOperator(operator));
                returnStatement.setExpression(newAssignment);
            }

            switchStatement.statements().add(returnStatement);
        }

        // The default statement: just return the old value.
        // This case should not be reached.
        SwitchCase defaultCase = ast.newSwitchCase();
        defaultCase.setExpression(null);
        switchStatement.statements().add(defaultCase);

        ReturnStatement defaultReturn = ast.newReturnStatement();
        defaultReturn.setExpression((Expression) ASTNode.copySubtree(ast, assignment.getLeftHandSide()));
        switchStatement.statements().add(defaultReturn);

        block.statements().add(switchStatement);
    } else {
        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(assignment);
        block.statements().add(returnStatement);
    }

    return block;
}

From source file:refactorer.Refactorer.java

License:Apache License

@SuppressWarnings("unchecked")
protected void processTypeDeclaration(AbstractTypeDeclaration type) {
    if (type == null)
        return;//w  w w.  j  a v  a 2 s  .c o m

    List<BodyDeclaration> bodies = type.bodyDeclarations();
    for (BodyDeclaration body : bodies) {
        processBodyDeclaration(body);
    }

    if (type.getNodeType() == ASTNode.TYPE_DECLARATION) {
        TypeDeclaration typeDeclaration = (TypeDeclaration) type;

        if (typeDeclaration.getSuperclassType() != null) {
            ITypeBinding superclass = typeDeclaration.getSuperclassType().resolveBinding();
            if (superclass != null) {
                if ("javax.media.opengl.GLCanvas".equals(superclass.getQualifiedName())) {
                    addImportIfRequired("javax.media.opengl.awt.GLCanvas");
                } else if ("javax.media.opengl.GLJPanel".equals(superclass.getQualifiedName())) {
                    addImportIfRequired("javax.media.opengl.awt.GLJPanel");
                }
            }
        }

        for (Type interfaceType : (List<Type>) typeDeclaration.superInterfaceTypes()) {
            ITypeBinding binding = interfaceType.resolveBinding();
            if (binding != null) {
                String interfaceName = binding.getQualifiedName();
                if ("javax.media.opengl.GLEventListener".equals(interfaceName)) {
                    for (int i = bodies.size() - 1; i >= 0; i--) {
                        BodyDeclaration body = bodies.get(i);
                        if (body.getNodeType() == ASTNode.METHOD_DECLARATION) {
                            MethodDeclaration methodDeclaration = (MethodDeclaration) body;
                            if ("displayChanged".equals(methodDeclaration.getName().getFullyQualifiedName())) {
                                bodies.remove(i);
                            }
                        }
                    }

                    AST ast = typeDeclaration.getAST();
                    MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
                    methodDeclaration.setName(ast.newSimpleName("dispose"));
                    methodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
                    methodDeclaration.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
                    Block block = ast.newBlock();
                    methodDeclaration.setBody(block);
                    SingleVariableDeclaration parameter = ast.newSingleVariableDeclaration();
                    parameter.setName(ast.newSimpleName("glDrawable"));
                    parameter.setType(ast.newSimpleType(ast.newName("GLAutoDrawable")));
                    methodDeclaration.parameters().add(parameter);
                    bodies.add(methodDeclaration);

                    if ("performance.VBORenderer.GLDisplay.MyGLEventListener"
                            .equals(type.resolveBinding().getQualifiedName())) {
                        ForStatement forStatement = ast.newForStatement();

                        VariableDeclarationFragment forInitializerFragment = ast
                                .newVariableDeclarationFragment();
                        forInitializerFragment.setName(ast.newSimpleName("i"));
                        forInitializerFragment.setInitializer(ast.newNumberLiteral("0"));
                        VariableDeclarationExpression forInitializer = ast
                                .newVariableDeclarationExpression(forInitializerFragment);
                        forInitializer.setType(ast.newPrimitiveType(PrimitiveType.INT));
                        forStatement.initializers().add(forInitializer);

                        InfixExpression forExpression = ast.newInfixExpression();
                        forExpression.setLeftOperand(ast.newSimpleName("i"));
                        forExpression.setOperator(InfixExpression.Operator.LESS);
                        MethodInvocation rightOperand = ast.newMethodInvocation();
                        rightOperand.setExpression(ast.newSimpleName("eventListeners"));
                        rightOperand.setName(ast.newSimpleName("size"));
                        forExpression.setRightOperand(rightOperand);
                        forStatement.setExpression(forExpression);

                        PostfixExpression forUpdater = ast.newPostfixExpression();
                        forUpdater.setOperand(ast.newSimpleName("i"));
                        forUpdater.setOperator(PostfixExpression.Operator.INCREMENT);
                        forStatement.updaters().add(forUpdater);

                        Block forBlock = ast.newBlock();
                        MethodInvocation mi1 = ast.newMethodInvocation();
                        mi1.setName(ast.newSimpleName("dispose"));
                        mi1.arguments().add(ast.newName("glDrawable"));
                        CastExpression castExpression = ast.newCastExpression();
                        castExpression.setType(ast.newSimpleType(ast.newName("GLEventListener")));
                        MethodInvocation mi2 = ast.newMethodInvocation();
                        mi2.setExpression(ast.newName("eventListeners"));
                        mi2.setName(ast.newSimpleName("get"));
                        mi2.arguments().add(ast.newName("i"));
                        castExpression.setExpression(mi2);
                        ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
                        parenthesizedExpression.setExpression(castExpression);
                        mi1.setExpression(parenthesizedExpression);
                        forBlock.statements().add(ast.newExpressionStatement(mi1));
                        forStatement.setBody(forBlock);

                        block.statements().add(forStatement);
                    }
                } else if ("com.sun.opengl.impl.packrect.BackingStoreManager".equals(interfaceName)) {
                    AST ast = typeDeclaration.getAST();
                    MethodDeclaration newMethodDeclaration = ast.newMethodDeclaration();
                    newMethodDeclaration.setName(ast.newSimpleName("canCompact"));
                    newMethodDeclaration.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
                    newMethodDeclaration.setReturnType2(ast.newPrimitiveType(PrimitiveType.BOOLEAN));
                    Block block = ast.newBlock();
                    ReturnStatement returnStatement = ast.newReturnStatement();
                    returnStatement.setExpression(ast.newBooleanLiteral(false));
                    block.statements().add(returnStatement);
                    newMethodDeclaration.setBody(block);
                    bodies.add(newMethodDeclaration);

                    if ("gov.nasa.worldwind.util.TextureAtlas.AtlasBackingStore"
                            .equals(type.resolveBinding().getQualifiedName())) {
                        for (BodyDeclaration body : (List<BodyDeclaration>) typeDeclaration
                                .bodyDeclarations()) {
                            if (body.getNodeType() == ASTNode.METHOD_DECLARATION) {
                                MethodDeclaration methodDeclaration = (MethodDeclaration) body;
                                if ("additionFailed"
                                        .equals(methodDeclaration.getName().getFullyQualifiedName())) {
                                    methodDeclaration
                                            .setReturnType2(ast.newPrimitiveType(PrimitiveType.BOOLEAN));
                                    Block body2 = methodDeclaration.getBody();
                                    if (!body2.statements().isEmpty()) {
                                        Statement firstStatement = (Statement) body2.statements().get(0);
                                        if (firstStatement.getNodeType() == ASTNode.IF_STATEMENT) {
                                            IfStatement ifStatement = (IfStatement) firstStatement;
                                            Expression expression = ifStatement.getExpression();
                                            ifStatement.setExpression(ast.newBooleanLiteral(true));
                                            ReturnStatement newReturnStatement = ast.newReturnStatement();
                                            newReturnStatement.setExpression(expression);
                                            body2.statements().clear();
                                            body2.statements().add(newReturnStatement);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}