<commit_before>package me.coley.recaf.ui.component.editor;

import javafx.scene.control.Tooltip;
import me.coley.recaf.Input;
import me.coley.recaf.config.impl.ConfASM;
import me.coley.recaf.event.ClassReloadEvent;
import me.coley.recaf.util.Lang;
import org.controlsfx.control.PropertySheet.Item;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;

import javafx.scene.Node;
import javafx.scene.control.TextField;
import me.coley.event.Bus;
import me.coley.recaf.event.MethodRenameEvent;
import me.coley.recaf.ui.component.ReflectiveMethodNodeItem;

/**
 * Editor for method names, emits a rename event when the rename is applied.
 * 
 * @author Matt
 */
public class MethodNameEditor extends StagedCustomEditor<String> {
	public MethodNameEditor(Item item) {
		super(item);
	}

	@Override
	public Node getEditor() {
		ReflectiveMethodNodeItem refItem = (ReflectiveMethodNodeItem) item;
		ClassNode cn = refItem.getNode();
		MethodNode mn = (MethodNode) refItem.getOwner();
		TextField txtName = new TextField();
		txtName.setText(mn.name);


		ConfASM conf = ConfASM.instance();
		if (conf.useLinkedMethodRenaming()) {
			if (conf.doLockLibraryMethod() && Input.get().getHierarchy().isLibrary(cn.name, mn.name, mn.desc)) {
				txtName.setDisable(true);
				txtName.setTooltip(new Tooltip(Lang.get("asm.edit.locklibmethods.locked")));
			}
		}

		txtName.setOnAction(e -> rename(cn, mn, txtName));
		return txtName;
	}

	private void rename(ClassNode owner, MethodNode method, TextField txtName) {
		String text = txtName.getText();
		if (!txtName.isDisabled() && !text.equals(method.name)) {
			// use disable property to prevent-double send
			txtName.setDisable(true);
			// send update
			Bus.post(new MethodRenameEvent(owner, method, method.name, text));
			Bus.post(new ClassReloadEvent(owner.name));
		}
	}<commit_msg>Minor cleanup<commit_after>package me.coley.recaf.ui.component.editor;

import javafx.scene.control.Tooltip;
import me.coley.recaf.Input;
import me.coley.recaf.config.impl.ConfASM;
import me.coley.recaf.event.ClassReloadEvent;
import me.coley.recaf.util.Lang;
import org.controlsfx.control.PropertySheet.Item;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;

import javafx.scene.Node;
import javafx.scene.control.TextField;
import me.coley.event.Bus;
import me.coley.recaf.event.MethodRenameEvent;
import me.coley.recaf.ui.component.ReflectiveMethodNodeItem;

/**
 * Editor for method names, emits a rename event when the rename is applied.
 * 
 * @author Matt
 */
public class MethodNameEditor extends StagedCustomEditor<String> {
	public MethodNameEditor(Item item) {
		super(item);
	}

	@Override
	public Node getEditor() {
		ReflectiveMethodNodeItem refItem = (ReflectiveMethodNodeItem) item;
		ClassNode cn = refItem.getNode();
		MethodNode mn = (MethodNode) refItem.getOwner();
		TextField txtName = new TextField();
		txtName.setText(mn.name);
		
		ConfASM conf = ConfASM.instance();
		if (conf.useLinkedMethodRenaming() && conf.doLockLibraryMethod()
				&& Input.get().getHierarchy().isLibrary(cn.name, mn.name, mn.desc)) {
			txtName.setDisable(true);
			txtName.setTooltip(new Tooltip(Lang.get("asm.edit.locklibmethods.locked")));
		}

		txtName.setOnAction(e -> rename(cn, mn, txtName));
		return txtName;
	}

	private void rename(ClassNode owner, MethodNode method, TextField txtName) {
		String text = txtName.getText();
		if (!txtName.isDisabled() && !text.equals(method.name)) {
			// use disable property to prevent-double send
			txtName.setDisable(true);
			// send update
			Bus.post(new MethodRenameEvent(owner, method, method.name, text));
			Bus.post(new ClassReloadEvent(owner.name));
		}
	}
{'fraction_non_alphanumeric': 0.12732667925546265, 'fraction_numerical': 0.0, 'mean_word_length': 4.876386687797147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4825102', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1229, 'n_words': 242}