Program: 12226
Project: 12226
Buggy source:
private void replaceTargetClassVariableNameWithThisExpressionInMethodInvocationArguments(MethodDeclaration newMethodDeclaration){
  ExpressionExtractor extractor=new ExpressionExtractor();
  List<Expression> sourceMethodInvocations=extractor.getMethodInvocations(sourceMethod.getBody());
  List<Expression> newMethodInvocations=extractor.getMethodInvocations(newMethodDeclaration.getBody());
  int i=0;
  for (  Expression invocation : newMethodInvocations) {
    if (invocation instanceof MethodInvocation) {
      MethodInvocation methodInvocation=(MethodInvocation)invocation;
      List<Expression> arguments=methodInvocation.arguments();
      for (      Expression argument : arguments) {
        if (argument instanceof SimpleName) {
          SimpleName simpleNameArgument=(SimpleName)argument;
          if (simpleNameArgument.getIdentifier().equals(targetClassVariableName)) {
            ListRewrite argumentRewrite=targetRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            MethodInvocation sourceMethodInvocation=(MethodInvocation)sourceMethodInvocations.get(i);
            AST ast=newMethodDeclaration.getAST();
            if (sourceMethod.resolveBinding().isEqualTo(sourceMethodInvocation.resolveMethodBinding())) {
              targetRewriter.set(methodInvocation,MethodInvocation.NAME_PROPERTY,ast.newSimpleName(movedMethodName),null);
              argumentRewrite.remove(argument,null);
            }
 else {
              argumentRewrite.replace(argument,ast.newThisExpression(),null);
            }
          }
        }
 else         if (argument instanceof FieldAccess) {
          FieldAccess fieldAccess=(FieldAccess)argument;
          SimpleName simpleNameArgument=fieldAccess.getName();
          if (simpleNameArgument.getIdentifier().equals(targetClassVariableName)) {
            ListRewrite argumentRewrite=targetRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            MethodInvocation sourceMethodInvocation=(MethodInvocation)sourceMethodInvocations.get(i);
            AST ast=newMethodDeclaration.getAST();
            if (sourceMethod.resolveBinding().isEqualTo(sourceMethodInvocation.resolveMethodBinding())) {
              targetRewriter.set(methodInvocation,MethodInvocation.NAME_PROPERTY,ast.newSimpleName(movedMethodName),null);
              argumentRewrite.remove(argument,null);
            }
 else {
              argumentRewrite.replace(argument,ast.newThisExpression(),null);
            }
          }
        }
      }
    }
    i++;
  }
}

Fixed version (ground truth):
private void replaceTargetClassVariableNameWithThisExpressionInMethodInvocationArguments(MethodDeclaration newMethodDeclaration){
  ExpressionExtractor extractor=new ExpressionExtractor();
  List<Expression> sourceMethodInvocations=extractor.getMethodInvocations(sourceMethod.getBody());
  List<Expression> newMethodInvocations=extractor.getMethodInvocations(newMethodDeclaration.getBody());
  int i=0;
  for (  Expression invocation : newMethodInvocations) {
    if (invocation instanceof MethodInvocation) {
      MethodInvocation methodInvocation=(MethodInvocation)invocation;
      List<Expression> arguments=methodInvocation.arguments();
      for (      Expression argument : arguments) {
        if (argument instanceof SimpleName) {
          SimpleName simpleNameArgument=(SimpleName)argument;
          if (simpleNameArgument.getIdentifier().equals(targetClassVariableName)) {
            ListRewrite argumentRewrite=targetRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            MethodInvocation sourceMethodInvocation=(MethodInvocation)sourceMethodInvocations.get(i);
            AST ast=newMethodDeclaration.getAST();
            if (!sourceMethod.resolveBinding().isEqualTo(sourceMethodInvocation.resolveMethodBinding())) {
              argumentRewrite.replace(argument,ast.newThisExpression(),null);
            }
          }
        }
 else         if (argument instanceof FieldAccess) {
          FieldAccess fieldAccess=(FieldAccess)argument;
          SimpleName simpleNameArgument=fieldAccess.getName();
          if (simpleNameArgument.getIdentifier().equals(targetClassVariableName)) {
            ListRewrite argumentRewrite=targetRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
            MethodInvocation sourceMethodInvocation=(MethodInvocation)sourceMethodInvocations.get(i);
            AST ast=newMethodDeclaration.getAST();
            if (!sourceMethod.resolveBinding().isEqualTo(sourceMethodInvocation.resolveMethodBinding())) {
              argumentRewrite.replace(argument,ast.newThisExpression(),null);
            }
          }
        }
      }
    }
    i++;
  }
}