From bbc76e7cb4bd119930852f31f8e4b08eb0c2dd7d Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 4 May 2017 14:40:09 +0300 Subject: [PATCH] IDEA-127533 int field is displayed as char - show \n etc as chars --- .../modules/decompiler/exps/ConstExprent.java | 3 +- testData/classes/pkg/TestPrimitives.class | Bin 3083 -> 3197 bytes testData/results/TestPrimitives.dec | 46 +++++++++++++++--- testData/src/pkg/TestPrimitives.java | 6 +++ 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java index 0f0e141..612fd37 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/exps/ConstExprent.java @@ -371,7 +371,8 @@ public class ConstExprent extends Exprent { // BYTECHAR and SHORTCHAR => CHAR in the CHAR context if (expectedType.equals(VarType.VARTYPE_CHAR) && (constType.equals(VarType.VARTYPE_BYTECHAR) || constType.equals(VarType.VARTYPE_SHORTCHAR))) { - if (isPrintableAscii(getIntValue())) { + int intValue = getIntValue(); + if (isPrintableAscii(intValue) || CHAR_ESCAPES.containsKey(intValue)) { setConstType(VarType.VARTYPE_CHAR); } } diff --git a/testData/classes/pkg/TestPrimitives.class b/testData/classes/pkg/TestPrimitives.class index 8ed2ef7df9feb5797be2caf784f8d49e36c09577..be15ee5f11867ff023c89f26814bcbc4985d2194 100644 GIT binary patch delta 222 zcmeB{_$#r&h?|Sio`H#hnSp^}_GBAwC0mXq4D2k+8CaNYr3E;V*jz|#9was|5?f(% zFt;nS6$9Vo+1#?V0SqAwF$|#$84O_zB@E#V4Ga+sJq(cyGZ~^7w1M_1Kx}2uVbBHg zfc7)^F!(YsGH^3Y0IDzox+)qds>2|~>A?7hfrHV35y;@ejkp~cfx2UWdYBku0TiGh Ao&W#< delta 142 zcmew>(JisTh?|SyECUk*GXn!d@MIfqrOC^m77q7Nvi3*-S!VDJIzVg%~*V2ENc0-75Q6qRD&<8)yB!@$Al VzzAe;!4S6tBT#J&Pz4i1ECAu<5w`#U diff --git a/testData/results/TestPrimitives.dec b/testData/results/TestPrimitives.dec index d6fcbc4..eae376a 100644 --- a/testData/results/TestPrimitives.dec +++ b/testData/results/TestPrimitives.dec @@ -74,11 +74,17 @@ public class TestPrimitives { boolean res = c > -1;// 77 res = c > 0;// 78 res = c > 1;// 79 - res = c > 'a';// 80 - res = c > 'Z';// 81 - res = c > 127;// 82 - res = c > 255;// 83 - return res;// 84 + res = c > '\b';// 80 + res = c > '\t';// 81 + res = c > '\n';// 82 + res = c > '\f';// 83 + res = c > '\r';// 84 + res = c > ' ';// 85 + res = c > 'a';// 86 + res = c > 'Z';// 87 + res = c > 127;// 88 + res = c > 255;// 89 + return res;// 90 } } @@ -241,9 +247,27 @@ class 'pkg/TestPrimitives' { 3b 78 43 78 45 79 - 48 79 - 50 79 - 52 80 + 47 79 + 4f 79 + 51 80 + 53 80 + 5b 80 + 5d 81 + 5f 81 + 67 81 + 69 82 + 6b 82 + 73 82 + 75 83 + 77 83 + 7f 83 + 81 84 + 83 84 + 8b 84 + 8d 85 + 90 85 + 98 85 + 9a 86 } } @@ -291,3 +315,9 @@ Lines mapping: 82 <-> 79 83 <-> 80 84 <-> 81 +85 <-> 82 +86 <-> 83 +87 <-> 84 +88 <-> 85 +89 <-> 86 +90 <-> 87 diff --git a/testData/src/pkg/TestPrimitives.java b/testData/src/pkg/TestPrimitives.java index b4aa878..39041ef 100644 --- a/testData/src/pkg/TestPrimitives.java +++ b/testData/src/pkg/TestPrimitives.java @@ -77,6 +77,12 @@ public class TestPrimitives { boolean res = (c > -1); res = (c > 0); res = (c > 1); + res = (c > '\b'); + res = (c > '\t'); + res = (c > '\n'); + res = (c > '\f'); + res = (c > '\r'); + res = (c > ' '); res = (c > 'a'); res = (c > 'Z'); res = (c > 127);