added spaces after if and inside the ternary operator

master
Egor.Ushakov 8 years ago
parent e09e303e71
commit d706718b1b
  1. 16
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java
  2. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/IfExprent.java
  3. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java
  4. 2
      testData/bulk/pkg/res/Loader.java
  5. 2
      testData/results/TestAnonymousClass.dec
  6. 2
      testData/results/TestClassCast.dec
  7. 12
      testData/results/TestClassLoop.dec
  8. 2
      testData/results/TestClassSimpleBytecodeMapping.dec
  9. 8
      testData/results/TestClassTypes.dec
  10. 4
      testData/results/TestClassVar.dec
  11. 22
      testData/results/TestIffSimplification.dec
  12. 2
      testData/results/TestKotlinConstructorKt.dec
  13. 2
      testData/results/TestLocalsNames.dec
  14. 2
      testData/results/TestThrowException.dec
  15. 4
      testData/results/TestTryCatchFinally.dec

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -485,9 +485,9 @@ public class FunctionExprent extends Exprent {
return res.append(".length");
case FUNCTION_IIF:
return wrapOperandString(lstOperands.get(0), true, indent, tracer)
.append("?")
.append(" ? ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(":")
.append(" : ")
.append(wrapOperandString(lstOperands.get(2), true, indent, tracer));
case FUNCTION_IPP:
return wrapOperandString(lstOperands.get(0), true, indent, tracer).append("++");
@ -501,27 +501,27 @@ public class FunctionExprent extends Exprent {
return wrapOperandString(lstOperands.get(0), true, indent, tracer).append(" instanceof ").append(wrapOperandString(lstOperands.get(1), true, indent, tracer));
case FUNCTION_LCMP: // shouldn't appear in the final code
return wrapOperandString(lstOperands.get(0), true, indent, tracer).prepend("__lcmp__(")
.append(",")
.append(", ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(")");
case FUNCTION_FCMPL: // shouldn't appear in the final code
return wrapOperandString(lstOperands.get(0), true, indent, tracer).prepend("__fcmpl__(")
.append(",")
.append(", ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(")");
case FUNCTION_FCMPG: // shouldn't appear in the final code
return wrapOperandString(lstOperands.get(0), true, indent, tracer).prepend("__fcmpg__(")
.append(",")
.append(", ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(")");
case FUNCTION_DCMPL: // shouldn't appear in the final code
return wrapOperandString(lstOperands.get(0), true, indent, tracer).prepend("__dcmpl__(")
.append(",")
.append(", ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(")");
case FUNCTION_DCMPG: // shouldn't appear in the final code
return wrapOperandString(lstOperands.get(0), true, indent, tracer).prepend("__dcmpg__(")
.append(",")
.append(", ")
.append(wrapOperandString(lstOperands.get(1), true, indent, tracer))
.append(")");
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -115,7 +115,7 @@ public class IfExprent extends Exprent {
@Override
public TextBuffer toJava(int indent, BytecodeMappingTracer tracer) {
tracer.addMapping(bytecode);
return condition.toJava(indent, tracer).enclose("if(", ")");
return condition.toJava(indent, tracer).enclose("if (", ")");
}
@Override

@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -144,7 +144,7 @@ public class CatchAllStatement extends Statement {
tracer.incrementCurrentSourceLine();
if (monitor != null) {
buf.appendIndent(indent+1).append("if(").append(monitor.toJava(indent, tracer)).append(") {").appendLineSeparator();
buf.appendIndent(indent+1).append("if (").append(monitor.toJava(indent, tracer)).append(") {").appendLineSeparator();
tracer.incrementCurrentSourceLine();
}

@ -7,7 +7,7 @@ import java.net.URL;
public class Loader {
public String getResource() {
URL resource = this.getClass().getClassLoader().getResource("pkg/res/resource.txt");
if(resource == null) {
if (resource == null) {
throw new RuntimeException("Resource missing");
} else {
try {

@ -45,7 +45,7 @@ public abstract class TestAnonymousClass {
};
void foo(int var1) throws Exception {
if(var1 > 0) {// 10
if (var1 > 0) {// 10
TestAnonymousClass.I var2 = new TestAnonymousClass.I() {
public void foo() throws Exception {
boolean var1 = true;// 13

@ -6,7 +6,7 @@ import java.util.List;
public class TestClassCast {
public void test(List var1) {
Object var2 = var1;// 22
if(var1 != null) {// 23
if (var1 != null) {// 23
((List)(var2 = new ArrayList(var1))).add("23");// 24
}

@ -12,7 +12,7 @@ public class TestClassLoop {
while(true) {
try {
if(!var0) {// 33
if (!var0) {// 33
return;// 34
}
} finally {
@ -30,7 +30,7 @@ public class TestClassLoop {
System.out.println("1");// 49
break;
} finally {
if(var0) {// 52
if (var0) {// 52
System.out.println("3");// 53
continue;// 54
}
@ -51,19 +51,19 @@ public class TestClassLoop {
for(boolean var8 = false; var2 < var1; ++var2) {// 70 73 90
char var6 = var0.charAt(var2);// 74
if(var6 == 48) {// 75
if (var6 == 48) {// 75
++var7;// 76
} else {
if(var6 != 46) {// 77
if (var6 != 46) {// 77
break;
}
if(var3) {// 78
if (var3) {// 78
throw new NumberFormatException("multiple points");// 80
}
var5 = var2;// 82
if(var4) {// 83
if (var4) {// 83
var5 = var2 - 1;// 84
}

@ -9,7 +9,7 @@ public class TestClassSimpleBytecodeMapping {
}// 18
});
this.test2("1");// 21
if(Math.random() > 0.0D) {// 23
if (Math.random() > 0.0D) {// 23
System.out.println("0");// 24
return 0;// 25
} else {

@ -7,13 +7,13 @@ public class TestClassTypes {
public void testBoolean() {
byte var1 = 0;// 25
long var2 = System.currentTimeMillis();// 26
if(var2 % 2L > 0L) {// 28
if (var2 % 2L > 0L) {// 28
var1 = 1;// 29
} else if(var2 % 3L > 0L) {// 31
} else if (var2 % 3L > 0L) {// 31
var1 = 2;// 32
}
if(var1 == 1) {// 35
if (var1 == 1) {// 35
System.out.println();// 36
}
@ -40,7 +40,7 @@ public class TestClassTypes {
public void testAssignmentType(List var1) {
Object var2 = var1;// 61
if(var1 != null) {// 63
if (var1 != null) {// 63
((List)(var2 = new ArrayList(var1))).add("23");// 64
}

@ -9,7 +9,7 @@ public class TestClassVar {
try {
System.out.println();// 29
} finally {
if(this.field_boolean) {// 32
if (this.field_boolean) {// 32
System.out.println();// 33
}
@ -31,7 +31,7 @@ public class TestClassVar {
;
}
if(var2 != var1) {// 54
if (var2 != var1) {// 54
System.out.println();// 55
}
}

@ -2,30 +2,30 @@ package pkg;
public class TestIffSimplification {
public int simpleIff(boolean status, int[] values) {
return status?values[0]:values[1];// 7
return status ? values[0] : values[1];// 7
}
public int simpleIf(boolean status, int[] values) {
return status?values[0]:values[1];// 11 12 15
return status ? values[0] : values[1];// 11 12 15
}
public int nestedIf(boolean status, boolean condition, int[] values) {
if(status) {// 20
return condition?values[2]:values[0];// 21 22 25
if (status) {// 20
return condition ? values[2] : values[0];// 21 22 25
} else {
return values[1];// 29
}
}
public int compareTo(int mc1, int mc2, byte csg1, byte csg2, double score1, double score2, int doc1, int doc2) {
if(mc1 != mc2) {// 34
return mc1 < mc2?1:-1;// 35
} else if(csg1 != csg2) {// 38
return csg1 < csg2?1:-1;// 39
} else if(Math.abs(score1 - score2) < 1.0E-6D) {// 42
return doc1 < doc2?-1:1;// 43
if (mc1 != mc2) {// 34
return mc1 < mc2 ? 1 : -1;// 35
} else if (csg1 != csg2) {// 38
return csg1 < csg2 ? 1 : -1;// 39
} else if (Math.abs(score1 - score2) < 1.0E-6D) {// 42
return doc1 < doc2 ? -1 : 1;// 43
} else {
return score1 < score2?1:-1;// 46
return score1 < score2 ? 1 : -1;// 46
}
}
}

@ -23,7 +23,7 @@ public final class TestKotlinConstructorKt {
Object item$iv$iv = var4.next();
String it = (String)item$iv$iv;// 12
Mapping var10000 = new Mapping;
if(it == null) {// 3
if (it == null) {// 3
throw new TypeCastException("null cannot be cast to non-null type kotlin.String");
}

@ -4,7 +4,7 @@ import java.io.File;
public class TestLocalsNames {
private static void rename(File file, boolean recursively) {
if(file.isDirectory()) {// 22
if (file.isDirectory()) {// 22
long start = System.currentTimeMillis();// 23
File[] files = file.listFiles();// 25
File[] var5 = files;

@ -4,7 +4,7 @@ public class TestThrowException {
Runnable r;
public TestThrowException(int var1) {
if(var1 > 0) {// 9
if (var1 > 0) {// 9
throw new IllegalArgumentException("xxx");// 10
} else {
this.r = new Runnable() {// 12

@ -17,9 +17,9 @@ public class TestTryCatchFinally {
}// 36
int foo(int var1) throws Exception {
if(var1 < 1) {// 39
if (var1 < 1) {// 39
throw new RuntimeException();// 40
} else if(var1 < 5) {// 41
} else if (var1 < 5) {// 41
return var1;// 42
} else {
throw new Exception();// 45

Loading…
Cancel
Save