diff --git a/README.md b/README.md index c3444b8..698e749 100644 --- a/README.md +++ b/README.md @@ -711,6 +711,8 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo ## Changelog +#### V1.8 (unreleased) + #### V1.7 (19-Nov-19) - Fixed a lapsuus in AssertThatFileExpression also transforming ```.listFiles()``` with a filter argument. - Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible, diff --git a/build.gradle b/build.gradle index 12b4fd7..cf34d9b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { id 'java' - id 'org.jetbrains.intellij' version '0.4.13' - id 'org.jetbrains.kotlin.jvm' version '1.3.60' + id 'org.jetbrains.intellij' version '0.4.16' + id 'org.jetbrains.kotlin.jvm' version '1.3.61' id 'jacoco' - id 'com.github.kt3k.coveralls' version '2.8.4' + id 'com.github.kt3k.coveralls' version '2.9.0' } group 'de.platon42' -version '1.7' +version '1.8' repositories { mavenCentral() @@ -20,10 +20,10 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" - testCompile "org.assertj:assertj-core:3.14.0" + testCompile "org.assertj:assertj-core:3.15.0" testCompile "org.assertj:assertj-guava:3.3.0" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0' testImplementation "org.jetbrains.kotlin:kotlin-test" // testImplementation "org.jetbrains.kotlin:kotlin-test-junit" } @@ -35,7 +35,7 @@ compileTestKotlin { kotlinOptions.jvmTarget = "1.8" } intellij { - version '2019.2.4' + version '2019.2.4' // Upgrading to 2019.3.x breaks build/tests due to dependency with assertj-core 13.3.2 // pluginName 'Concise AssertJ Optimizing Nitpicker (Cajon)' updateSinceUntilBuild false plugins = ['java'] @@ -43,13 +43,9 @@ intellij { patchPluginXml { changeNotes """ -
Full changelog available at Github project site.
""" diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt b/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt index eb99ba0..1f3b975 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt @@ -1,6 +1,5 @@ package de.platon42.intellij.plugins.cajon -import com.intellij.lang.jvm.JvmModifier import com.intellij.psi.* import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.codeStyle.JavaCodeStyleManager @@ -33,7 +32,7 @@ fun PsiElement.findOutmostMethodCall(): PsiMethodCallExpression? { fun PsiElement.findStaticMethodCall(): PsiMethodCallExpression? { var elem: PsiElement? = this while (elem != null) { - if ((elem is PsiMethodCallExpression) && (elem.resolveMethod()?.hasModifier(JvmModifier.STATIC) == true)) { + if ((elem is PsiMethodCallExpression) && (elem.resolveMethod()?.hasModifierProperty(PsiModifier.STATIC) == true)) { return elem } elem = elem.firstChild diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt index ec42c1d..ea344ee 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatGuavaOptionalInspection.kt @@ -92,9 +92,7 @@ class AssertThatGuavaOptionalInspection : AbstractAssertJInspection() { } private fun checkPreconditions(staticMethodCall: PsiMethodCallExpression): Boolean { - val assertThatGuava = GUAVA_ASSERT_THAT_ANY.test(staticMethodCall) - - if (ASSERT_THAT_ANY.test(staticMethodCall) || assertThatGuava) { + if (CallMatcher.anyOf(ASSERT_THAT_ANY, GUAVA_ASSERT_THAT_ANY).test(staticMethodCall)) { JavaPsiFacade.getInstance(staticMethodCall.project) .findClass(AssertJClassNames.GUAVA_ASSERTIONS_CLASSNAME, GlobalSearchScope.allScope(staticMethodCall.project)) ?: return false return true diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectExpressionInspection.kt b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectExpressionInspection.kt index 6d85704..5e62010 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectExpressionInspection.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/inspections/AssertThatObjectExpressionInspection.kt @@ -34,9 +34,9 @@ class AssertThatObjectExpressionInspection : AbstractMoveOutInspection() { override fun visitExpressionStatement(statement: PsiExpressionStatement) { super.visitExpressionStatement(statement) if (!statement.hasAssertThat()) return - + val staticMethodCall = statement.findStaticMethodCall() ?: return - val assertThatArgument = staticMethodCall.firstArg as? PsiMethodCallExpression ?: return + val assertThatArgument = staticMethodCall.getArgOrNull(0) as? PsiMethodCallExpression ?: return if (OBJECT_HASHCODE.test(assertThatArgument)) { val expectedCallExpression = statement.findOutmostMethodCall() ?: return val isEqualTo = staticMethodCall.findFluentCallTo(IS_EQUAL_TO_INT) ?: return diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/references/ExtractorReferenceContributor.kt b/src/main/java/de/platon42/intellij/plugins/cajon/references/ExtractorReferenceContributor.kt index 25a1937..ff69374 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/references/ExtractorReferenceContributor.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/references/ExtractorReferenceContributor.kt @@ -1,6 +1,5 @@ package de.platon42.intellij.plugins.cajon.references -import com.intellij.lang.jvm.JvmModifier import com.intellij.openapi.util.TextRange import com.intellij.patterns.PlatformPatterns import com.intellij.psi.* @@ -30,7 +29,7 @@ class ExtractorReferenceContributor : PsiReferenceContributor() { val matchedGetter = PropertyUtilBase.findPropertyGetter(containingClass, partName, false, true) val fieldResult = PropertyUtilBase.findPropertyField(containingClass, partName, false) val textRange = TextRange(startOffset + 1, nextOffset) - val matchedBareMethod = containingClass.allMethods.find { (it.name == partName) && !it.hasModifier(JvmModifier.STATIC) } + val matchedBareMethod = containingClass.allMethods.find { (it.name == partName) && !it.hasModifierProperty(PsiModifier.STATIC) } val targets = listOfNotNull