Program: 12258
Project: 12258
Buggy source:
private void modifyClient(){
  AST clientAST=sourceTypeDeclaration.getAST();
  MethodDeclaration typeCheckMethod=typeCheckElimination.getTypeCheckMethod();
  Block typeCheckCodeFragmentParentBlock=(Block)typeCheckElimination.getTypeCheckCodeFragment().getParent();
  ListRewrite typeCheckCodeFragmentParentBlockStatementsRewrite=sourceRewriter.getListRewrite(typeCheckCodeFragmentParentBlock,Block.STATEMENTS_PROPERTY);
  Type typeCheckMethodReturnType=typeCheckMethod.getReturnType2();
  if (typeCheckMethodReturnType.isPrimitiveType() && ((PrimitiveType)typeCheckMethodReturnType).getPrimitiveTypeCode().equals(PrimitiveType.VOID)) {
    MethodInvocation abstractMethodInvocation=clientAST.newMethodInvocation();
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckMethod.getName(),null);
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,typeCheckElimination.getTypeMethodInvocation().getExpression(),null);
    for (    SingleVariableDeclaration abstractMethodParameter : typeCheckElimination.getAccessedParameters()) {
      ListRewrite methodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(abstractMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
      methodInvocationArgumentsRewrite.insertLast(abstractMethodParameter.getName(),null);
    }
    ExpressionStatement expressionStatement=clientAST.newExpressionStatement(abstractMethodInvocation);
    typeCheckCodeFragmentParentBlockStatementsRewrite.replace(typeCheckElimination.getTypeCheckCodeFragment(),expressionStatement,null);
  }
 else {
    Assignment assignment=clientAST.newAssignment();
    MethodInvocation abstractMethodInvocation=clientAST.newMethodInvocation();
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckMethod.getName(),null);
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,typeCheckElimination.getTypeMethodInvocation().getExpression(),null);
    for (    SingleVariableDeclaration abstractMethodParameter : typeCheckElimination.getAccessedParameters()) {
      ListRewrite methodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(abstractMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
      methodInvocationArgumentsRewrite.insertLast(abstractMethodParameter.getName(),null);
    }
    VariableDeclarationFragment returnedVariable=typeCheckElimination.getTypeCheckMethodReturnedVariable();
    sourceRewriter.set(assignment,Assignment.OPERATOR_PROPERTY,Assignment.Operator.ASSIGN,null);
    sourceRewriter.set(assignment,Assignment.LEFT_HAND_SIDE_PROPERTY,returnedVariable.getName(),null);
    sourceRewriter.set(assignment,Assignment.RIGHT_HAND_SIDE_PROPERTY,abstractMethodInvocation,null);
    ExpressionStatement expressionStatement=clientAST.newExpressionStatement(assignment);
    typeCheckCodeFragmentParentBlockStatementsRewrite.replace(typeCheckElimination.getTypeCheckCodeFragment(),expressionStatement,null);
  }
  ITextFileBufferManager bufferManager=FileBuffers.getTextFileBufferManager();
  ITextFileBuffer sourceTextFileBuffer=bufferManager.getTextFileBuffer(sourceFile.getFullPath(),LocationKind.IFILE);
  IDocument sourceDocument=sourceTextFileBuffer.getDocument();
  TextEdit sourceEdit=sourceRewriter.rewriteAST(sourceDocument,null);
  try {
    UndoEdit sourceUndoEdit=sourceEdit.apply(sourceDocument,UndoEdit.CREATE_UNDO);
    undoRefactoring.put(sourceFile,sourceDocument,sourceUndoEdit);
  }
 catch (  MalformedTreeException e) {
    e.printStackTrace();
  }
