// Path: src/ca/uwaterloo/ece/qhanam/jrsrepair/SourceStatement.java
// public class SourceStatement {
// 	public String sourceFile;
// 	public Statement statement;
// 	public boolean inUse;
// 	
// 	public SourceStatement(String sourceFile, Statement statement){
// 		this.sourceFile = sourceFile;
// 		this.statement = statement;
// 		this.inUse = false;
// 	}
// }
// 
// Path: src/ca/uwaterloo/ece/qhanam/jrsrepair/DocumentASTRewrite.java
// public class DocumentASTRewrite {
// 	public File backingFile;
// 	public IDocument document;
// 	public IDocument modifiedDocument;
// 	public ASTRewrite rewriter;
// 	private boolean modified;
// 	private boolean tainted;
// 
// 	public DocumentASTRewrite(IDocument document, File backingFile, ASTRewrite rewriter){
// 		this.backingFile = backingFile;
// 		this.document = document;
// 		this.rewriter = rewriter;
// 		this.tainted = false;
// 		this.modified = false;
// 		
// 		this.resetModifiedDocument();
// 	}
// 	
// 	public void taintDocument(){
// 		this.modified = true;
// 		this.tainted = true;
// 	}
// 	
// 	public void untaintDocument(){
// 		this.tainted = false;
// 	}
// 	
// 	public boolean isDocumentTainted(){
// 		return this.tainted;
// 	}
// 	
// 	public void resetModifiedDocument(){
// 		this.modifiedDocument = new Document(document.get());
// 	}
// 	
// 	public boolean isDocumentModified(){
// 		return this.modified;
// 	}
// }


import ca.uwaterloo.ece.qhanam.jrsrepair.SourceStatement;
import ca.uwaterloo.ece.qhanam.jrsrepair.DocumentASTRewrite;
import java.util.HashMap;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.text.edits.*;
package ca.uwaterloo.ece.qhanam.jrsrepair.mutation;




public class DeletionMutation extends Mutation {
	
	private ASTNode emptyBlock;
	
	public DeletionMutation(HashMap<String, DocumentASTRewrite> sourceFileContents, SourceStatement faulty, SourceStatement seed){
		super(sourceFileContents, faulty, seed);
		this.emptyBlock = null;
	}

	/**
	 * Adds the seed statement to the AST right before the 
	 * faulty statement. 
	 */
	@Override
	public void concreteMutate() throws Exception {
        /* Create a new block to insert in place of the deleted statement. */
        this.emptyBlock = (Block) this.rewrite.getAST().createInstance(Block.class);

        /* Replace the faulty statement with the empty Block. */
        rewrite.replace(faulty.statement, this.emptyBlock, null);
        
        /* Modify the source code file. */
        this.docrwt.resetModifiedDocument(); // Start with the original document to avoid the AST-doesn't-match-doc error.
        TextEdit edits = rewrite.rewriteAST(this.docrwt.modifiedDocument, null);
        edits.apply(this.docrwt.modifiedDocument, TextEdit.NONE);
	}
	
	/**
	 * Removes the statement added in mutate().
	 */
// Path: src/ca/uwaterloo/ece/qhanam/jrsrepair/SourceStatement.java
// public class SourceStatement {
// 	public String sourceFile;
// 	public Statement statement;
// 	public boolean inUse;
// 	
// 	public SourceStatement(String sourceFile, Statement statement){
// 		this.sourceFile = sourceFile;
// 		this.statement = statement;
// 		this.inUse = false;
// 	}
// }
// 
// Path: src/ca/uwaterloo/ece/qhanam/jrsrepair/DocumentASTRewrite.java
// public class DocumentASTRewrite {
// 	public File backingFile;
// 	public IDocument document;
// 	public IDocument modifiedDocument;
// 	public ASTRewrite rewriter;
// 	private boolean modified;
// 	private boolean tainted;
// 
// 	public DocumentASTRewrite(IDocument document, File backingFile, ASTRewrite rewriter){
// 		this.backingFile = backingFile;
// 		this.document = document;
// 		this.rewriter = rewriter;
// 		this.tainted = false;
// 		this.modified = false;
// 		
// 		this.resetModifiedDocument();
// 	}
// 	
// 	public void taintDocument(){
// 		this.modified = true;
// 		this.tainted = true;
// 	}
// 	
// 	public void untaintDocument(){
// 		this.tainted = false;
// 	}
// 	
// 	public boolean isDocumentTainted(){
// 		return this.tainted;
// 	}
// 	
// 	public void resetModifiedDocument(){
// 		this.modifiedDocument = new Document(document.get());
// 	}
// 	
// 	public boolean isDocumentModified(){
// 		return this.modified;
// 	}
// }


// Path: src/ca/uwaterloo/ece/qhanam/jrsrepair/mutation/DeletionMutation.java
import ca.uwaterloo.ece.qhanam.jrsrepair.SourceStatement;
import ca.uwaterloo.ece.qhanam.jrsrepair.DocumentASTRewrite;
import java.util.HashMap;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.text.edits.*;

package ca.uwaterloo.ece.qhanam.jrsrepair.mutation;




public class DeletionMutation extends Mutation {
	
	private ASTNode emptyBlock;
	
	public DeletionMutation(HashMap<String, DocumentASTRewrite> sourceFileContents, SourceStatement faulty, SourceStatement seed){
		super(sourceFileContents, faulty, seed);
		this.emptyBlock = null;
	}

	/**
	 * Adds the seed statement to the AST right before the 
	 * faulty statement. 
	 */
	@Override
	public void concreteMutate() throws Exception {
        /* Create a new block to insert in place of the deleted statement. */
        this.emptyBlock = (Block) this.rewrite.getAST().createInstance(Block.class);

        /* Replace the faulty statement with the empty Block. */
        rewrite.replace(faulty.statement, this.emptyBlock, null);
        
        /* Modify the source code file. */
        this.docrwt.resetModifiedDocument(); // Start with the original document to avoid the AST-doesn't-match-doc error.
        TextEdit edits = rewrite.rewriteAST(this.docrwt.modifiedDocument, null);
        edits.apply(this.docrwt.modifiedDocument, TextEdit.NONE);
	}
	
	/**
	 * Removes the statement added in mutate().
	 */
	@Override