Skip to content

Commit

Permalink
ignore autoboxing and simple get
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jan 14, 2024
1 parent 25e69c2 commit a37a170
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,6 +36,8 @@

public class FluentGetterSuggester implements LvtSuggester {

private static final Set<String> 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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a37a170

Please sign in to comment.