Move this keyword to the right-hand side of comparisons

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 4 years ago
parent 9cd19e3708
commit 1318cce216
  1. 6
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt

@ -2,6 +2,7 @@ package dev.openrs2.deob.ast.transform
import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.CompilationUnit
import com.github.javaparser.ast.expr.BinaryExpr import com.github.javaparser.ast.expr.BinaryExpr
import com.github.javaparser.ast.expr.Expression
import dev.openrs2.deob.ast.Library import dev.openrs2.deob.ast.Library
import dev.openrs2.deob.ast.LibraryGroup import dev.openrs2.deob.ast.LibraryGroup
import dev.openrs2.deob.ast.util.flip import dev.openrs2.deob.ast.util.flip
@ -22,11 +23,14 @@ class BinaryExprOrderTransformer : Transformer() {
val left = expr.left val left = expr.left
val right = expr.right val right = expr.right
if (left.isLiteralExpr && !right.isLiteralExpr) { if (left.isLiteralOrThisExpr && !right.isLiteralOrThisExpr) {
expr.operator = op expr.operator = op
expr.left = right.clone() expr.left = right.clone()
expr.right = left.clone() expr.right = left.clone()
} }
} }
} }
private val Expression.isLiteralOrThisExpr: Boolean
get() = isLiteralExpr || isThisExpr
} }

Loading…
Cancel
Save