Program: 12230
Project: 12230
Buggy source:
private void modifyVariableInstructionsInSubclass(List<Expression> oldVariableInstructions,List<Expression> newVariableInstructions,AST subclassAST,ASTRewrite subclassRewriter,Set<VariableDeclarationFragment> accessedFields,Set<VariableDeclarationFragment> assignedFields){
  int j=0;
  for (  Expression expression : newVariableInstructions) {
    SimpleName newSimpleName=(SimpleName)expression;
    SimpleName oldSimpleName=(SimpleName)oldVariableInstructions.get(j);
    Expression newParentExpression=null;
    Expression oldParentExpression=null;
    if (newSimpleName.getParent() instanceof QualifiedName) {
      newParentExpression=(QualifiedName)newSimpleName.getParent();
      oldParentExpression=(QualifiedName)oldSimpleName.getParent();
    }
 else     if (newSimpleName.getParent() instanceof FieldAccess) {
      newParentExpression=(FieldAccess)newSimpleName.getParent();
      oldParentExpression=(FieldAccess)oldSimpleName.getParent();
    }
 else {
      newParentExpression=newSimpleName;
      oldParentExpression=oldSimpleName;
    }
    if (newParentExpression.getParent() instanceof Assignment) {
      Assignment newAssignment=(Assignment)newParentExpression.getParent();
      Assignment oldAssignment=(Assignment)oldParentExpression.getParent();
      Expression newLeftHandSide=newAssignment.getLeftHandSide();
      Expression oldLeftHandSide=oldAssignment.getLeftHandSide();
      SimpleName newLeftHandSideName=null;
      SimpleName oldLeftHandSideName=null;
      if (newLeftHandSide instanceof SimpleName) {
        newLeftHandSideName=(SimpleName)newLeftHandSide;
        oldLeftHandSideName=(SimpleName)oldLeftHandSide;
      }
 else       if (newLeftHandSide instanceof QualifiedName) {
        QualifiedName newLeftHandSideQualifiedName=(QualifiedName)newLeftHandSide;
        newLeftHandSideName=newLeftHandSideQualifiedName.getName();
        QualifiedName oldLeftHandSideQualifiedName=(QualifiedName)oldLeftHandSide;
        oldLeftHandSideName=oldLeftHandSideQualifiedName.getName();
      }
 else       if (newLeftHandSide instanceof FieldAccess) {
        FieldAccess newLeftHandSideFieldAccess=(FieldAccess)newLeftHandSide;
        newLeftHandSideName=newLeftHandSideFieldAccess.getName();
        FieldAccess oldLeftHandSideFieldAccess=(FieldAccess)oldLeftHandSide;
        oldLeftHandSideName=oldLeftHandSideFieldAccess.getName();
      }
      Expression newRightHandSide=newAssignment.getRightHandSide();
      Expression oldRightHandSide=oldAssignment.getRightHandSide();
      SimpleName newRightHandSideName=null;
      SimpleName oldRightHandSideName=null;
      if (newRightHandSide instanceof SimpleName) {
        newRightHandSideName=(SimpleName)newRightHandSide;
        oldRightHandSideName=(SimpleName)oldRightHandSide;
      }
 else       if (newRightHandSide instanceof QualifiedName) {
        QualifiedName newRightHandSideQualifiedName=(QualifiedName)newRightHandSide;
        newRightHandSideName=newRightHandSideQualifiedName.getName();
        QualifiedName oldRightHandSideQualifiedName=(QualifiedName)oldRightHandSide;
        oldRightHandSideName=oldRightHandSideQualifiedName.getName();
      }
 else       if (newRightHandSide instanceof FieldAccess) {
        FieldAccess newRightHandSideFieldAccess=(FieldAccess)newRightHandSide;
        newRightHandSideName=newRightHandSideFieldAccess.getName();
        FieldAccess oldRightHandSideFieldAccess=(FieldAccess)oldRightHandSide;
        oldRightHandSideName=oldRightHandSideFieldAccess.getName();
      }
      String invokerName=sourceTypeDeclaration.getName().getIdentifier();
      invokerName=invokerName.substring(0,1).toLowerCase() + invokerName.substring(1,invokerName.length());
      if (newLeftHandSideName != null && newLeftHandSideName.equals(newSimpleName)) {
        for (        VariableDeclarationFragment assignedFragment : assignedFields) {
          if (assignedFragment.resolveBinding().isEqualTo(oldLeftHandSideName.resolveBinding())) {
            MethodInvocation leftHandMethodInvocation=subclassAST.newMethodInvocation();
            String leftHandMethodName=assignedFragment.getName().getIdentifier();
            leftHandMethodName="String_Node_Str" + leftHandMethodName.substring(0,1).toUpperCase() + leftHandMethodName.substring(1,leftHandMethodName.length());
            subclassRewriter.set(leftHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(leftHandMethodName),null);
            subclassRewriter.set(leftHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
            ListRewrite methodInvocationArgumentsRewrite=subclassRewriter.getListRewrite(leftHandMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            if (newRightHandSideName != null) {
              boolean accessedFieldFound=false;
              for (              VariableDeclarationFragment accessedFragment : accessedFields) {
                if (accessedFragment.resolveBinding().isEqualTo(oldRightHandSideName.resolveBinding())) {
                  MethodInvocation rightHandMethodInvocation=subclassAST.newMethodInvocation();
                  String rightHandMethodName=accessedFragment.getName().getIdentifier();
                  rightHandMethodName="String_Node_Str" + rightHandMethodName.substring(0,1).toUpperCase() + rightHandMethodName.substring(1,rightHandMethodName.length());
                  subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(rightHandMethodName),null);
                  subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
                  methodInvocationArgumentsRewrite.insertLast(rightHandMethodInvocation,null);
                  accessedFieldFound=true;
                  break;
                }
              }
              if (!accessedFieldFound)               methodInvocationArgumentsRewrite.insertLast(newAssignment.getRightHandSide(),null);
            }
 else {
              methodInvocationArgumentsRewrite.insertLast(newAssignment.getRightHandSide(),null);
            }
            subclassRewriter.replace(newAssignment,leftHandMethodInvocation,null);
            break;
          }
        }
      }
      if (newRightHandSideName != null && newRightHandSideName.equals(newSimpleName)) {
        for (        VariableDeclarationFragment accessedFragment : accessedFields) {
          if (accessedFragment.resolveBinding().isEqualTo(oldRightHandSideName.resolveBinding())) {
            MethodInvocation rightHandMethodInvocation=subclassAST.newMethodInvocation();
            String rightHandMethodName=accessedFragment.getName().getIdentifier();
            rightHandMethodName="String_Node_Str" + rightHandMethodName.substring(0,1).toUpperCase() + rightHandMethodName.substring(1,rightHandMethodName.length());
            subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(rightHandMethodName),null);
            subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
            subclassRewriter.set(newAssignment,Assignment.RIGHT_HAND_SIDE_PROPERTY,rightHandMethodInvocation,null);
            break;
          }
        }
      }
    }
 else {
      for (      VariableDeclarationFragment fragment : accessedFields) {
        if (fragment.resolveBinding().isEqualTo(oldSimpleName.resolveBinding())) {
          MethodInvocation methodInvocation=subclassAST.newMethodInvocation();
          String methodName=fragment.getName().getIdentifier();
          methodName="String_Node_Str" + methodName.substring(0,1).toUpperCase() + methodName.substring(1,methodName.length());
          subclassRewriter.set(methodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(methodName),null);
          String invokerName=sourceTypeDeclaration.getName().getIdentifier();
          invokerName=invokerName.substring(0,1).toLowerCase() + invokerName.substring(1,invokerName.length());
          subclassRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
          subclassRewriter.replace(newSimpleName,methodInvocation,null);
          break;
        }
      }
    }
    j++;
  }
}

