<commit_before>package jadx.core.dex.visitors;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jetbrains.annotations.Nullable;

import jadx.api.JadxArgs;
import jadx.core.Consts;
import jadx.core.deobf.Deobfuscator;
import jadx.core.deobf.NameMapper;
import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.attributes.nodes.RenameReasonAttr;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.info.ClassInfo;
import jadx.core.dex.info.FieldInfo;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.DexNode;
import jadx.core.dex.nodes.FieldNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.nodes.RootNode;
import jadx.core.utils.files.InputFile;

public class RenameVisitor extends AbstractVisitor {

	@Override
	public void init(RootNode root) {
		List<DexNode> dexNodes = root.getDexNodes();
		if (dexNodes.isEmpty()) {
			return;
		}
		InputFile firstInputFile = dexNodes.get(0).getDexFile().getInputFile();
		Path inputFilePath = firstInputFile.getFile().toPath();

		String inputName = inputFilePath.getFileName().toString();
		String baseName = inputName.substring(0, inputName.lastIndexOf('.'));
		Path deobfMapPath = inputFilePath.getParent().resolve(baseName + ".jobf");

		JadxArgs args = root.getArgs();
		Deobfuscator deobfuscator = new Deobfuscator(args, dexNodes, deobfMapPath);
		if (args.isDeobfuscationOn()) {
			deobfuscator.execute();
		}

		checkClasses(deobfuscator, root, args);

		if (args.isDeobfuscationOn()) {
			deobfuscator.savePresets();
			deobfuscator.clear();
		}
	}
<commit_msg>fix: NPE if loading local file from CLI (`jadx sample.apk`)<commit_after>package jadx.core.dex.visitors;

import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jetbrains.annotations.Nullable;

import jadx.api.JadxArgs;
import jadx.core.Consts;
import jadx.core.deobf.Deobfuscator;
import jadx.core.deobf.NameMapper;
import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.attributes.nodes.RenameReasonAttr;
import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.info.ClassInfo;
import jadx.core.dex.info.FieldInfo;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.DexNode;
import jadx.core.dex.nodes.FieldNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.nodes.RootNode;
import jadx.core.utils.files.InputFile;

public class RenameVisitor extends AbstractVisitor {

	@Override
	public void init(RootNode root) {
		List<DexNode> dexNodes = root.getDexNodes();
		if (dexNodes.isEmpty()) {
			return;
		}
		InputFile firstInputFile = dexNodes.get(0).getDexFile().getInputFile();
		Path inputFilePath = firstInputFile.getFile().getAbsoluteFile().toPath();

		String inputName = inputFilePath.getFileName().toString();
		String baseName = inputName.substring(0, inputName.lastIndexOf('.'));
		Path deobfMapPath = inputFilePath.getParent().resolve(baseName + ".jobf");

		JadxArgs args = root.getArgs();
		Deobfuscator deobfuscator = new Deobfuscator(args, dexNodes, deobfMapPath);
		if (args.isDeobfuscationOn()) {
			deobfuscator.execute();
		}

		checkClasses(deobfuscator, root, args);

		if (args.isDeobfuscationOn()) {
			deobfuscator.savePresets();
			deobfuscator.clear();
		}
	}

{'fraction_non_alphanumeric': 0.12910085054678008, 'fraction_numerical': 0.001215066828675577, 'mean_word_length': 5.260456273764259, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6960712', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1197, 'n_words': 197}