Bumped kotlin to 1.3.41, jupiter 5.5.1, added compatibility with IDEA 2019.2 and fixed regressions with new AssertJ 3.13.0.
This commit is contained in:
parent
5048c898ec
commit
8fb3ecce95
18
build.gradle
18
build.gradle
@ -1,13 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '0.4.9'
|
id 'org.jetbrains.intellij' version '0.4.9'
|
||||||
id 'org.jetbrains.kotlin.jvm' version '1.3.40'
|
id 'org.jetbrains.kotlin.jvm' version '1.3.41'
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
id 'com.github.kt3k.coveralls' version '2.8.2'
|
id 'com.github.kt3k.coveralls' version '2.8.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'de.platon42'
|
group 'de.platon42'
|
||||||
version '1.2'
|
version '1.3'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -20,10 +20,10 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
testCompile "org.assertj:assertj-core:3.12.2"
|
testCompile "org.assertj:assertj-core:3.13.0"
|
||||||
testCompile "org.assertj:assertj-guava:3.2.1"
|
testCompile "org.assertj:assertj-guava:3.2.1"
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.0-RC2'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.1'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.0-RC2'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.1'
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||||
// testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
// testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
||||||
}
|
}
|
||||||
@ -35,17 +35,17 @@ compileTestKotlin {
|
|||||||
kotlinOptions.jvmTarget = "1.8"
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
intellij {
|
intellij {
|
||||||
version '2019.1.3'
|
version '2019.2'
|
||||||
// pluginName 'Concise AssertJ Optimizing Nitpicker (Cajon)'
|
// pluginName 'Concise AssertJ Optimizing Nitpicker (Cajon)'
|
||||||
updateSinceUntilBuild false
|
updateSinceUntilBuild false
|
||||||
|
plugins = ['java']
|
||||||
}
|
}
|
||||||
|
|
||||||
patchPluginXml {
|
patchPluginXml {
|
||||||
changeNotes """
|
changeNotes """
|
||||||
<h4>V1.2 (23-Jun-19)</h4>
|
<h4>V1.3 (01-Aug-19)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Due to popular demand the JoinAssertThatStatements inspection will now add line breaks on joining statements.
|
<li>AssertJ 3.13.0 broke some inspections due to new AbstractStringAssert::isEqualTo().
|
||||||
The amount of statements joined without causing line breaks can be configured but defaults to 1 (always).
|
|
||||||
</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>
|
||||||
"""
|
"""
|
||||||
|
@ -106,7 +106,7 @@ fun PsiMethodCallExpression.getExpectedNullNonNullResult(): Boolean? {
|
|||||||
if (isNull || isNotNull) {
|
if (isNull || isNotNull) {
|
||||||
return isNotNull
|
return isNotNull
|
||||||
} else {
|
} else {
|
||||||
val isEqualTo = AbstractAssertJInspection.IS_EQUAL_TO_OBJECT.test(this)
|
val isEqualTo = CallMatcher.anyOf(AbstractAssertJInspection.IS_EQUAL_TO_OBJECT, AbstractAssertJInspection.IS_EQUAL_TO_STRING).test(this)
|
||||||
val isNotEqualTo = AbstractAssertJInspection.IS_NOT_EQUAL_TO_OBJECT.test(this)
|
val isNotEqualTo = AbstractAssertJInspection.IS_NOT_EQUAL_TO_OBJECT.test(this)
|
||||||
if ((isEqualTo || isNotEqualTo) && firstArg.type == PsiType.NULL) {
|
if ((isEqualTo || isNotEqualTo) && firstArg.type == PsiType.NULL) {
|
||||||
return isNotEqualTo
|
return isNotEqualTo
|
||||||
|
@ -13,6 +13,7 @@ import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_A
|
|||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_BOOLEAN_ASSERT_CLASSNAME
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_BOOLEAN_ASSERT_CLASSNAME
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_COMPARABLE_ASSERT_CLASSNAME
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_COMPARABLE_ASSERT_CLASSNAME
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_INTEGER_ASSERT_CLASSNAME
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_INTEGER_ASSERT_CLASSNAME
|
||||||
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_STRING_ASSERT_CLASSNAME
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ASSERTIONS_CLASSNAME
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ASSERTIONS_CLASSNAME
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ASSERT_INTERFACE
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ASSERT_INTERFACE
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ENUMERABLE_ASSERT_INTERFACE
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ENUMERABLE_ASSERT_INTERFACE
|
||||||
@ -81,6 +82,8 @@ open class AbstractAssertJInspection : AbstractBaseJavaLocalInspectionTool() {
|
|||||||
|
|
||||||
val IS_EQUAL_TO_OBJECT = CallMatcher.instanceCall(ASSERT_INTERFACE, MethodNames.IS_EQUAL_TO)
|
val IS_EQUAL_TO_OBJECT = CallMatcher.instanceCall(ASSERT_INTERFACE, MethodNames.IS_EQUAL_TO)
|
||||||
.parameterTypes(CommonClassNames.JAVA_LANG_OBJECT)!!
|
.parameterTypes(CommonClassNames.JAVA_LANG_OBJECT)!!
|
||||||
|
val IS_EQUAL_TO_STRING = CallMatcher.instanceCall(ABSTRACT_STRING_ASSERT_CLASSNAME, MethodNames.IS_EQUAL_TO)
|
||||||
|
.parameterTypes(CommonClassNames.JAVA_LANG_STRING)!!
|
||||||
val IS_NOT_EQUAL_TO_OBJECT = CallMatcher.instanceCall(ASSERT_INTERFACE, MethodNames.IS_NOT_EQUAL_TO)
|
val IS_NOT_EQUAL_TO_OBJECT = CallMatcher.instanceCall(ASSERT_INTERFACE, MethodNames.IS_NOT_EQUAL_TO)
|
||||||
.parameterTypes(CommonClassNames.JAVA_LANG_OBJECT)!!
|
.parameterTypes(CommonClassNames.JAVA_LANG_OBJECT)!!
|
||||||
val IS_EQUAL_TO_BOOLEAN = CallMatcher.instanceCall(ABSTRACT_BOOLEAN_ASSERT_CLASSNAME, MethodNames.IS_EQUAL_TO)
|
val IS_EQUAL_TO_BOOLEAN = CallMatcher.instanceCall(ABSTRACT_BOOLEAN_ASSERT_CLASSNAME, MethodNames.IS_EQUAL_TO)
|
||||||
|
@ -30,7 +30,7 @@ class AssertThatGuavaOptionalInspection : AbstractAssertJInspection() {
|
|||||||
val outmostMethodCall = statement.findOutmostMethodCall() ?: return
|
val outmostMethodCall = statement.findOutmostMethodCall() ?: return
|
||||||
if (GUAVA_OPTIONAL_GET.test(actualExpression)) {
|
if (GUAVA_OPTIONAL_GET.test(actualExpression)) {
|
||||||
val expectedCallExpression = staticMethodCall.gatherAssertionCalls().singleOrNull() ?: return
|
val expectedCallExpression = staticMethodCall.gatherAssertionCalls().singleOrNull() ?: return
|
||||||
if (IS_EQUAL_TO_OBJECT.test(expectedCallExpression)) {
|
if (CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING).test(expectedCallExpression)) {
|
||||||
registerMoveOutMethod(holder, outmostMethodCall, actualExpression, MethodNames.CONTAINS) { desc, method ->
|
registerMoveOutMethod(holder, outmostMethodCall, actualExpression, MethodNames.CONTAINS) { desc, method ->
|
||||||
QuickFixWithPostfixDelegate(
|
QuickFixWithPostfixDelegate(
|
||||||
RemoveActualOutmostMethodCallQuickFix(desc, method),
|
RemoveActualOutmostMethodCallQuickFix(desc, method),
|
||||||
|
@ -28,7 +28,7 @@ class AssertThatJava8OptionalInspection : AbstractAssertJInspection() {
|
|||||||
val outmostMethodCall = statement.findOutmostMethodCall() ?: return
|
val outmostMethodCall = statement.findOutmostMethodCall() ?: return
|
||||||
if (OPTIONAL_GET.test(actualExpression)) {
|
if (OPTIONAL_GET.test(actualExpression)) {
|
||||||
val expectedCallExpression = staticMethodCall.gatherAssertionCalls().singleOrNull() ?: return
|
val expectedCallExpression = staticMethodCall.gatherAssertionCalls().singleOrNull() ?: return
|
||||||
if (IS_EQUAL_TO_OBJECT.test(expectedCallExpression)) {
|
if (CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING).test(expectedCallExpression)) {
|
||||||
registerMoveOutMethod(holder, outmostMethodCall, actualExpression, MethodNames.CONTAINS) { desc, method ->
|
registerMoveOutMethod(holder, outmostMethodCall, actualExpression, MethodNames.CONTAINS) { desc, method ->
|
||||||
RemoveActualOutmostMethodCallQuickFix(desc, method)
|
RemoveActualOutmostMethodCallQuickFix(desc, method)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class AssertThatObjectExpressionInspection : AbstractAssertJInspection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OBJECT_TO_STRING.test(assertThatArgument) -> {
|
OBJECT_TO_STRING.test(assertThatArgument) -> {
|
||||||
staticMethodCall.findFluentCallTo(IS_EQUAL_TO_OBJECT) ?: return
|
staticMethodCall.findFluentCallTo(IS_EQUAL_TO_OBJECT) ?: staticMethodCall.findFluentCallTo(IS_EQUAL_TO_STRING) ?: return
|
||||||
registerMoveOutMethod(holder, expectedCallExpression, assertThatArgument, MethodNames.HAS_TO_STRING) { desc, method ->
|
registerMoveOutMethod(holder, expectedCallExpression, assertThatArgument, MethodNames.HAS_TO_STRING) { desc, method ->
|
||||||
RemoveActualOutmostMethodCallQuickFix(desc, method)
|
RemoveActualOutmostMethodCallQuickFix(desc, method)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package de.platon42.intellij.plugins.cajon.inspections
|
|||||||
|
|
||||||
import com.intellij.codeInspection.ProblemsHolder
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
|
import com.siyeh.ig.callMatcher.CallMatcher
|
||||||
import de.platon42.intellij.plugins.cajon.MethodNames
|
import de.platon42.intellij.plugins.cajon.MethodNames
|
||||||
import de.platon42.intellij.plugins.cajon.firstArg
|
import de.platon42.intellij.plugins.cajon.firstArg
|
||||||
import de.platon42.intellij.plugins.cajon.hasAssertThat
|
import de.platon42.intellij.plugins.cajon.hasAssertThat
|
||||||
@ -21,7 +22,7 @@ class AssertThatObjectIsNullOrNotNullInspection : AbstractAssertJInspection() {
|
|||||||
super.visitMethodCallExpression(expression)
|
super.visitMethodCallExpression(expression)
|
||||||
if (!expression.hasAssertThat()) return
|
if (!expression.hasAssertThat()) return
|
||||||
val isNotEqualTo = IS_NOT_EQUAL_TO_OBJECT.test(expression)
|
val isNotEqualTo = IS_NOT_EQUAL_TO_OBJECT.test(expression)
|
||||||
val isEqualTo = IS_EQUAL_TO_OBJECT.test(expression)
|
val isEqualTo = CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING).test(expression)
|
||||||
val isLastExpression = expression.parent is PsiStatement
|
val isLastExpression = expression.parent is PsiStatement
|
||||||
if (!((isEqualTo && isLastExpression) || isNotEqualTo)) return
|
if (!((isEqualTo && isLastExpression) || isNotEqualTo)) return
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.intellij.psi.JavaElementVisitor
|
|||||||
import com.intellij.psi.PsiElementVisitor
|
import com.intellij.psi.PsiElementVisitor
|
||||||
import com.intellij.psi.PsiMethodCallExpression
|
import com.intellij.psi.PsiMethodCallExpression
|
||||||
import com.intellij.psi.PsiStatement
|
import com.intellij.psi.PsiStatement
|
||||||
|
import com.siyeh.ig.callMatcher.CallMatcher
|
||||||
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_CHAR_SEQUENCE_ASSERT_CLASSNAME
|
import de.platon42.intellij.plugins.cajon.AssertJClassNames.Companion.ABSTRACT_CHAR_SEQUENCE_ASSERT_CLASSNAME
|
||||||
import de.platon42.intellij.plugins.cajon.MethodNames
|
import de.platon42.intellij.plugins.cajon.MethodNames
|
||||||
import de.platon42.intellij.plugins.cajon.calculateConstantParameterValue
|
import de.platon42.intellij.plugins.cajon.calculateConstantParameterValue
|
||||||
@ -23,7 +24,7 @@ class AssertThatStringIsEmptyInspection : AbstractAssertJInspection() {
|
|||||||
override fun visitMethodCallExpression(expression: PsiMethodCallExpression) {
|
override fun visitMethodCallExpression(expression: PsiMethodCallExpression) {
|
||||||
super.visitMethodCallExpression(expression)
|
super.visitMethodCallExpression(expression)
|
||||||
if (!expression.hasAssertThat()) return
|
if (!expression.hasAssertThat()) return
|
||||||
val isEqual = IS_EQUAL_TO_OBJECT.test(expression)
|
val isEqual = CallMatcher.anyOf(IS_EQUAL_TO_OBJECT, IS_EQUAL_TO_STRING).test(expression)
|
||||||
val hasSize = HAS_SIZE.test(expression)
|
val hasSize = HAS_SIZE.test(expression)
|
||||||
val isLastExpression = expression.parent is PsiStatement
|
val isLastExpression = expression.parent is PsiStatement
|
||||||
if (!((isEqual || hasSize) && isLastExpression)) return
|
if (!((isEqual || hasSize) && isLastExpression)) return
|
||||||
|
@ -11,7 +11,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
|||||||
import com.intellij.testFramework.*;
|
import com.intellij.testFramework.*;
|
||||||
import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy;
|
import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy;
|
||||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture;
|
||||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.jupiter.api.extension.*;
|
import org.junit.jupiter.api.extension.*;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
|
||||||
@ -88,7 +88,6 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
|
|||||||
TestLoggerFactory.onTestFinished(true);
|
TestLoggerFactory.onTestFinished(true);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
TestLoggerFactory.onTestFinished(false);
|
TestLoggerFactory.onTestFinished(false);
|
||||||
e.fillInStackTrace();
|
|
||||||
throwables[0] = e;
|
throwables[0] = e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -112,7 +111,7 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LightCodeInsightFixtureTestCaseWrapper extends LightCodeInsightFixtureTestCase {
|
private static class LightCodeInsightFixtureTestCaseWrapper extends LightJavaCodeInsightFixtureTestCase {
|
||||||
private final ExtensionContext extensionContext;
|
private final ExtensionContext extensionContext;
|
||||||
|
|
||||||
private LightCodeInsightFixtureTestCaseWrapper(ExtensionContext extensionContext) {
|
private LightCodeInsightFixtureTestCaseWrapper(ExtensionContext extensionContext) {
|
||||||
@ -159,7 +158,7 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addJarContaining(ModifiableRootModel model, Class clazz) {
|
void addJarContaining(ModifiableRootModel model, Class clazz) {
|
||||||
try {
|
try {
|
||||||
Path jarPath = Paths.get(clazz.getProtectionDomain().getCodeSource().getLocation().toURI());
|
Path jarPath = Paths.get(clazz.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user