Program: 12206
Project: 12206
Buggy source:
private void modifyMovedMethodInvocationInSourceClass(){
  ExpressionExtractor expressionExtractor=new ExpressionExtractor();
  List<TypeDeclaration> sourceTypeDeclarationList=new ArrayList<TypeDeclaration>();
  sourceTypeDeclarationList.add(sourceTypeDeclaration);
  TypeDeclaration[] types=sourceTypeDeclaration.getTypes();
  for (  TypeDeclaration type : types) {
    sourceTypeDeclarationList.add(type);
  }
  for (  TypeDeclaration typeDeclaration : sourceTypeDeclarationList) {
    MethodDeclaration[] methodDeclarations=typeDeclaration.getMethods();
    for (    MethodDeclaration methodDeclaration : methodDeclarations) {
      Block methodBody=methodDeclaration.getBody();
      if (methodBody != null) {
        List<Statement> statements=methodBody.statements();
        for (        Statement statement : statements) {
          List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
          for (          Expression expression : methodInvocations) {
            if (expression instanceof MethodInvocation) {
              MethodInvocation methodInvocation=(MethodInvocation)expression;
              if (sourceMethod.resolveBinding().isEqualTo(methodInvocation.resolveMethodBinding())) {
                List<Expression> arguments=methodInvocation.arguments();
                boolean foundInArguments=false;
                for (                Expression argument : arguments) {
                  if (argument.resolveTypeBinding().isEqualTo(targetTypeDeclaration.resolveBinding())) {
                    foundInArguments=true;
                    ListRewrite argumentRewrite=sourceRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
                    argumentRewrite.remove(argument,null);
                    sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,argument,null);
                    break;
                  }
                }
                boolean foundInFields=false;
                if (!foundInArguments) {
                  FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
                  for (                  FieldDeclaration fieldDeclaration : fieldDeclarations) {
                    List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
                    for (                    VariableDeclarationFragment fragment : fragments) {
                      if (fieldDeclaration.getType().resolveBinding().isEqualTo(targetTypeDeclaration.resolveBinding())) {
                        foundInFields=true;
                        sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,fragment.getName(),null);
                        break;
                      }
                    }
                  }
                }
                if (!foundInArguments && !foundInFields) {
                  FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
                  for (                  FieldDeclaration fieldDeclaration : fieldDeclarations) {
                    List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
                    for (                    VariableDeclarationFragment fragment : fragments) {
                      if (targetTypeDeclaration.resolveBinding().isEqualTo(fieldDeclaration.getType().resolveBinding().getSuperclass())) {
                        sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,fragment.getName(),null);
                        break;
                      }
                    }
                  }
                }
                ListRewrite argumentRewrite=sourceRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
                AST ast=methodInvocation.getAST();
                for (                String argument : additionalArgumentsAddedToMovedMethod) {
                  if (argument.equals("String_Node_Str"))                   argumentRewrite.insertLast(ast.newThisExpression(),null);
 else                   argumentRewrite.insertLast(ast.newSimpleName(argument),null);
                }
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void modifyMovedMethodInvocationInSourceClass(){
  ExpressionExtractor expressionExtractor=new ExpressionExtractor();
  List<TypeDeclaration> sourceTypeDeclarationList=new ArrayList<TypeDeclaration>();
  sourceTypeDeclarationList.add(sourceTypeDeclaration);
  TypeDeclaration[] types=sourceTypeDeclaration.getTypes();
  for (  TypeDeclaration type : types) {
    sourceTypeDeclarationList.add(type);
  }
  for (  TypeDeclaration typeDeclaration : sourceTypeDeclarationList) {
    MethodDeclaration[] methodDeclarations=typeDeclaration.getMethods();
    for (    MethodDeclaration methodDeclaration : methodDeclarations) {
      Block methodBody=methodDeclaration.getBody();
      if (methodBody != null) {
        List<Statement> statements=methodBody.statements();
        for (        Statement statement : statements) {
          List<Expression> methodInvocations=expressionExtractor.getMethodInvocations(statement);
          for (          Expression expression : methodInvocations) {
            if (expression instanceof MethodInvocation) {
              MethodInvocation methodInvocation=(MethodInvocation)expression;
              if (sourceMethod.resolveBinding().isEqualTo(methodInvocation.resolveMethodBinding())) {
                List<Expression> arguments=methodInvocation.arguments();
                boolean foundInArguments=false;
                for (                Expression argument : arguments) {
                  if (argument.resolveTypeBinding().isEqualTo(targetTypeDeclaration.resolveBinding()) || targetTypeDeclaration.resolveBinding().isEqualTo(argument.resolveTypeBinding().getSuperclass())) {
                    foundInArguments=true;
                    ListRewrite argumentRewrite=sourceRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
                    argumentRewrite.remove(argument,null);
                    sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,argument,null);
                    break;
                  }
                }
                boolean foundInFields=false;
                if (!foundInArguments) {
                  FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
                  for (                  FieldDeclaration fieldDeclaration : fieldDeclarations) {
                    List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
                    for (                    VariableDeclarationFragment fragment : fragments) {
                      if (fieldDeclaration.getType().resolveBinding().isEqualTo(targetTypeDeclaration.resolveBinding())) {
                        foundInFields=true;
                        sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,fragment.getName(),null);
                        break;
                      }
                    }
                  }
                }
                if (!foundInArguments && !foundInFields) {
                  FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
                  for (                  FieldDeclaration fieldDeclaration : fieldDeclarations) {
                    List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
                    for (                    VariableDeclarationFragment fragment : fragments) {
                      if (targetTypeDeclaration.resolveBinding().isEqualTo(fieldDeclaration.getType().resolveBinding().getSuperclass())) {
                        sourceRewriter.set(methodInvocation,MethodInvocation.EXPRESSION_PROPERTY,fragment.getName(),null);
                        break;
                      }
                    }
                  }
                }
                ListRewrite argumentRewrite=sourceRewriter.getListRewrite(methodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
                AST ast=methodInvocation.getAST();
                for (                String argument : additionalArgumentsAddedToMovedMethod) {
                  if (argument.equals("String_Node_Str"))                   argumentRewrite.insertLast(ast.newThisExpression(),null);
 else                   argumentRewrite.insertLast(ast.newSimpleName(argument),null);
                }
              }
            }
          }
        }
      }
    }
  }
}