Fixed version (ground truth):
private void modifyVariableInstructionsInSubclass(List<Expression> oldVariableInstructions,List<Expression> newVariableInstructions,AST subclassAST,ASTRewrite subclassRewriter,Set<VariableDeclarationFragment> accessedFields,Set<VariableDeclarationFragment> assignedFields){
  int j=0;
  for (  Expression expression : newVariableInstructions) {
    SimpleName newSimpleName=(SimpleName)expression;
    SimpleName oldSimpleName=(SimpleName)oldVariableInstructions.get(j);
    Expression newParentExpression=null;
    Expression oldParentExpression=null;
    if (newSimpleName.getParent() instanceof QualifiedName) {
      newParentExpression=(QualifiedName)newSimpleName.getParent();
      oldParentExpression=(QualifiedName)oldSimpleName.getParent();
    }
 else     if (newSimpleName.getParent() instanceof FieldAccess) {
      newParentExpression=(FieldAccess)newSimpleName.getParent();
      oldParentExpression=(FieldAccess)oldSimpleName.getParent();
    }
 else {
      newParentExpression=newSimpleName;
      oldParentExpression=oldSimpleName;
    }
    if (newParentExpression.getParent() instanceof Assignment) {
      Assignment newAssignment=(Assignment)newParentExpression.getParent();
      Assignment oldAssignment=(Assignment)oldParentExpression.getParent();
      Expression newLeftHandSide=newAssignment.getLeftHandSide();
      Expression oldLeftHandSide=oldAssignment.getLeftHandSide();
      SimpleName newLeftHandSideName=null;
      SimpleName oldLeftHandSideName=null;
      if (newLeftHandSide instanceof SimpleName) {
        newLeftHandSideName=(SimpleName)newLeftHandSide;
        oldLeftHandSideName=(SimpleName)oldLeftHandSide;
      }
 else       if (newLeftHandSide instanceof QualifiedName) {
        QualifiedName newLeftHandSideQualifiedName=(QualifiedName)newLeftHandSide;
        newLeftHandSideName=newLeftHandSideQualifiedName.getName();
        QualifiedName oldLeftHandSideQualifiedName=(QualifiedName)oldLeftHandSide;
        oldLeftHandSideName=oldLeftHandSideQualifiedName.getName();
      }
 else       if (newLeftHandSide instanceof FieldAccess) {
        FieldAccess newLeftHandSideFieldAccess=(FieldAccess)newLeftHandSide;
        newLeftHandSideName=newLeftHandSideFieldAccess.getName();
        FieldAccess oldLeftHandSideFieldAccess=(FieldAccess)oldLeftHandSide;
        oldLeftHandSideName=oldLeftHandSideFieldAccess.getName();
      }
      Expression newRightHandSide=newAssignment.getRightHandSide();
      Expression oldRightHandSide=oldAssignment.getRightHandSide();
      SimpleName newRightHandSideName=null;
      SimpleName oldRightHandSideName=null;
      if (newRightHandSide instanceof SimpleName) {
        newRightHandSideName=(SimpleName)newRightHandSide;
        oldRightHandSideName=(SimpleName)oldRightHandSide;
      }
 else       if (newRightHandSide instanceof QualifiedName) {
        QualifiedName newRightHandSideQualifiedName=(QualifiedName)newRightHandSide;
        newRightHandSideName=newRightHandSideQualifiedName.getName();
        QualifiedName oldRightHandSideQualifiedName=(QualifiedName)oldRightHandSide;
        oldRightHandSideName=oldRightHandSideQualifiedName.getName();
      }
 else       if (newRightHandSide instanceof FieldAccess) {
        FieldAccess newRightHandSideFieldAccess=(FieldAccess)newRightHandSide;
        newRightHandSideName=newRightHandSideFieldAccess.getName();
        FieldAccess oldRightHandSideFieldAccess=(FieldAccess)oldRightHandSide;
        oldRightHandSideName=oldRightHandSideFieldAccess.getName();
      }
      String invokerName=sourceTypeDeclaration.getName().getIdentifier();
      invokerName=invokerName.substring(0,1).toLowerCase() + invokerName.substring(1,invokerName.length());
      if (newLeftHandSideName != null && newLeftHandSideName.equals(newSimpleName)) {
        for (        VariableDeclarationFragment assignedFragment : assignedFields) {
          if (assignedFragment.resolveBinding().isEqualTo(oldLeftHandSideName.resolveBinding()) || assignedFragment.getName().getIdentifier().equals(newLeftHandSideName.getIdentifier())) {
            MethodInvocation leftHandMethodInvocation=subclassAST.newMethodInvocation();
            String leftHandMethodName=assignedFragment.getName().getIdentifier();
            leftHandMethodName="String_Node_Str" + leftHandMethodName.substring(0,1).toUpperCase() + leftHandMethodName.substring(1,leftHandMethodName.length());
            subclassRewriter.set(leftHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(leftHandMethodName),null);
            subclassRewriter.set(leftHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
            ListRewrite methodInvocationArgumentsRewrite=subclassRewriter.getListRewrite(leftHandMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            if (newRightHandSideName != null) {
              boolean accessedFieldFound=false;
              for (              VariableDeclarationFragment accessedFragment : accessedFields) {
                if (accessedFragment.resolveBinding().isEqualTo(oldRightHandSideName.resolveBinding()) || accessedFragment.getName().getIdentifier().equals(newRightHandSideName.getIdentifier())) {
                  MethodInvocation rightHandMethodInvocation=subclassAST.newMethodInvocation();
                  String rightHandMethodName=accessedFragment.getName().getIdentifier();
                  rightHandMethodName="String_Node_Str" + rightHandMethodName.substring(0,1).toUpperCase() + rightHandMethodName.substring(1,rightHandMethodName.length());
                  subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(rightHandMethodName),null);
                  subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
                  methodInvocationArgumentsRewrite.insertLast(rightHandMethodInvocation,null);
                  accessedFieldFound=true;
                  break;
                }
              }
              if (!accessedFieldFound)               methodInvocationArgumentsRewrite.insertLast(newAssignment.getRightHandSide(),null);
            }
 else {
              methodInvocationArgumentsRewrite.insertLast(newAssignment.getRightHandSide(),null);
            }
            subclassRewriter.replace(newAssignment,leftHandMethodInvocation,null);
            break;
          }
        }
      }
      if (newRightHandSideName != null && newRightHandSideName.equals(newSimpleName)) {
        for (        VariableDeclarationFragment accessedFragment : accessedFields) {
          if (accessedFragment.resolveBinding().isEqualTo(oldRightHandSideName.resolveBinding()) || accessedFragment.getName().getIdentifier().equals(newRightHandSideName.getIdentifier())) {
            MethodInvocation rightHandMethodInvocation=subclassAST.newMethodInvocation();
            String rightHandMethodName=accessedFragment.getName().getIdentifier();
            rightHandMethodName="String_Node_Str" + rightHandMethodName.substring(0,1).toUpperCase() + rightHandMethodName.substring(1,rightHandMethodName.length());
            subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(rightHandMethodName),null);
            subclassRewriter.set(rightHandMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
            subclassRewriter.set(newAssignment,Assignment.RIGHT_HAND_SIDE_PROPERTY,rightHandMethodInvocation,null);
            break;
          }
        }
      }
    }
 else {
      for (      VariableDeclarationFragment fragment : accessedFields) {
        if (fragment.resolveBinding().isEqualTo(oldSimpleName.resolveBinding()) || fragment.getName().getIdentifier().equals(newSimpleName.getIdentifier())) {
          MethodInvocation methodInvocation=subclassAST.newMethodInvocation();
          String methodName=fragment.getName().getIdentifier();
          methodName="String_Node_Str" + methodName.substring(0,1).toUpperCase() + methodName.substring(1,methodName.length());
          subclassRewriter.set(methodInvocation,MethodInvocation.NAME_PROPERTY,subclassAST.newSimpleName(methodName),null);
          String invokerName=sourceTypeDeclaration.getName().getIdentifier();
          invokerName=invokerName.substring(0,1).toLowerCase() + invokerName.substring(1,invokerName.length());
          subclassRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,subclassAST.newSimpleName(invokerName),null);
          subclassRewriter.replace(newSimpleName,methodInvocation,null);
          break;
        }
      }
    }
    j++;
  }
}