[java-dfa] AssertJInliner: partially support contains* methods

GitOrigin-RevId: cb4954a6a869cf11f0741db06560f3f5c2a7b7c7
This commit is contained in:
Tagir Valeev
2024-06-25 18:00:05 +02:00
committed by intellij-monorepo-bot
parent a0a8dc42b3
commit 180c1fe1e9

View File

@@ -27,7 +27,7 @@ import static com.intellij.psi.CommonClassNames.JAVA_LANG_BOOLEAN;
public class AssertJInliner implements CallInliner {
private static final String[] METHOD_NAMES =
{"isNotNull", "isNull", "isPresent", "isNotEmpty", "isNotBlank", "isNotPresent", "isEmpty", "isTrue", "isFalse",
"hasOnlyElementsOfType",
"contains", "containsSame", "containsInstanceOf", "hasOnlyElementsOfType",
"hasOnlyElementsOfTypes", "have", "haveAtLeast", "haveAtLeastOne", "haveAtMost", "haveExactly", "hasSize", "hasSizeBetween",
"hasSizeGreaterThan", "hasSizeLessThan", "hasSizeGreaterThanOrEqualTo", "hasSizeLessThanOrEqualTo"};
private static final CallMatcher ASSERT = CallMatcher.anyOf(
@@ -79,7 +79,7 @@ public class AssertJInliner implements CallInliner {
"haveExactly", "hasOnlyElementsOfType", "hasOnlyElementsOfTypes" ->
builder.ensure(RelationType.NE, DfTypes.NULL, new ContractFailureProblem(call), JAVA_LANG_ASSERTION_ERROR);
case "isNull" -> builder.ensure(RelationType.EQ, DfTypes.NULL, new ContractFailureProblem(call), JAVA_LANG_ASSERTION_ERROR);
case "isPresent", "isNotEmpty", "isNotBlank" -> {
case "isPresent", "isNotEmpty", "isNotBlank", "contains", "containsSame", "containsInstanceOf" -> {
builder.ensure(RelationType.NE, DfTypes.NULL, new ContractFailureProblem(call), JAVA_LANG_ASSERTION_ERROR);
if (container) {
builder.unwrap(field);