From b9c707782ccd012495ce88ed29cae28cc0a1a8bb Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 24 Mar 2020 20:09:31 +0000 Subject: [PATCH] Place @Pc annotations on the same line as variable declarations This is much more readable than placing them on a separate line. Signed-off-by: Graham --- .../src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt index a1ac5c29..5d355eb8 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt @@ -79,7 +79,7 @@ class AstDeobfuscator(private val modules: List) { } for (root in roots) { - root.printer = Function(printer::print) + root.printer = Function(printer::print).andThen(::stripNewlineAfterPcAnnotation) root.saveAll() } } @@ -102,5 +102,10 @@ class AstDeobfuscator(private val modules: List) { GlTransformer(), EncloseTransformer() ) + private val PC_ANNOTATION_REGEX = Regex("@Pc\\(([0-9]+)\\)\\s+") + + private fun stripNewlineAfterPcAnnotation(s: String): String { + return s.replace(PC_ANNOTATION_REGEX, "@Pc($1) ") + } } }