Convert TypeUtils to Kotlin

master
Graham 5 years ago
parent e3baede541
commit fc00d69539
  1. 4
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt
  2. 4
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt
  3. 13
      deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.java
  4. 7
      deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.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
}

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

@ -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 */
}
}

@ -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"
}
Loading…
Cancel
Save