From fb8772333916c5cd53d37e3f207c3ce5f3988532 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 25 Jul 2023 23:05:57 -0700 Subject: [PATCH] name variables based on distanceToSqr --- .../codebook/lvt/LvtAssignmentSuggester.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/io/papermc/codebook/lvt/LvtAssignmentSuggester.java b/src/main/java/io/papermc/codebook/lvt/LvtAssignmentSuggester.java index f7c979f..c644e8e 100644 --- a/src/main/java/io/papermc/codebook/lvt/LvtAssignmentSuggester.java +++ b/src/main/java/io/papermc/codebook/lvt/LvtAssignmentSuggester.java @@ -61,6 +61,11 @@ private LvtAssignmentSuggester() {} return suggested; } + suggested = suggestNameFromDistanceToSqr(methodName, insn); + if (suggested != null) { + return suggested; + } + suggested = suggestNameFromStrings(methodName, insn); return suggested; } @@ -171,6 +176,14 @@ public static String suggestNameFromRecord(final String methodName) { return null; } + private static @Nullable String suggestNameFromDistanceToSqr(final String methodName, final MethodInsnNode insn) { + if (!"distanceToSqr".equals(methodName) || insn.desc == null || !(insn.desc.endsWith("D") || insn.desc.endsWith("I") || insn.desc.endsWith("F"))) { + return null; + } + + return "distanceSqr"; + } + private static final Type stringType = Type.getType("Ljava/lang/String;"); private static @Nullable String suggestNameFromStrings(final String methodName, final MethodInsnNode insn) {