diff --git a/LICENSE.TXT b/LICENSE.TXT index d50b2aa..3384159 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,4 +1,4 @@ -Copyright 2019 Chris Hodges +Copyright 2019-2022 Chris Hodges Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 688e3d9..fad2f65 100644 --- a/README.md +++ b/README.md @@ -798,7 +798,7 @@ You can toggle the various inspections in the Settings/Editor/Inspections in the ## Development notice -Cajon is written in Kotlin 1.4. +Cajon is written in Kotlin 1.7. Cajon is probably the only plugin that uses JUnit 5 Jupiter for unit testing so far (or at least the only one I'm aware of ;) ). The IntelliJ framework actually uses the JUnit 3 TestCase for plugin testing, and it took me quite a while to make it work with JUnit 5. @@ -814,6 +814,7 @@ Feel free to use the code (in package ```de.platon42.intellij.jupiter```) for yo from: assertThat(object).extracting("propOne", "propNoGetter", "propTwo.innerProp")... to: assertThat(object).extracting(type::getPropOne, it -> it.propNoGetter, it -> it.getPropTwo().getInnerProp())... ``` +- Support primitives in assertThat(map.containsKey(1)).isTrue(); ## Changelog diff --git a/build.gradle b/build.gradle index 15d3dee..dd7faac 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { id 'java' - id 'org.jetbrains.intellij' version '1.1.3' - id 'org.jetbrains.kotlin.jvm' version '1.5.21' + id 'org.jetbrains.intellij' version '1.8.0' + id 'org.jetbrains.kotlin.jvm' version '1.7.10' id 'jacoco' - id 'com.github.kt3k.coveralls' version '2.11.0' + id 'com.github.kt3k.coveralls' version '2.12.0' } group 'de.platon42' -version '1.12' +version '1.13' sourceCompatibility = "1.8" targetCompatibility = "1.8" @@ -22,10 +22,10 @@ repositories { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" - testImplementation "org.assertj:assertj-core:3.20.2" - testImplementation "org.assertj:assertj-guava:3.4.0" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.0-M1' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.0-M1' + testImplementation "org.assertj:assertj-core:3.23.1" + testImplementation "org.assertj:assertj-guava:3.5.0" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0' testImplementation "org.jetbrains.kotlin:kotlin-test" testImplementation "org.jetbrains.kotlin:kotlin-reflect" // testImplementation "org.jetbrains.kotlin:kotlin-test-junit" @@ -40,18 +40,24 @@ compileTestKotlin { } intellij { - setVersion("2021.1.3") // LATEST-EAP-SNAPSHOT + setVersion("2022.2") // LATEST-EAP-SNAPSHOT //pluginName.set(provider { 'Concise AssertJ Optimizing Nitpicker (Cajon)' }) setUpdateSinceUntilBuild(false) setPlugins(["com.intellij.java"]) } +runPluginVerifier { + ideVersions = ["IC-193.5662.53", "IC-222.3345.118"] // 2020.3 - 2022.2 + downloadDir = System.getProperty("user.home") + "/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/verifier" +} + patchPluginXml { setChangeNotes(""" -

V1.12 (06-May-21)

+

V1.13 (15-Aug-22)

Full changelog available at Github project site.

""") @@ -64,8 +70,12 @@ test { } } +tasks.test { + systemProperty("idea.force.use.core.classloader", "true") +} + jacoco { - toolVersion = '0.8.7' + toolVersion = '0.8.8' } jacocoTestReport { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 05679dc..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists 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 d303f9d..ccd53e0 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/Extensions.kt @@ -115,8 +115,7 @@ fun PsiMethodCallExpression.getExpectedNullNonNullResult(): Boolean? { } fun PsiMethodCallExpression.calculateConstantParameterValue(argIndex: Int): Any? { - if (argIndex >= argumentList.expressions.size) return null - return getArg(argIndex).calculateConstantValue() + return getArgOrNull(argIndex)?.calculateConstantValue() } fun PsiExpression.calculateConstantValue(): Any? { diff --git a/src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/JoinStatementsQuickFix.kt b/src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/JoinStatementsQuickFix.kt index db7a2fb..90d9b7e 100644 --- a/src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/JoinStatementsQuickFix.kt +++ b/src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/JoinStatementsQuickFix.kt @@ -56,9 +56,14 @@ class JoinStatementsQuickFix(private val separateLineLimit: Int) : AbstractCommo } private fun addLineBreak(project: Project, lastElementBeforeConcat: PsiElement) { - val newLineNode = + val newLineNode = try { + PsiParserFacade.getInstance(project).createWhiteSpaceFromText("\n\t") + } catch (ex: NoSuchMethodError) { + // scheduled for removal, but alternate version not even available in 2020.3. + // So keep it here until we run into a problem. + // Changing the min version from 2017.3 to 2021.x is a major thing. PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\t") - + } lastElementBeforeConcat.addAfter(newLineNode, lastElementBeforeConcat.firstChild) } diff --git a/src/test/java/de/platon42/intellij/plugins/cajon/AbstractCajonTest.kt b/src/test/java/de/platon42/intellij/plugins/cajon/AbstractCajonTest.kt index 8e1c44a..c8cf73f 100644 --- a/src/test/java/de/platon42/intellij/plugins/cajon/AbstractCajonTest.kt +++ b/src/test/java/de/platon42/intellij/plugins/cajon/AbstractCajonTest.kt @@ -8,6 +8,7 @@ import de.platon42.intellij.jupiter.LightCodeInsightExtension import de.platon42.intellij.jupiter.TestDataPath import de.platon42.intellij.jupiter.TestJdk import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Condition import org.junit.jupiter.api.DisplayNameGeneration import org.junit.jupiter.api.DisplayNameGenerator import org.junit.jupiter.api.extension.ExtendWith @@ -39,11 +40,8 @@ abstract class AbstractCajonTest { } protected fun assertHighlightings(myFixture: JavaCodeInsightTestFixture, count: Int, snippet: String) { - val highlights = myFixture.doHighlighting() - .asSequence() - .filter { it.description?.contains(snippet) ?: false } - .toList() - assertThat(highlights).hasSize(count) + assertThat(myFixture.doHighlighting()) + .areExactly(count, Condition({ it.description?.contains(snippet) ?: false }, "containing")) } class CutOffFixtureDisplayNameGenerator : DisplayNameGenerator.ReplaceUnderscores() {