Convert ValueOfTransformer to Kotlin

master
Graham 5 years ago
parent afb52c2e93
commit fc34f18e92
  1. 21
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.java
  2. 18
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt

@ -1,21 +0,0 @@
package dev.openrs2.deob.ast.transform;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.expr.MethodCallExpr;
import com.github.javaparser.ast.expr.ObjectCreationExpr;
import com.github.javaparser.ast.expr.TypeExpr;
import dev.openrs2.deob.ast.util.NodeUtils;
public final class ValueOfTransformer extends Transformer {
@Override
public void transform(CompilationUnit unit) {
NodeUtils.walk(unit, Node.TreeTraversal.POSTORDER, ObjectCreationExpr.class, expr -> {
if (!expr.getType().isBoxedType()) {
return;
}
expr.replace(new MethodCallExpr(new TypeExpr(expr.getType()), "valueOf", expr.getArguments()));
});
}
}

@ -0,0 +1,18 @@
package dev.openrs2.deob.ast.transform
import com.github.javaparser.ast.CompilationUnit
import com.github.javaparser.ast.Node
import com.github.javaparser.ast.expr.MethodCallExpr
import com.github.javaparser.ast.expr.ObjectCreationExpr
import com.github.javaparser.ast.expr.TypeExpr
import dev.openrs2.deob.ast.util.NodeUtils
class ValueOfTransformer : Transformer() {
override fun transform(unit: CompilationUnit) {
NodeUtils.walk(unit, Node.TreeTraversal.POSTORDER, ObjectCreationExpr::class.java) { expr ->
if (expr.type.isBoxedType) {
expr.replace(MethodCallExpr(TypeExpr(expr.type), "valueOf", expr.arguments))
}
}
}
}
Loading…
Cancel
Save