mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-dfa] IDEA-326613 Support constant evaluation of Integer.parseInt and friends
GitOrigin-RevId: 178e0b4309a84b07a1f01c5fc782a49f03feeb79
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dbf25ab12b
commit
7a7e094d2d
@@ -53,6 +53,12 @@ public final class CustomMethodHandlers {
|
||||
staticCall(JAVA_LANG_BYTE, "toString").parameterTypes("byte"),
|
||||
staticCall(JAVA_LANG_SHORT, "toString").parameterTypes("short"),
|
||||
staticCall(JAVA_LANG_BOOLEAN, "parseBoolean").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_INTEGER, "parseInt").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_LONG, "parseLong").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_DOUBLE, "parseDouble").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_FLOAT, "parseFloat").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_BYTE, "parseByte").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_SHORT, "parseShort").parameterTypes("java.lang.String"),
|
||||
staticCall(JAVA_LANG_INTEGER, "compare", "compareUnsigned").parameterTypes("int", "int"),
|
||||
staticCall(JAVA_LANG_LONG, "compare", "compareUnsigned").parameterTypes("long", "long"),
|
||||
staticCall(JAVA_LANG_DOUBLE, "compare").parameterTypes("double", "double"),
|
||||
|
||||
@@ -399,4 +399,10 @@ public class LongRangeKnownMethods {
|
||||
if (<warning descr="Condition 'val >= 20' is always 'false'">val >= 20</warning>) {}
|
||||
if (val >= 19) {}
|
||||
}
|
||||
|
||||
void testParse(String s) {
|
||||
if (!s.equals("1234")) return;
|
||||
int val = Integer.parseInt(s);
|
||||
if (<warning descr="Condition 'val != 1234' is always 'false'">val != 1234</warning>) return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
<item name='java.lang.Boolean java.lang.Boolean valueOf(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.lang.Byte byte parseByte(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Byte int intValue()'>
|
||||
<annotation name='org.jetbrains.annotations.Range'>
|
||||
<val name="from" val="java.lang.Byte.MIN_VALUE"/>
|
||||
@@ -465,6 +470,11 @@
|
||||
<item name="java.lang.Comparable int compareTo(T) 0">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='java.lang.Double double parseDouble(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Enum T valueOf(java.lang.Class<T>, java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
@@ -486,6 +496,11 @@
|
||||
<item name='java.lang.Enum java.lang.String name()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.lang.Float float parseFloat(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Integer int bitCount(int)'>
|
||||
<annotation name='org.jetbrains.annotations.Range'>
|
||||
<val name="from" val="0"/>
|
||||
@@ -504,7 +519,12 @@
|
||||
<val name="to" val="32"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Integer java.lang.Integer decode(java.lang.String)'>
|
||||
<item name='java.lang.Integer int parseInt(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Integer java.lang.Integer decode(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
@@ -597,6 +617,11 @@
|
||||
<item name='java.lang.Long java.lang.Long valueOf(long)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.lang.Long long parseLong(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Math double IEEEremainder(double, double)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
@@ -869,6 +894,11 @@
|
||||
<val name="to" val="0xFFFF"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.Short short parseShort(java.lang.String)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="pure" val="true"/>
|
||||
</annotation>
|
||||
</item>
|
||||
<item name='java.lang.StackTraceElement java.lang.String getClassName()'>
|
||||
<annotation name='org.jetbrains.annotations.NonNls'/>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
|
||||
Reference in New Issue
Block a user