Fix for issue #6.
This commit is contained in:
parent
1ba1363dd2
commit
bb7497b494
@ -55,10 +55,11 @@ patchPluginXml {
|
|||||||
setChangeNotes("""
|
setChangeNotes("""
|
||||||
<h4>V1.13 (15-Aug-22)</h4>
|
<h4>V1.13 (15-Aug-22)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Maintenance. Updated various dependencies (Kotlin 1.70.0) and AssertJ 3.23.1 and AssertJ-Guava 3.5.0.
|
<li>Maintenance. Updated various dependencies (Kotlin 1.7.10) and AssertJ 3.23.1 and AssertJ-Guava 3.5.0.
|
||||||
<li>Tried to fix unreproducable issue #9.
|
<li>Tried to fix unreproducable issue #9.
|
||||||
<li>Added workaround for upcoming API change in IntelliJ breaking older releases.
|
<li>Added workaround for upcoming API change in IntelliJ breaking older releases.
|
||||||
<li>Added AssertThatIsZeroOne inspection demanded by issue #5.
|
<li>Added AssertThatIsZeroOne inspection demanded by issue #5.
|
||||||
|
<li>Fix for wrongly joining statements that cannot be trivially joined (e.g. with filteredOn). Fixes issue #6.
|
||||||
</ul>
|
</ul>
|
||||||
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
|
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
|
||||||
""")
|
""")
|
||||||
|
@ -50,9 +50,21 @@ val MORE_EXTENSION_POINTS = CallMatcher.instanceCall(
|
|||||||
"singleElement", "hasOnlyOneElementSatisfying", "anyMatch", "noneMatch", "anySatisfy", "noneSatisfy"
|
"singleElement", "hasOnlyOneElementSatisfying", "anyMatch", "noneMatch", "anySatisfy", "noneSatisfy"
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
|
val FILTERED_ON = CallMatcher.instanceCall(AssertJClassNames.ABSTRACT_ITERABLE_ASSERT_CLASSNAME, "filteredOn", "filteredOnNull", "filteredOnAssertions")!!
|
||||||
|
|
||||||
val COMPLEX_CALLS_THAT_MAKES_STUFF_TRICKY = CallMatcher.anyOf(
|
val COMPLEX_CALLS_THAT_MAKES_STUFF_TRICKY = CallMatcher.anyOf(
|
||||||
|
EXTRACTING_CALL_MATCHERS,
|
||||||
DESCRIBED_AS,
|
DESCRIBED_AS,
|
||||||
WITH_REPRESENTATION_AND_SUCH,
|
WITH_REPRESENTATION_AND_SUCH,
|
||||||
|
FILTERED_ON,
|
||||||
|
USING_COMPARATOR,
|
||||||
|
IN_HEXADECIMAL_OR_BINARY
|
||||||
|
)!!
|
||||||
|
|
||||||
|
val COMPLEX_STUFF_THAT_MAKES_JOINING_IMPOSSIBLE = CallMatcher.anyOf(
|
||||||
|
EXTRACTING_CALL_MATCHERS,
|
||||||
|
WITH_REPRESENTATION_AND_SUCH,
|
||||||
|
FILTERED_ON,
|
||||||
USING_COMPARATOR,
|
USING_COMPARATOR,
|
||||||
IN_HEXADECIMAL_OR_BINARY
|
IN_HEXADECIMAL_OR_BINARY
|
||||||
)!!
|
)!!
|
||||||
|
@ -72,7 +72,7 @@ class JoinAssertThatStatementsInspection : AbstractAssertJInspection() {
|
|||||||
if (!statement.hasAssertThat()) return null
|
if (!statement.hasAssertThat()) return null
|
||||||
|
|
||||||
val assertThatCall = PsiTreeUtil.findChildrenOfType(statement, PsiMethodCallExpression::class.java).find { ALL_ASSERT_THAT_MATCHERS.test(it) }
|
val assertThatCall = PsiTreeUtil.findChildrenOfType(statement, PsiMethodCallExpression::class.java).find { ALL_ASSERT_THAT_MATCHERS.test(it) }
|
||||||
return assertThatCall?.takeIf { it.findFluentCallTo(EXTRACTING_CALL_MATCHERS) == null }
|
return assertThatCall?.takeIf { it.findFluentCallTo(COMPLEX_STUFF_THAT_MAKES_JOINING_IMPOSSIBLE) == null }
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -83,6 +83,7 @@ class JoinAssertThatStatementsInspection : AbstractAssertJInspection() {
|
|||||||
val matched = when (element) {
|
val matched = when (element) {
|
||||||
is PsiUnaryExpression -> (element.operationTokenType == JavaTokenType.PLUSPLUS)
|
is PsiUnaryExpression -> (element.operationTokenType == JavaTokenType.PLUSPLUS)
|
||||||
|| (element.operationTokenType == JavaTokenType.MINUSMINUS)
|
|| (element.operationTokenType == JavaTokenType.MINUSMINUS)
|
||||||
|
|
||||||
is PsiMethodCallExpression -> KNOWN_METHODS_WITH_SIDE_EFFECTS.test(element)
|
is PsiMethodCallExpression -> KNOWN_METHODS_WITH_SIDE_EFFECTS.test(element)
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,9 @@ public class JoinStatements {
|
|||||||
assertThat(list.get(--i)).isEqualTo("foo");
|
assertThat(list.get(--i)).isEqualTo("foo");
|
||||||
assertThat(list.get(--i)).isEqualTo("foo");
|
assertThat(list.get(--i)).isEqualTo("foo");
|
||||||
|
|
||||||
|
assertThat(list).filteredOn("foo", "foo").contains("narf");
|
||||||
|
assertThat(list).filteredOn("bar", "bar").contains("puit");
|
||||||
|
|
||||||
org.junit.Assert.assertThat(list, null);
|
org.junit.Assert.assertThat(list, null);
|
||||||
fail("oh no!");
|
fail("oh no!");
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,9 @@ public class JoinStatements {
|
|||||||
assertThat(list.get(--i)).isEqualTo("foo");
|
assertThat(list.get(--i)).isEqualTo("foo");
|
||||||
assertThat(list.get(--i)).isEqualTo("foo");
|
assertThat(list.get(--i)).isEqualTo("foo");
|
||||||
|
|
||||||
|
assertThat(list).filteredOn("foo", "foo").contains("narf");
|
||||||
|
assertThat(list).filteredOn("bar", "bar").contains("puit");
|
||||||
|
|
||||||
org.junit.Assert.assertThat(list, null);
|
org.junit.Assert.assertThat(list, null);
|
||||||
fail("oh no!");
|
fail("oh no!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user