From fc34f18e9265ba03c67ce69b32163b8cc745ee38 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 26 Dec 2019 19:01:22 +0000 Subject: [PATCH] Convert ValueOfTransformer to Kotlin --- .../ast/transform/ValueOfTransformer.java | 21 ------------------- .../deob/ast/transform/ValueOfTransformer.kt | 18 ++++++++++++++++ 2 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.java create mode 100644 deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.java b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.java deleted file mode 100644 index bed617f515..0000000000 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.java +++ /dev/null @@ -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())); - }); - } -} diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt new file mode 100644 index 0000000000..618324e8c9 --- /dev/null +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt @@ -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)) + } + } + } +}