<commit_before>package jp.gr.java_conf.daisy.ajax_mutator.detector.event_detector;

import java.util.List;
import java.util.Set;

import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.FunctionCall;
import org.mozilla.javascript.ast.PropertyGet;

import com.google.common.collect.ImmutableSet;

import jp.gr.java_conf.daisy.ajax_mutator.detector.EventAttacherDetector;
import jp.gr.java_conf.daisy.ajax_mutator.mutatable.EventAttachment;

/**
 * Event detector that detect jQuery like event attachment.
 * e.g., $("#hoge").click('hoge');
 *       $("#hoge").on('click', hoge);
 *
 * @author <NAME>
 */
public class JQueryEventAttachmentDetector extends EventAttacherDetector {
	private final Set<String> jQueryEvents = ImmutableSet.of(
			"blur", "change", "click", "dblclick", "error", "focus", "keydown",
			"keypress", "keyup", "load", "mousedown", "mousemove", "mouseout",
			"mouseover", "mouseup", "resize", "scroll", "select", "submit",
			"unload");
	private final Set<String> jQueryEventAttachers 
		= ImmutableSet.of("bind", "on", "one", "live");
	
	@Override
	public EventAttachment detectFromFunctionCall(
			FunctionCall functionCall, AstNode target, List<AstNode> arguments) {
		if (target instanceof PropertyGet) {
			PropertyGet propertyGet = (PropertyGet) target;
			String methodName = propertyGet.getProperty().getIdentifier();
			if (jQueryEvents.contains(methodName)) {
				return new EventAttachment(functionCall, propertyGet.getTarget(), 
						propertyGet.getProperty(), arguments.get(0));
			} else if (jQueryEventAttachers.contains(methodName)) {
				return new EventAttachment(functionCall, propertyGet.getProperty(),
						arguments.get(0), arguments.get(arguments.size() - 1));
			}
		}
		return null;
	}
}<commit_msg>bugfix: added workarond for event invoking method like click() in jQuery<commit_after>package jp.gr.java_conf.daisy.ajax_mutator.detector.event_detector;

import java.util.List;
import java.util.Set;

import org.mozilla.javascript.ast.AstNode;
import org.mozilla.javascript.ast.FunctionCall;
import org.mozilla.javascript.ast.PropertyGet;

import com.google.common.collect.ImmutableSet;

import jp.gr.java_conf.daisy.ajax_mutator.detector.EventAttacherDetector;
import jp.gr.java_conf.daisy.ajax_mutator.mutatable.EventAttachment;

/**
 * Event detector that detect jQuery like event attachment.
 * e.g., $("#hoge").click('hoge');
 *       $("#hoge").on('click', hoge);
 *
 * @author <NAME>
 */
public class JQueryEventAttachmentDetector extends EventAttacherDetector {
	private final Set<String> jQueryEvents = ImmutableSet.of(
			"blur", "change", "click", "dblclick", "error", "focus", "keydown",
			"keypress", "keyup", "load", "mousedown", "mousemove", "mouseout",
			"mouseover", "mouseup", "resize", "scroll", "select", "submit",
			"unload");
	private final Set<String> jQueryEventAttachers 
		= ImmutableSet.of("bind", "on", "one", "live");
	
	@Override
	public EventAttachment detectFromFunctionCall(
			FunctionCall functionCall, AstNode target, List<AstNode> arguments) {
		if (target instanceof PropertyGet) {
			PropertyGet propertyGet = (PropertyGet) target;
			String methodName = propertyGet.getProperty().getIdentifier();
			if (jQueryEvents.contains(methodName) && arguments.size() > 0) {
				return new EventAttachment(functionCall, propertyGet.getTarget(), 
						propertyGet.getProperty(), arguments.get(0));
			} else if (jQueryEventAttachers.contains(methodName)) {
				return new EventAttachment(functionCall, propertyGet.getProperty(),
						arguments.get(0), arguments.get(arguments.size() - 1));
			}
		}
		return null;
	}
}
{'fraction_non_alphanumeric': 0.14167357083678542, 'fraction_numerical': 0.0019331676332504833, 'mean_word_length': 5.3992932862190814, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4745494', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1118, 'n_words': 234}