From 48f8c68500fa4a78accaaf82d30b88bcbd6f98a3 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 2 Aug 2019 08:04:36 +0100 Subject: [PATCH] Format code --- .../java/dev/openrs2/asm/InsnNodeUtils.java | 16 ++++++-- .../main/java/dev/openrs2/asm/Library.java | 16 +++++--- .../decompiler/Slf4jFernflowerLogger.java | 40 +++++++++---------- .../openrs2/deob/classpath/TypedRemapper.java | 34 ++++++++-------- .../deob/transform/CounterTransformer.java | 2 +- 5 files changed, 60 insertions(+), 48 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java index 7c517a4d..a4ec5268 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java +++ b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.java @@ -4,22 +4,30 @@ import org.objectweb.asm.tree.AbstractInsnNode; public final class InsnNodeUtils { public static AbstractInsnNode nextReal(AbstractInsnNode insn) { - while ((insn = insn.getNext()) != null && insn.getOpcode() == -1); + while ((insn = insn.getNext()) != null && insn.getOpcode() == -1) { + /* empty */ + } return insn; } public static AbstractInsnNode previousReal(AbstractInsnNode insn) { - while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1); + while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1) { + /* empty */ + } return insn; } public static AbstractInsnNode nextVirtual(AbstractInsnNode insn) { - while ((insn = insn.getNext()) != null && insn.getOpcode() != -1); + while ((insn = insn.getNext()) != null && insn.getOpcode() != -1) { + /* empty */ + } return insn; } public static AbstractInsnNode previousVirtual(AbstractInsnNode insn) { - while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1); + while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1) { + /* empty */ + } return insn; } diff --git a/asm/src/main/java/dev/openrs2/asm/Library.java b/asm/src/main/java/dev/openrs2/asm/Library.java index 8a670ebb..9477e015 100644 --- a/asm/src/main/java/dev/openrs2/asm/Library.java +++ b/asm/src/main/java/dev/openrs2/asm/Library.java @@ -63,10 +63,12 @@ public final class Library implements Iterable { var temp = Files.createTempFile(TEMP_PREFIX, JAR_SUFFIX); try { - try (var header = new ByteArrayInputStream(GZIP_HEADER); - var data = Files.newInputStream(path); - var in = new GZIPInputStream(new SequenceInputStream(header, data)); - var out = new JarOutputStream(Files.newOutputStream(temp))) { + try ( + var header = new ByteArrayInputStream(GZIP_HEADER); + var data = Files.newInputStream(path); + var in = new GZIPInputStream(new SequenceInputStream(header, data)); + var out = new JarOutputStream(Files.newOutputStream(temp)) + ) { Pack200.newUnpacker().unpack(in, out); return readJar(temp); } @@ -138,8 +140,10 @@ public final class Library implements Iterable { try { writeJar(temp, remapper); - try (var in = new JarInputStream(Files.newInputStream(temp)); - var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2))) { + try ( + var in = new JarInputStream(Files.newInputStream(temp)); + var out = new GZIPOutputStream(new SkipOutputStream(Files.newOutputStream(path), 2)) + ) { Pack200.newPacker().pack(in, out); } } finally { diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java b/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java index f82bb159..aa50cb65 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.java @@ -21,32 +21,32 @@ public final class Slf4jFernflowerLogger extends IFernflowerLogger { @Override public void writeMessage(String message, Severity severity) { switch (severity) { - case TRACE: - logger.trace(message); - case INFO: - logger.info(message); - case WARN: - logger.warn(message); - case ERROR: - logger.error(message); - default: - throw new IllegalArgumentException(); + case TRACE: + logger.trace(message); + case INFO: + logger.info(message); + case WARN: + logger.warn(message); + case ERROR: + logger.error(message); + default: + throw new IllegalArgumentException(); } } @Override public void writeMessage(String message, Severity severity, Throwable t) { switch (severity) { - case TRACE: - logger.trace(message, t); - case INFO: - logger.info(message, t); - case WARN: - logger.warn(message, t); - case ERROR: - logger.error(message, t); - default: - throw new IllegalArgumentException(); + case TRACE: + logger.trace(message, t); + case INFO: + logger.info(message, t); + case WARN: + logger.warn(message, t); + case ERROR: + logger.error(message, t); + default: + throw new IllegalArgumentException(); } } } diff --git a/deob/src/main/java/dev/openrs2/deob/classpath/TypedRemapper.java b/deob/src/main/java/dev/openrs2/deob/classpath/TypedRemapper.java index f05579fc..0bcafdd2 100644 --- a/deob/src/main/java/dev/openrs2/deob/classpath/TypedRemapper.java +++ b/deob/src/main/java/dev/openrs2/deob/classpath/TypedRemapper.java @@ -258,23 +258,23 @@ public final class TypedRemapper extends Remapper { } switch (type.getSort()) { - case Type.BOOLEAN: - case Type.BYTE: - case Type.CHAR: - case Type.SHORT: - case Type.INT: - case Type.LONG: - case Type.FLOAT: - case Type.DOUBLE: - prefix = type.getClassName() + prefix; - break; - case Type.OBJECT: - var className = classMapping.getOrDefault(type.getInternalName(), type.getInternalName()); - className = className.substring(className.lastIndexOf('/') + 1); - prefix = className + prefix; - break; - default: - throw new IllegalArgumentException("Unknown field type " + type); + case Type.BOOLEAN: + case Type.BYTE: + case Type.CHAR: + case Type.SHORT: + case Type.INT: + case Type.LONG: + case Type.FLOAT: + case Type.DOUBLE: + prefix = type.getClassName() + prefix; + break; + case Type.OBJECT: + var className = classMapping.getOrDefault(type.getInternalName(), type.getInternalName()); + className = className.substring(className.lastIndexOf('/') + 1); + prefix = className + prefix; + break; + default: + throw new IllegalArgumentException("Unknown field type " + type); } prefix = StringUtils.indefiniteArticle(prefix) + StringUtils.capitalize(prefix); diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java index b018e44f..619bfba0 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.java @@ -105,7 +105,7 @@ public final class CounterTransformer extends Transformer { var putstatic = (FieldInsnNode) match.get(3); if (getstatic.owner.equals(putstatic.owner) && getstatic.name.equals(putstatic.name) && getstatic.desc.equals(putstatic.desc) && - counters.contains(new MemberRef(putstatic.owner, putstatic.name, putstatic.desc))) { + counters.contains(new MemberRef(putstatic.owner, putstatic.name, putstatic.desc))) { match.forEach(method.instructions::remove); } });