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; }