Fixed ImplicitAssertion crashing the plugin with IntelliJ 2020.3 EAP, added support for singleElement(). Unrelated: Documentation grammar fixes.
This commit is contained in:
@@ -33,7 +33,7 @@ val MORE_EXTENSION_POINTS = CallMatcher.instanceCall(
|
||||
"are", "areNot", "have", "doNotHave",
|
||||
"areAtLeast", "areAtLeastOne", "areAtMost", "areExactly",
|
||||
"haveAtLeastOne", "haveAtLeast", "haveAtMost", "haveExactly",
|
||||
"hasOnlyOneElementSatisfying", "anyMatch", "noneMatch", "anySatisfy", "noneSatisfy"
|
||||
"singleElement", "hasOnlyOneElementSatisfying", "anyMatch", "noneMatch", "anySatisfy", "noneSatisfy"
|
||||
)!!
|
||||
|
||||
val COMPLEX_CALLS_THAT_MAKES_STUFF_TRICKY = CallMatcher.anyOf(
|
||||
|
||||
+1
-2
@@ -39,11 +39,10 @@ class ImplicitAssertionInspection : AbstractAssertJInspection() {
|
||||
"startsWith", "endsWith", "containsNull", "doesNotContainNull",
|
||||
"are", "areNot", "have", "doNotHave", "areAtLeastOne", "areAtLeast", "areAtMost", "areExactly",
|
||||
"haveAtLeastOne", "haveAtLeast", "haveAtMost", "haveExactly",
|
||||
"doesNotHave", "doesNotHaveSameClassAs",
|
||||
"hasAtLeastOneElementOfType", "hasOnlyElementsOfType", "hasOnlyElementsOfTypes",
|
||||
"doesNotHaveAnyElementsOfTypes",
|
||||
"has", "doesNotHave",
|
||||
"hasOnlyOneElementSatisfying", "hasSameElementsAs",
|
||||
"singleElement", "hasOnlyOneElementSatisfying", "hasSameElementsAs",
|
||||
"allMatch", "allSatisfy", "anyMatch", "anySatisfy", "noneMatch", "noneSatisfy"
|
||||
)!!
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ internal class ImplicitAssertionInspectionTest : AbstractCajonTest() {
|
||||
internal fun implicit_assertions_can_be_removed(@MyFixture myFixture: JavaCodeInsightTestFixture) {
|
||||
myFixture.enableInspections(ImplicitAssertionInspection::class.java)
|
||||
myFixture.configureByFile("ImplicitAssertionBefore.java")
|
||||
executeQuickFixesNoFamilyNameCheck(myFixture, Regex("Delete implicit isNotNull\\(\\) covered by .*"), 101)
|
||||
executeQuickFixesNoFamilyNameCheck(myFixture, Regex("Delete implicit isNotNull\\(\\) covered by .*"), 102)
|
||||
executeQuickFixesNoFamilyNameCheck(myFixture, Regex("Delete implicit isNotEmpty\\(\\) covered by .*"), 17)
|
||||
executeQuickFixesNoFamilyNameCheck(myFixture, Regex("Delete implicit isPresent\\(\\) covered by .*"), 8)
|
||||
myFixture.checkResultByFile("ImplicitAssertionAfter.java")
|
||||
|
||||
@@ -153,6 +153,7 @@ public class ImplicitAssertion {
|
||||
assertThat(list).areAtMost(1, stringCondition);
|
||||
assertThat(list).areExactly(1, stringCondition);
|
||||
assertThat(list).hasOnlyOneElementSatisfying(stringConsumer);
|
||||
assertThat(list).singleElement(as(STRING)).isEqualTo(stringConsumer);
|
||||
assertThat(list).haveAtLeastOne(stringCondition);
|
||||
assertThat(list).haveAtLeast(1, stringCondition);
|
||||
assertThat(list).haveAtMost(1, stringCondition);
|
||||
@@ -229,6 +230,7 @@ public class ImplicitAssertion {
|
||||
assertThat(list).isNotEmpty().areAtMost(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().areExactly(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().hasOnlyOneElementSatisfying(stringConsumer);
|
||||
assertThat(list).isNotEmpty().singleElement(as(STRING)).isEqualTo(stringConsumer);
|
||||
assertThat(list).haveAtLeastOne(stringCondition);
|
||||
assertThat(list).isNotEmpty().haveAtLeast(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().haveAtMost(1, stringCondition);
|
||||
|
||||
@@ -153,6 +153,7 @@ public class ImplicitAssertion {
|
||||
assertThat(list).isNotNull().areAtMost(1, stringCondition);
|
||||
assertThat(list).isNotNull().areExactly(1, stringCondition);
|
||||
assertThat(list).isNotNull().hasOnlyOneElementSatisfying(stringConsumer);
|
||||
assertThat(list).isNotNull().singleElement(as(STRING)).isEqualTo(stringConsumer);
|
||||
assertThat(list).isNotNull().haveAtLeastOne(stringCondition);
|
||||
assertThat(list).isNotNull().haveAtLeast(1, stringCondition);
|
||||
assertThat(list).isNotNull().haveAtMost(1, stringCondition);
|
||||
@@ -229,6 +230,7 @@ public class ImplicitAssertion {
|
||||
assertThat(list).isNotEmpty().areAtMost(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().areExactly(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().hasOnlyOneElementSatisfying(stringConsumer);
|
||||
assertThat(list).isNotEmpty().singleElement(as(STRING)).isEqualTo(stringConsumer);
|
||||
assertThat(list).isNotEmpty().haveAtLeastOne(stringCondition);
|
||||
assertThat(list).isNotEmpty().haveAtLeast(1, stringCondition);
|
||||
assertThat(list).isNotEmpty().haveAtMost(1, stringCondition);
|
||||
|
||||
Reference in New Issue
Block a user