aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2021-06-05 10:13:36 +0200
committerJonas Herzig <me@johni0702.de>2021-06-05 10:18:24 +0200
commit744b9288f6aa9cdabe1d3ec8da96f63709cf3f67 (patch)
tree48c95fec9be3d90916e2f12429b23cfd8e9e0247 /src/main
parente7bc0828ad53c283ca9048e5b54146bf4e81e057 (diff)
downloadRemap-744b9288f6aa9cdabe1d3ec8da96f63709cf3f67.tar.gz
Remap-744b9288f6aa9cdabe1d3ec8da96f63709cf3f67.tar.bz2
Remap-744b9288f6aa9cdabe1d3ec8da96f63709cf3f67.zip
Ignore pattern if either method body is empty
So they can be easily (i.e. without requiring a dedicated file) disabled when no longer applicable.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
index 1000666..3c095c4 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiPatterns.kt
@@ -36,10 +36,15 @@ internal class PsiPatterns(private val annotationFQN: String) {
candidates.firstOrNull()
} ?: throw RuntimeException("Failed to find updated method \"${method.name}\" (line ${methodLine + 1})")
}
+ val replacementBody = replacementMethod.body!!
if (method.text == replacementMethod.text) return
- val replacementExpression = when (val statement = replacementMethod.body!!.statements.last()) {
+ // If either body is empty, then consider the pattern to be disabled
+ if (body.statements.isEmpty()) return
+ if (replacementBody.statements.isEmpty()) return
+
+ val replacementExpression = when (val statement = replacementBody.statements.last()) {
is PsiReturnStatement -> statement.returnValue!!
else -> statement
}