diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt index c3ff3193..62a0cb96 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt @@ -6,7 +6,7 @@ import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.Expression import com.github.javaparser.ast.expr.UnaryExpr import dev.openrs2.deob.ast.util.ExprUtils -import dev.openrs2.deob.ast.util.TypeUtils +import dev.openrs2.deob.ast.util.isString import dev.openrs2.deob.ast.util.walk class AddSubTransformer : Transformer() { @@ -17,7 +17,7 @@ class AddSubTransformer : Transformer() { val right = expr.right val type = expr.calculateResolvedType() - if (op == BinaryExpr.Operator.PLUS && TypeUtils.isString(type)) { + if (op == BinaryExpr.Operator.PLUS && type.isString()) { return@walk } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt index 8cfada67..f6ea3b78 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt @@ -3,7 +3,7 @@ package dev.openrs2.deob.ast.transform import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.Node import com.github.javaparser.ast.expr.BinaryExpr -import dev.openrs2.deob.ast.util.TypeUtils +import dev.openrs2.deob.ast.util.isString import dev.openrs2.deob.ast.util.walk class BinaryExprOrderTransformer : Transformer() { @@ -12,7 +12,7 @@ class BinaryExprOrderTransformer : Transformer() { val op = flip(expr.operator) ?: return@walk val type = expr.calculateResolvedType() - if (op == BinaryExpr.Operator.PLUS && TypeUtils.isString(type)) { + if (op == BinaryExpr.Operator.PLUS && type.isString()) { return@walk } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.java b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.java deleted file mode 100644 index 9ecb47e7..00000000 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.openrs2.deob.ast.util; - -import com.github.javaparser.resolution.types.ResolvedType; - -public final class TypeUtils { - public static boolean isString(ResolvedType type) { - return type.isReferenceType() && type.asReferenceType().getQualifiedName().equals("java.lang.String"); - } - - private TypeUtils() { - /* empty */ - } -} diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt new file mode 100644 index 00000000..4e8f8814 --- /dev/null +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt @@ -0,0 +1,7 @@ +package dev.openrs2.deob.ast.util + +import com.github.javaparser.resolution.types.ResolvedType + +fun ResolvedType.isString(): Boolean { + return isReferenceType && asReferenceType().qualifiedName == "java.lang.String" +}