Program: 12266
Project: 12266
Buggy source:
private void createMovedMethod(){
  AST ast=targetTypeDeclaration.getAST();
  MethodDeclaration newMethodDeclaration=(MethodDeclaration)ASTNode.copySubtree(ast,sourceMethod);
  ListRewrite modifierRewrite=targetRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
  Modifier publicModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
  boolean modifierFound=false;
  List<Modifier> modifiers=newMethodDeclaration.modifiers();
  for (  Modifier modifier : modifiers) {
    if (modifier.getKeyword().equals(Modifier.ModifierKeyword.PUBLIC_KEYWORD)) {
      modifierFound=true;
    }
 else     if (modifier.getKeyword().equals(Modifier.ModifierKeyword.PRIVATE_KEYWORD) || modifier.getKeyword().equals(Modifier.ModifierKeyword.PROTECTED_KEYWORD)) {
      modifierFound=true;
      modifierRewrite.replace(modifier,publicModifier,null);
    }
  }
  if (!modifierFound) {
    modifierRewrite.insertFirst(publicModifier,null);
  }
  ListRewrite parametersRewrite=targetRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
  List<SingleVariableDeclaration> sourceMethodParameters=sourceMethod.parameters();
  List<SingleVariableDeclaration> newMethodParameters=newMethodDeclaration.parameters();
  int i=0;
  for (  SingleVariableDeclaration parameter : sourceMethodParameters) {
    ITypeBinding parameterTypeBinding=parameter.getType().resolveBinding();
    if (parameterTypeBinding.getQualifiedName().equals(targetTypeDeclaration.resolveBinding().getQualifiedName())) {
      targetClassVariableName=parameter.getName().getIdentifier();
      parametersRewrite.remove(newMethodParameters.get(i),null);
      break;
    }
    i++;
  }
  if (targetClassVariableName == null) {
    FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
    for (    FieldDeclaration fieldDeclaration : fieldDeclarations) {
      List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
      for (      VariableDeclarationFragment fragment : fragments) {
        if (fieldDeclaration.getType().resolveBinding().getQualifiedName().equals(targetTypeDeclaration.resolveBinding().getQualifiedName())) {
          targetClassVariableName=fragment.getName().getIdentifier();
          break;
        }
      }
    }
  }
  modifySourceMemberAccessesInTargetClass(newMethodDeclaration);
  if (targetClassVariableName != null) {
    modifyTargetMethodInvocations(newMethodDeclaration);
    modifyTargetPublicFieldInstructions(newMethodDeclaration);
  }
  modifySourceStaticFieldInstructionsInTargetClass(newMethodDeclaration);
  replaceTargetClassVariableNameWithThisExpressionInMethodInvocationArguments(newMethodDeclaration);
  insertTargetClassVariableNameAsVariableDeclaration(newMethodDeclaration);
  replaceThisExpressionWithSourceClassParameterInMethodInvocationArguments(newMethodDeclaration);
  ListRewrite targetClassBodyRewrite=targetRewriter.getListRewrite(targetTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
  targetClassBodyRewrite.insertLast(newMethodDeclaration,null);
}

Fixed version (ground truth):
private void createMovedMethod(){
  AST ast=targetTypeDeclaration.getAST();
  MethodDeclaration newMethodDeclaration=(MethodDeclaration)ASTNode.copySubtree(ast,sourceMethod);
  ListRewrite modifierRewrite=targetRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
  Modifier publicModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
  boolean modifierFound=false;
  List<Modifier> modifiers=newMethodDeclaration.modifiers();
  for (  Modifier modifier : modifiers) {
    if (modifier.getKeyword().equals(Modifier.ModifierKeyword.PUBLIC_KEYWORD)) {
      modifierFound=true;
    }
 else     if (modifier.getKeyword().equals(Modifier.ModifierKeyword.PRIVATE_KEYWORD) || modifier.getKeyword().equals(Modifier.ModifierKeyword.PROTECTED_KEYWORD)) {
      modifierFound=true;
      modifierRewrite.replace(modifier,publicModifier,null);
    }
  }
  if (!modifierFound) {
    modifierRewrite.insertFirst(publicModifier,null);
  }
  ListRewrite parametersRewrite=targetRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
  List<SingleVariableDeclaration> sourceMethodParameters=sourceMethod.parameters();
  List<SingleVariableDeclaration> newMethodParameters=newMethodDeclaration.parameters();
  int i=0;
  for (  SingleVariableDeclaration parameter : sourceMethodParameters) {
    ITypeBinding parameterTypeBinding=parameter.getType().resolveBinding();
    if (parameterTypeBinding.getQualifiedName().equals(targetTypeDeclaration.resolveBinding().getQualifiedName())) {
      targetClassVariableName=parameter.getName().getIdentifier();
      parametersRewrite.remove(newMethodParameters.get(i),null);
      break;
    }
    i++;
  }
  if (targetClassVariableName == null) {
    FieldDeclaration[] fieldDeclarations=sourceTypeDeclaration.getFields();
    for (    FieldDeclaration fieldDeclaration : fieldDeclarations) {
      List<VariableDeclarationFragment> fragments=fieldDeclaration.fragments();
      for (      VariableDeclarationFragment fragment : fragments) {
        if (fieldDeclaration.getType().resolveBinding().getQualifiedName().equals(targetTypeDeclaration.resolveBinding().getQualifiedName())) {
          targetClassVariableName=fragment.getName().getIdentifier();
          break;
        }
      }
    }
  }
  modifySourceMemberAccessesInTargetClass(newMethodDeclaration);
  if (targetClassVariableName != null) {
    modifyTargetMethodInvocations(newMethodDeclaration);
    modifyTargetPublicFieldInstructions(newMethodDeclaration);
  }
  modifySourceStaticFieldInstructionsInTargetClass(newMethodDeclaration);
  replaceTargetClassVariableNameWithThisExpressionInMethodInvocationArguments(newMethodDeclaration);
  insertTargetClassVariableNameAsVariableDeclaration(newMethodDeclaration);
  replaceThisExpressionWithSourceClassParameterInMethodInvocationArguments(newMethodDeclaration);
  replaceThisExpressionWithSourceClassParameterInVariableDeclarationInitializers(newMethodDeclaration);
  ListRewrite targetClassBodyRewrite=targetRewriter.getListRewrite(targetTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
  targetClassBodyRewrite.insertLast(newMethodDeclaration,null);
}