IDEA-127533 int field is displayed as char - show only reasonable ascii as chars

This commit is contained in:
Egor.Ushakov
2017-05-04 12:52:28 +03:00
parent 1c0cad79c6
commit 844177d33e
4 changed files with 62 additions and 3 deletions

View File

@@ -133,7 +133,7 @@ public class ConstExprent extends Exprent {
String ret = CHAR_ESCAPES.get(val);
if (ret == null) {
char c = (char)val.intValue();
if (c >= 32 && c < 127 || !ascii && TextUtil.isPrintableUnicode(c)) {
if (isPrintableAscii(c) || !ascii && TextUtil.isPrintableUnicode(c)) {
ret = String.valueOf(c);
}
else {
@@ -278,7 +278,7 @@ public class ConstExprent extends Exprent {
// buffer.append("\\\'");
// break;
default:
if (c >= 32 && c < 127 || !ascii && TextUtil.isPrintableUnicode(c)) {
if (isPrintableAscii(c) || !ascii && TextUtil.isPrintableUnicode(c)) {
buffer.append(c);
}
else {
@@ -371,7 +371,7 @@ 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 (getIntValue() != 0) {
if (isPrintableAscii(getIntValue())) {
setConstType(VarType.VARTYPE_CHAR);
}
}
@@ -382,6 +382,11 @@ public class ConstExprent extends Exprent {
}
}
private static boolean isPrintableAscii(int c) {
return c >= 32 && c < 127;
}
public Object getValue() {
return value;
}