From a37a17042196bf1190bac5bc39189cdc18b6fc56 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sun, 14 Jan 2024 20:29:16 +0100 Subject: [PATCH] ignore autoboxing and simple get --- .../codebook/lvt/suggestion/FluentGetterSuggester.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/codebook-lvt/src/main/java/io/papermc/codebook/lvt/suggestion/FluentGetterSuggester.java b/codebook-lvt/src/main/java/io/papermc/codebook/lvt/suggestion/FluentGetterSuggester.java index 502bd03..ab8e746 100644 --- a/codebook-lvt/src/main/java/io/papermc/codebook/lvt/suggestion/FluentGetterSuggester.java +++ b/codebook-lvt/src/main/java/io/papermc/codebook/lvt/suggestion/FluentGetterSuggester.java @@ -27,6 +27,7 @@ import io.papermc.codebook.lvt.suggestion.context.method.MethodCallContext; import io.papermc.codebook.lvt.suggestion.context.method.MethodInsnContext; import java.io.IOException; +import java.util.Set; import java.util.function.IntPredicate; import org.checkerframework.checker.nullness.qual.Nullable; import org.objectweb.asm.Opcodes; @@ -35,6 +36,8 @@ public class FluentGetterSuggester implements LvtSuggester { + private static final Set ignored = Set.of("byteValue", "shortValue", "intValue", "longValue", "floatValue", "doubleValue", "booleanValue", "charValue", "get"); + // 3 instructions, load "this" local var, getfield, return - TODO maybe if there is a CAST, private static final IntPredicate[] OPCODES_IN_ORDER = new IntPredicate[] { i -> i == Opcodes.ALOAD, i -> i == Opcodes.GETFIELD, i -> i >= Opcodes.IRETURN && i <= Opcodes.RETURN @@ -74,7 +77,11 @@ public class FluentGetterSuggester implements LvtSuggester { return "currentTimeMillis"; } } else { - return call.data().name(); + final String name = call.data().name(); + if (ignored.contains(name)) { + return null; + } + return name; } return null; }