catch (  BadLocationException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void modifyClient(){
  AST clientAST=sourceTypeDeclaration.getAST();
  MethodDeclaration typeCheckMethod=typeCheckElimination.getTypeCheckMethod();
  Block typeCheckCodeFragmentParentBlock=(Block)typeCheckElimination.getTypeCheckCodeFragment().getParent();
  ListRewrite typeCheckCodeFragmentParentBlockStatementsRewrite=sourceRewriter.getListRewrite(typeCheckCodeFragmentParentBlock,Block.STATEMENTS_PROPERTY);
  Type typeCheckMethodReturnType=typeCheckMethod.getReturnType2();
  if (typeCheckMethodReturnType.isPrimitiveType() && ((PrimitiveType)typeCheckMethodReturnType).getPrimitiveTypeCode().equals(PrimitiveType.VOID)) {
    MethodInvocation abstractMethodInvocation=clientAST.newMethodInvocation();
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckMethod.getName(),null);
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,typeCheckElimination.getTypeMethodInvocation().getExpression(),null);
    for (    SingleVariableDeclaration abstractMethodParameter : typeCheckElimination.getAccessedParameters()) {
      ListRewrite methodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(abstractMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
      methodInvocationArgumentsRewrite.insertLast(abstractMethodParameter.getName(),null);
    }
    ExpressionStatement expressionStatement=clientAST.newExpressionStatement(abstractMethodInvocation);
    typeCheckCodeFragmentParentBlockStatementsRewrite.replace(typeCheckElimination.getTypeCheckCodeFragment(),expressionStatement,null);
  }
 else {
    MethodInvocation abstractMethodInvocation=clientAST.newMethodInvocation();
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.NAME_PROPERTY,typeCheckMethod.getName(),null);
    sourceRewriter.set(abstractMethodInvocation,MethodInvocation.EXPRESSION_PROPERTY,typeCheckElimination.getTypeMethodInvocation().getExpression(),null);
    for (    SingleVariableDeclaration abstractMethodParameter : typeCheckElimination.getAccessedParameters()) {
      ListRewrite methodInvocationArgumentsRewrite=sourceRewriter.getListRewrite(abstractMethodInvocation,MethodInvocation.ARGUMENTS_PROPERTY);
      methodInvocationArgumentsRewrite.insertLast(abstractMethodParameter.getName(),null);
    }
    VariableDeclarationFragment returnedVariable=typeCheckElimination.getTypeCheckMethodReturnedVariable();
    if (returnedVariable != null) {
      Assignment assignment=clientAST.newAssignment();
      sourceRewriter.set(assignment,Assignment.OPERATOR_PROPERTY,Assignment.Operator.ASSIGN,null);
      sourceRewriter.set(assignment,Assignment.LEFT_HAND_SIDE_PROPERTY,returnedVariable.getName(),null);
      sourceRewriter.set(assignment,Assignment.RIGHT_HAND_SIDE_PROPERTY,abstractMethodInvocation,null);
      ExpressionStatement expressionStatement=clientAST.newExpressionStatement(assignment);
      typeCheckCodeFragmentParentBlockStatementsRewrite.replace(typeCheckElimination.getTypeCheckCodeFragment(),expressionStatement,null);
    }
 else {
      ReturnStatement returnStatement=clientAST.newReturnStatement();
      sourceRewriter.set(returnStatement,ReturnStatement.EXPRESSION_PROPERTY,abstractMethodInvocation,null);
      typeCheckCodeFragmentParentBlockStatementsRewrite.replace(typeCheckElimination.getTypeCheckCodeFragment(),returnStatement,null);
    }
  }
  ITextFileBufferManager bufferManager=FileBuffers.getTextFileBufferManager();
  ITextFileBuffer sourceTextFileBuffer=bufferManager.getTextFileBuffer(sourceFile.getFullPath(),LocationKind.IFILE);
  IDocument sourceDocument=sourceTextFileBuffer.getDocument();
  TextEdit sourceEdit=sourceRewriter.rewriteAST(sourceDocument,null);
  try {
    UndoEdit sourceUndoEdit=sourceEdit.apply(sourceDocument,UndoEdit.CREATE_UNDO);
    undoRefactoring.put(sourceFile,sourceDocument,sourceUndoEdit);
  }
 catch (  MalformedTreeException e) {
    e.printStackTrace();
  }
catch (  BadLocationException e) {
    e.printStackTrace();
  }
}