// Path: src/main/java/jp/gr/java_conf/daisy/ajax_mutator/mutatable/EventAttachment.java
// public class EventAttachment extends Mutatable {
//     private AstNode target;
//     private AstNode event;
//     private AstNode callback;
// 
//     public EventAttachment(AstNode astNode, AstNode target, AstNode event,
//             AstNode callback) {
//         super(astNode);
//         this.target = target;
//         this.event = event;
//         this.callback = callback;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder builder = new StringBuilder();
//         builder.append(super.toString()).append('\n');
//         builder.append("  ").append("Event attachment: ");
//         builder.append("[target: " + target.toSource());
//         builder.append(", event:" + event.toSource());
//         builder.append(", callback: " + Util.oneLineStringOf(callback));
//         builder.append("]");
//         return builder.toString();
//     }
// 
//     public AstNode getTarget() {
//         return target;
//     }
// 
//     public AstNode getEvent() {
//         return event;
//     }
// 
//     public AstNode getCallback() {
//         return callback;
//     }
// }


import java.util.List;
import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.FunctionCall;
import org.mozilla.javascript.ast.PropertyGet;
import jp.gr.java_conf.daisy.ajax_mutator.detector.EventAttacherDetector;
import jp.gr.java_conf.daisy.ajax_mutator.mutatable.EventAttachment;
package jp.gr.java_conf.daisy.ajax_mutator.detector.event_detector;




/**
 * Detect event attachment in form of target.attachEvent('on'+event, callback).
 * IE may use this kind of event attachment.
 * 
 * @author Kazuki Nishiura
 */
public class AttachEventDetector extends EventAttacherDetector {
    static private String targetString = "attachEvent";

    @Override
    public EventAttachment detectFromFunctionCall(FunctionCall functionCall,
            AstNode target, List<AstNode> arguments) {
        if (target instanceof PropertyGet) {
            PropertyGet propertyGet = (PropertyGet) target;
            if (targetString.equals(propertyGet.getProperty().getIdentifier())) {
// Path: src/main/java/jp/gr/java_conf/daisy/ajax_mutator/mutatable/EventAttachment.java
// public class EventAttachment extends Mutatable {
//     private AstNode target;
//     private AstNode event;
//     private AstNode callback;
// 
//     public EventAttachment(AstNode astNode, AstNode target, AstNode event,
//             AstNode callback) {
//         super(astNode);
//         this.target = target;
//         this.event = event;
//         this.callback = callback;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuilder builder = new StringBuilder();
//         builder.append(super.toString()).append('\n');
//         builder.append("  ").append("Event attachment: ");
//         builder.append("[target: " + target.toSource());
//         builder.append(", event:" + event.toSource());
//         builder.append(", callback: " + Util.oneLineStringOf(callback));
//         builder.append("]");
//         return builder.toString();
//     }
// 
//     public AstNode getTarget() {
//         return target;
//     }
// 
//     public AstNode getEvent() {
//         return event;
//     }
// 
//     public AstNode getCallback() {
//         return callback;
//     }
// }


// Path: src/main/java/jp/gr/java_conf/daisy/ajax_mutator/detector/event_detector/AttachEventDetector.java
import java.util.List;
import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.FunctionCall;
import org.mozilla.javascript.ast.PropertyGet;
import jp.gr.java_conf.daisy.ajax_mutator.detector.EventAttacherDetector;
import jp.gr.java_conf.daisy.ajax_mutator.mutatable.EventAttachment;

package jp.gr.java_conf.daisy.ajax_mutator.detector.event_detector;




/**
 * Detect event attachment in form of target.attachEvent('on'+event, callback).
 * IE may use this kind of event attachment.
 * 
 * @author Kazuki Nishiura
 */
public class AttachEventDetector extends EventAttacherDetector {
    static private String targetString = "attachEvent";

    @Override
    public EventAttachment detectFromFunctionCall(FunctionCall functionCall,
            AstNode target, List<AstNode> arguments) {
        if (target instanceof PropertyGet) {
            PropertyGet propertyGet = (PropertyGet) target;
            if (targetString.equals(propertyGet.getProperty().getIdentifier())) {
                return new EventAttachment(functionCall,