mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-159977 inspector "Constant conditions & exceptions" not support org.springframework.util.Assert
This commit is contained in:
+4
-4
@@ -69,12 +69,12 @@ public class HardcodedContracts {
|
||||
return Collections.singletonList(new MethodContract(constraints, THROW_EXCEPTION));
|
||||
}
|
||||
}
|
||||
else if ("org.apache.commons.lang.Validate".equals(className) ||
|
||||
"org.apache.commons.lang3.Validate".equals(className) ||
|
||||
else if ("org.apache.commons.lang.Validate".equals(className) ||
|
||||
"org.apache.commons.lang3.Validate".equals(className) ||
|
||||
"org.springframework.util.Assert".equals(className)) {
|
||||
if ("notNull".equals(methodName) && paramCount > 0) {
|
||||
if (("isTrue".equals(methodName) || "state".equals(methodName)) && paramCount > 0) {
|
||||
MethodContract.ValueConstraint[] constraints = createConstraintArray(paramCount);
|
||||
constraints[0] = NULL_VALUE;
|
||||
constraints[0] = FALSE_VALUE;
|
||||
return Collections.singletonList(new MethodContract(constraints, THROW_EXCEPTION));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
class Contracts {
|
||||
|
||||
void foo(Object o) {
|
||||
Assert.isTrue(o instanceof String);
|
||||
String s = (String) o;
|
||||
}
|
||||
|
||||
void foo1(Object o) {
|
||||
Assert.state(o instanceof String, "oops");
|
||||
String s = (String) o;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,5 +97,12 @@ public class HardcodedContractsTest extends DataFlowInspectionTestCase {
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
public void testSpringAssert() {
|
||||
myFixture.addClass("package org.springframework.util; public class Assert {\n" +
|
||||
" public static void isTrue(boolean expression) {}\n" +
|
||||
" public static void state(boolean expression, String s) {}\n" +
|
||||
"}");
|
||||
checkHighlighting();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user