mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't try to convert hex and octal to float literal (IDEA-186852)
This commit is contained in:
+8
-6
@@ -138,12 +138,14 @@ public class UnnecessaryBoxingInspection extends BaseInspection {
|
||||
if (unboxedType.equals(PsiType.LONG) && expressionType.equals(PsiType.INT)) {
|
||||
return text + 'L';
|
||||
}
|
||||
else if (unboxedType.equals(PsiType.FLOAT) && (expressionType.equals(PsiType.INT) || (expressionType.equals(PsiType.DOUBLE)) &&
|
||||
!StringUtil.endsWithIgnoreCase(text, "d"))) {
|
||||
return text + 'f';
|
||||
}
|
||||
else if (unboxedType.equals(PsiType.DOUBLE) && expressionType.equals(PsiType.INT)) {
|
||||
return text + 'd';
|
||||
else if (!text.startsWith("0")) { // no octal & hex
|
||||
if (unboxedType.equals(PsiType.FLOAT) && (expressionType.equals(PsiType.INT) || (expressionType.equals(PsiType.DOUBLE)) &&
|
||||
!StringUtil.endsWithIgnoreCase(text, "d"))) {
|
||||
return text + 'f';
|
||||
}
|
||||
else if (unboxedType.equals(PsiType.DOUBLE) && expressionType.equals(PsiType.INT)) {
|
||||
return text + 'd';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ParenthesesUtils.getPrecedence(unboxedExpression) > ParenthesesUtils.TYPE_CAST_PRECEDENCE) {
|
||||
|
||||
+12
@@ -74,6 +74,18 @@ public class UnnecessaryBoxingFixTest extends IGQuickFixesTestCase {
|
||||
"\"a\" + (1L - 2L) + \"b\"");
|
||||
}
|
||||
|
||||
public void testHex() {
|
||||
doMemberTest(InspectionGadgetsBundle.message("unnecessary.boxing.remove.quickfix"),
|
||||
"float f = Float./**/valueOf(0x123);",
|
||||
"float f = (float) 0x123;");
|
||||
}
|
||||
|
||||
public void testOctal() {
|
||||
doMemberTest(InspectionGadgetsBundle.message("unnecessary.boxing.remove.quickfix"),
|
||||
"float f = Float.valueOf/**/(0123);",
|
||||
"float f = (float) 0123;");
|
||||
}
|
||||
|
||||
public void testCast() {
|
||||
doFixTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user