Minor NPE Bugfix. Fixed use of "experimental API". Upgraded dependencies.

This commit is contained in:
Chris Hodges 2019-12-22 19:47:18 +01:00
parent a0909d8c39
commit 77d3608fd3
6 changed files with 18 additions and 24 deletions

View File

@ -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,

View File

@ -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 """
<h4>V1.7 (19-Nov-19)</h4>
<h4>V1.8 (unreleased)</h4>
<ul>
<li>Fixed a lapsuus in AssertThatFileExpression also transforming listFiles() with a filter argument.
<li>Added first version of AssertThatPathExpression for a limited number transformations (more stuff is possible,
but requires detection and transformation of static Files-methods).
<li>Added AssertThatComparableExpression for funny compareTo() uses.
<li>Added hasSize(), isEmpty() and isNotEmpty() for AssertThatFileExpression when using AssertJ >= 3.14.0.
<li>Maintenance. Removed experimental API use. Updated dependencies.
</ul>
<p>Full changelog available at <a href="https://github.com/chrisly42/cajon-plugin#changelog">Github project site</a>.</p>
"""

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<PsiElement>(fieldResult, matchedGetter, matchedBareMethod)
if (targets.isNotEmpty()) {
val results = listOf(textRange to targets)
@ -44,7 +43,7 @@ class ExtractorReferenceContributor : PsiReferenceContributor() {
}
private fun lookupMethod(containingClass: PsiClass, methodName: String): List<Pair<TextRange, List<PsiElement>>>? {
val matchedMethod = containingClass.allMethods.find { (it.name == methodName) && !it.hasModifier(JvmModifier.STATIC) } ?: return null
val matchedMethod = containingClass.allMethods.find { (it.name == methodName) && !it.hasModifierProperty(PsiModifier.STATIC) } ?: return null
val textRange = TextRange(1, methodName.length + 1)
return listOf(textRange to listOf(matchedMethod))
}