From b58d8cfd2f64fb91de6584592d39f79abdc98378 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Sat, 13 Apr 2019 18:35:49 +0200 Subject: [PATCH] Fix for incompatible method call regarding IDEA <2018.2. Heavy refactoring regarding quick fixes (using more extensions). Even more refactoring. Fixed/extended AssertThatGuavaOptionalInspection regarding static. imports and wrong reference to core assertThat() where Guava assertThat() actually was necessary. --- README.md | 4 + build.gradle | 7 +- .../plugins/cajon/AssertJClassNames.kt | 2 + .../intellij/plugins/cajon/Extensions.kt | 36 +++++++- .../platon42/intellij/plugins/cajon/Helper.kt | 33 +++++++ .../inspections/AbstractAssertJInspection.kt | 28 ++---- ...BinaryExpressionIsTrueOrFalseInspection.kt | 31 ++++--- .../AssertThatGuavaOptionalInspection.kt | 90 +++++++++++++++---- .../AssertThatJava8OptionalInspection.kt | 22 +++-- .../inspections/AssertThatSizeInspection.kt | 40 ++++----- .../JUnitAssertToAssertJInspection.kt | 37 +++----- .../quickfixes/AbstractCommonQuickFix.kt | 26 ------ .../cajon/quickfixes/ForGuavaPostFix.kt | 27 ++++++ .../quickfixes/QuickFixWithPostfixDelegate.kt | 16 ++++ .../RemoveActualOutmostMethodCallQuickFix.kt | 22 ++--- ...RemoveExpectedOutmostMethodCallQuickFix.kt | 14 +-- .../ReplaceJUnitAssertMethodCallQuickFix.kt | 40 +++------ ...placeJUnitDeltaAssertMethodCallQuickFix.kt | 42 ++------- .../ReplaceSimpleMethodCallQuickFix.kt | 12 +-- .../ReplaceSizeMethodCallQuickFix.kt | 32 +++---- ...SplitBinaryExpressionMethodCallQuickFix.kt | 23 ++--- ...SplitEqualsExpressionMethodCallQuickFix.kt | 17 +--- .../AssertThatGuavaOptionalInspectionTest.kt | 29 +++++- .../AssertThatGuavaOptionalAfter.java | 16 ++++ .../AssertThatGuavaOptionalBefore.java | 16 ++++ .../WithoutPriorGuavaImportAfter.java | 27 ++++++ .../WithoutPriorGuavaImportBefore.java | 26 ++++++ 27 files changed, 425 insertions(+), 290 deletions(-) create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/Helper.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/ForGuavaPostFix.kt create mode 100644 src/main/java/de/platon42/intellij/plugins/cajon/quickfixes/QuickFixWithPostfixDelegate.kt create mode 100644 src/test/resources/inspections/AssertThatGuavaOptional/WithoutPriorGuavaImportAfter.java create mode 100644 src/test/resources/inspections/AssertThatGuavaOptional/WithoutPriorGuavaImportBefore.java diff --git a/README.md b/README.md index fc2b627..7064ab0 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,10 @@ Feel free to use the code (in package de.platon42.intellij.jupiter) for your pro ## Changelog +#### V0.5 (13-Apr-19) +- Fixed incompatibility with IDEA versions < 2018.2 (affected AssertThatSizeInspection). +- Fixed missing Guava imports (if not already present) for AssertThatGuavaInspection. This was a major PITA to get right. + #### V0.4 (11-Apr-19) - Reduced minimal supported IDEA version from 2018.2 to 2017.2. - New inspection AssertThatJava8Optional that operates on Java 8 Optional objects and tries to use contains(), containsSame(), isPresent(), and isNotPresent() instead. diff --git a/build.gradle b/build.gradle index b7d887b..559d802 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'de.platon42' -version '0.4' +version '0.5' repositories { mavenCentral() @@ -41,6 +41,11 @@ intellij { patchPluginXml { changeNotes """ +

V0.5 (13-Apr-19)

+

V0.4 (11-Apr-19)