From 28b661acee7e73b9346b67c1a9c45d1427dcb913 Mon Sep 17 00:00:00 2001 From: Michail Plushnikov Date: Wed, 24 Oct 2018 20:40:05 +0200 Subject: [PATCH] Cleanup extenion point (#544) * added example for issue #512 * fix removing of field annotations during delombok * cleanup code * added to changelog #530 * added support for ImplicitResourceCloser extension point for @Cleanup #287 * master is now for: up from 2018.1 IntelliJ builds --- .travis.yml | 4 -- gradle.properties | 4 -- parts/pluginChanges.html | 2 + .../plugin/action/BaseRefactorAction.java | 4 +- .../inline/LombokInlineMethodHandler.java | 6 +-- .../extension/LombokCanBeFinalHandler.java | 4 +- .../LombokCleanUpImplicitResourceCloser.java | 17 +++++++ .../extension/LombokHighlightErrorFilter.java | 8 ++-- .../plugin/lombokconfig/ConfigIndexKey.java | 6 +-- .../processor/LombokPsiElementUsage.java | 2 +- .../clazz/AbstractClassProcessor.java | 4 +- .../clazz/EqualsAndHashCodeProcessor.java | 4 +- .../processor/clazz/ToStringProcessor.java | 4 +- .../clazz/builder/BuilderProcessor.java | 5 +- .../NoArgsConstructorProcessor.java | 2 +- .../plugin/processor/field/AccessorsInfo.java | 2 +- .../provider/LombokProcessorProvider.java | 4 +- .../plugin/psi/LombokLightModifierList.java | 6 +-- .../ChangeAnnotationParameterQuickFix.java | 2 +- .../plugin/quickfix/CreateFieldQuickFix.java | 2 +- .../plugin/settings/ProjectSettingsPage.java | 2 +- .../plugin/util/PsiAnnotationSearchUtil.java | 5 ++ .../intellij/plugin/util/PsiElementUtil.java | 2 +- .../intellij/plugin/util/ReflectionUtil.java | 16 ------- src/main/resources/META-INF/plugin.xml | 2 + .../messages/lombokBundle.properties | 2 + ...okPluginProjectValidatorComponentTest.java | 24 +++++----- .../intellij/plugin/SneakyThrowsTest.java | 2 +- .../DelombokEqualsAndHashcodeActionTest.java | 4 ++ .../AbstractLombokConfigSystemTestCase.java | 2 +- .../completion/LoggerCompletionTest.java | 4 +- .../extension/LombokElementFinderTest.java | 8 ++-- .../AutoCloseableResourceInspectionTest.java | 22 +++++++++ .../inspection/BuilderInspectionTest.java | 12 ++--- .../DefaultConstructorInspectionTest.java | 10 ++-- .../inspection/DelegateInspectionTest.java | 8 ++-- .../FieldDefaultsOnEnumInspectionTest.java | 2 +- .../FieldMayBeFinalInspectionTest.java | 12 ++--- .../lombokconfig/ConfigDiscoveryTest.java | 16 +++---- .../plugin/processor/AccessorsTest.java | 4 +- .../plugin/processor/BuilderSingularTest.java | 34 +++++++------- .../processor/BuilderToBuilderTest.java | 8 ++-- .../plugin/processor/ConstructorTest.java | 12 ++--- .../intellij/plugin/processor/DataTest.java | 20 ++++---- .../plugin/processor/DelegateTest.java | 18 ++++---- .../processor/FieldNameConstantsTest.java | 4 +- .../intellij/plugin/processor/GetterTest.java | 46 +++++++++---------- .../intellij/plugin/processor/LoggerTest.java | 24 +++++----- .../intellij/plugin/processor/SetterTest.java | 18 ++++---- .../plugin/processor/UtilityClassTest.java | 2 +- .../intellij/plugin/processor/ValTest.java | 22 ++++----- .../intellij/plugin/processor/ValueTest.java | 22 ++++----- .../intellij/plugin/processor/VarTest.java | 18 ++++---- .../intellij/plugin/processor/WitherTest.java | 22 ++++----- .../plugin/thirdparty/LombokHandlerUtil.java | 2 +- .../thirdparty/LombokUtilsAllGetterTest.java | 20 ++++---- .../thirdparty/LombokUtilsAllSetterTest.java | 18 ++++---- .../thirdparty/LombokUtilsAllWitherTest.java | 16 +++---- .../thirdparty/LombokUtilsGetterTest.java | 22 ++++----- .../LombokUtilsPrefixedFluentTest.java | 22 ++++----- .../thirdparty/LombokUtilsSetterTest.java | 22 ++++----- .../thirdparty/LombokUtilsWitherTest.java | 20 ++++---- .../java/de/plushnikov/refactor/Issue512.java | 28 +++++++++++ .../afterEqualsAndHashCodeIncludeExclude.java | 42 +++++++++++++++++ ...beforeEqualsAndHashCodeIncludeExclude.java | 20 ++++++++ .../AutoCloseableCleanup.java | 24 ++++++++++ 66 files changed, 456 insertions(+), 321 deletions(-) create mode 100644 src/main/java/de/plushnikov/intellij/plugin/extension/LombokCleanUpImplicitResourceCloser.java create mode 100644 src/test/java/de/plushnikov/intellij/plugin/inspection/AutoCloseableResourceInspectionTest.java create mode 100644 test-manual/src/main/java/de/plushnikov/refactor/Issue512.java create mode 100644 testData/action/delombok/equalsandhashcode/afterEqualsAndHashCodeIncludeExclude.java create mode 100644 testData/action/delombok/equalsandhashcode/beforeEqualsAndHashCodeIncludeExclude.java create mode 100644 testData/inspection/autoCloseableResource/AutoCloseableCleanup.java diff --git a/.travis.yml b/.travis.yml index 4887d4ba7..bdcb0cee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,10 +17,6 @@ env: - IDEA_VERSION=IC-2018.2 - IDEA_VERSION=IC-2018.1.6 - IDEA_VERSION=IC-2018.1 - - IDEA_VERSION=IC-2017.3.4 - - IDEA_VERSION=IC-2017.3 - - IDEA_VERSION=IC-2017.2.6 - - IDEA_VERSION=IC-2017.2 before_install: - chmod +x gradlew diff --git a/gradle.properties b/gradle.properties index e2dad81a9..905e6d019 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,6 @@ # https://www.jetbrains.com/intellij-repository/releases # https://www.jetbrains.com/intellij-repository/snapshots # -#ideaVersion=2017.2 -#ideaVersion=2017.2.7 -#ideaVersion=2017.3 -#ideaVersion=2017.3.5 #ideaVersion=2018.1 #ideaVersion=2018.1.6 #ideaVersion=2018.2 diff --git a/parts/pluginChanges.html b/parts/pluginChanges.html index 25f556243..89c08ae65 100644 --- a/parts/pluginChanges.html +++ b/parts/pluginChanges.html @@ -5,7 +5,9 @@
  • Fixed #504: Added Support for Delombok of @EqualsAndHashcode and @ToString Exclude/Include annotations
  • Fixed #507: @Value and @FieldDefaults should skip static fields
  • Fixed #472: Lombok should not interfer with java 10 'var'
  • +
  • Fixed #530: Remove explicit type argument leads to error
  • Fixed #531: Inspection for Lombok annotations incorrectly highlights 'var'
  • +
  • Better Support for @Cleanup: 'AutoCloseableResource'-Inspection can handle @Cleanup correctly in IntelliJ
  • 0.21 diff --git a/src/main/java/de/plushnikov/intellij/plugin/action/BaseRefactorAction.java b/src/main/java/de/plushnikov/intellij/plugin/action/BaseRefactorAction.java index aa800bca2..1045c0dd4 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/action/BaseRefactorAction.java +++ b/src/main/java/de/plushnikov/intellij/plugin/action/BaseRefactorAction.java @@ -36,9 +36,7 @@ private boolean isActionAvailable(AnActionEvent e) { final VirtualFile file = getVirtualFiles(e); if (getEventProject(e) != null && file != null) { final FileType fileType = file.getFileType(); - if (StdFileTypes.JAVA.equals(fileType)) { - return true; - } + return StdFileTypes.JAVA.equals(fileType); } return false; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/action/inline/LombokInlineMethodHandler.java b/src/main/java/de/plushnikov/intellij/plugin/action/inline/LombokInlineMethodHandler.java index 2791b5c3a..f1411c901 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/action/inline/LombokInlineMethodHandler.java +++ b/src/main/java/de/plushnikov/intellij/plugin/action/inline/LombokInlineMethodHandler.java @@ -198,11 +198,9 @@ private static boolean checkCalls(PsiElement scope, PsiMethod method) { private boolean isThisReference(PsiReference reference) { if (reference != null) { final PsiElement referenceElement = reference.getElement(); - if (referenceElement instanceof PsiJavaCodeReferenceElement && + return referenceElement instanceof PsiJavaCodeReferenceElement && referenceElement.getParent() instanceof PsiMethodCallExpression && - "this".equals(((PsiJavaCodeReferenceElement) referenceElement).getReferenceName())) { - return true; - } + "this".equals(((PsiJavaCodeReferenceElement) referenceElement).getReferenceName()); } return false; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCanBeFinalHandler.java b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCanBeFinalHandler.java index ba71592cb..11feaa36f 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCanBeFinalHandler.java +++ b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCanBeFinalHandler.java @@ -22,9 +22,7 @@ public boolean canBeFinal(PsiMember member) { } final PsiClass psiClass = PsiTreeUtil.getParentOfType(member, PsiClass.class); - if (null != psiClass && PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, Setter.class, Data.class, Value.class)) { - return false; - } + return null == psiClass || !PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, Setter.class, Data.class, Value.class); } return true; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCleanUpImplicitResourceCloser.java b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCleanUpImplicitResourceCloser.java new file mode 100644 index 000000000..f446f013b --- /dev/null +++ b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokCleanUpImplicitResourceCloser.java @@ -0,0 +1,17 @@ +package de.plushnikov.intellij.plugin.extension; + +import com.intellij.codeInspection.resources.ImplicitResourceCloser; +import com.intellij.psi.PsiVariable; +import de.plushnikov.intellij.plugin.util.PsiAnnotationSearchUtil; +import lombok.Cleanup; +import org.jetbrains.annotations.NotNull; + +/** + * Implement additional way to close AutoCloseables by @lombok.Cleanup for IntelliJ + */ +public class LombokCleanUpImplicitResourceCloser implements ImplicitResourceCloser { + @Override + public boolean isSafelyClosed(@NotNull PsiVariable variable) { + return PsiAnnotationSearchUtil.isAnnotatedWith(variable, Cleanup.class); + } +} diff --git a/src/main/java/de/plushnikov/intellij/plugin/extension/LombokHighlightErrorFilter.java b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokHighlightErrorFilter.java index 5719247c5..991cd481a 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/extension/LombokHighlightErrorFilter.java +++ b/src/main/java/de/plushnikov/intellij/plugin/extension/LombokHighlightErrorFilter.java @@ -36,11 +36,9 @@ public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile fi } //Handling onX parameters - if (OnXAnnotationHandler.isOnXParameterAnnotation(highlightInfo, file) - || OnXAnnotationHandler.isOnXParameterValue(highlightInfo, file) - || LOMBOK_ANYANNOTATIONREQUIRED.matcher(description).matches()) { - return false; - } + return !OnXAnnotationHandler.isOnXParameterAnnotation(highlightInfo, file) + && !OnXAnnotationHandler.isOnXParameterValue(highlightInfo, file) + && !LOMBOK_ANYANNOTATIONREQUIRED.matcher(description).matches(); } } return true; diff --git a/src/main/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigIndexKey.java b/src/main/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigIndexKey.java index 35a2e0029..b37b78c33 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigIndexKey.java +++ b/src/main/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigIndexKey.java @@ -31,11 +31,7 @@ public boolean equals(Object o) { if (configKey != null ? !configKey.equalsIgnoreCase(that.configKey) : that.configKey != null) { return false; } - if (directoryName != null ? !directoryName.equals(that.directoryName) : that.directoryName != null) { - return false; - } - - return true; + return directoryName != null ? directoryName.equals(that.directoryName) : that.directoryName == null; } @Override diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/LombokPsiElementUsage.java b/src/main/java/de/plushnikov/intellij/plugin/processor/LombokPsiElementUsage.java index bcb0810ea..de63bc572 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/LombokPsiElementUsage.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/LombokPsiElementUsage.java @@ -1,5 +1,5 @@ package de.plushnikov.intellij.plugin.processor; public enum LombokPsiElementUsage { - NONE, USAGE, READ, WRITE, READ_WRITE; + NONE, USAGE, READ, WRITE, READ_WRITE } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/AbstractClassProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/AbstractClassProcessor.java index 9fd909bd2..7a376e024 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/AbstractClassProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/AbstractClassProcessor.java @@ -76,9 +76,9 @@ public Collection collectProcessedAnnotations(@NotNull PsiClass p return result; } - protected void addFieldsAnnotation(Collection result, @NotNull PsiClass psiClass, Class... annotations) { + protected void addFieldsAnnotation(Collection result, @NotNull PsiClass psiClass, String... annotationFQNs) { for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { - PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, annotations); + PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, annotationFQNs); if (null != psiAnnotation) { result.add(psiAnnotation); } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/EqualsAndHashCodeProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/EqualsAndHashCodeProcessor.java index d8bebf60f..720b5bdc8 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/EqualsAndHashCodeProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/EqualsAndHashCodeProcessor.java @@ -40,6 +40,8 @@ public class EqualsAndHashCodeProcessor extends AbstractClassProcessor { private static final String CAN_EQUAL_METHOD_NAME = "canEqual"; private static final String INCLUDE_ANNOTATION_METHOD = "replaces"; + private static final String EQUALSANDHASHCODE_INCLUDE = EqualsAndHashCode.Include.class.getName().replace("$", "."); + private static final String EQUALSANDHASHCODE_EXCLUDE = EqualsAndHashCode.Exclude.class.getName().replace("$", "."); private final EqualsAndHashCodeToStringHandler handler; @@ -342,7 +344,7 @@ private boolean readCallSuperAnnotationOrConfigProperty(@NotNull PsiAnnotation p @Override public Collection collectProcessedAnnotations(@NotNull PsiClass psiClass) { final Collection result = super.collectProcessedAnnotations(psiClass); - addFieldsAnnotation(result, psiClass, EqualsAndHashCode.Include.class, EqualsAndHashCode.Exclude.class); + addFieldsAnnotation(result, psiClass, EQUALSANDHASHCODE_INCLUDE, EQUALSANDHASHCODE_EXCLUDE); return result; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/ToStringProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/ToStringProcessor.java index b1dcdf2f8..cd37c96f2 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/ToStringProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/ToStringProcessor.java @@ -33,6 +33,8 @@ public class ToStringProcessor extends AbstractClassProcessor { private static final String INCLUDE_ANNOTATION_METHOD = "name"; private static final String INCLUDE_ANNOTATION_RANK = "rank"; private static final String INCLUDE_ANNOTATION_SKIP_NULL = "skipNull"; + private static final String TOSTRING_INCLUDE = ToString.Include.class.getName().replace("$", "."); + private static final String TOSTRING_EXCLUDE = ToString.Exclude.class.getName().replace("$", "."); private final EqualsAndHashCodeToStringHandler handler; @@ -180,7 +182,7 @@ private String createParamString(@NotNull PsiClass psiClass, @NotNull Collection @Override public Collection collectProcessedAnnotations(@NotNull PsiClass psiClass) { final Collection result = super.collectProcessedAnnotations(psiClass); - addFieldsAnnotation(result, psiClass, ToString.Include.class, ToString.Exclude.class); + addFieldsAnnotation(result, psiClass, TOSTRING_INCLUDE, TOSTRING_EXCLUDE); return result; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/builder/BuilderProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/builder/BuilderProcessor.java index f3cec6375..e4ff4ae1b 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/builder/BuilderProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/builder/BuilderProcessor.java @@ -32,6 +32,9 @@ */ public class BuilderProcessor extends AbstractClassProcessor { + private static final String SINGULAR_CLASS = Singular.class.getName(); + private static final String BUILDER_DEFAULT_CLASS = Builder.Default.class.getName().replace("$", "."); + private final BuilderHandler builderHandler; private final AllArgsConstructorProcessor allArgsConstructorProcessor; @@ -51,7 +54,7 @@ public boolean isEnabled(@NotNull PropertiesComponent propertiesComponent) { @Override public Collection collectProcessedAnnotations(@NotNull PsiClass psiClass) { final Collection result = super.collectProcessedAnnotations(psiClass); - addFieldsAnnotation(result, psiClass, Singular.class, Builder.Default.class); + addFieldsAnnotation(result, psiClass, SINGULAR_CLASS, BUILDER_DEFAULT_CLASS); return result; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/NoArgsConstructorProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/NoArgsConstructorProcessor.java index 2ded4a7ff..a8efb5032 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/NoArgsConstructorProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/NoArgsConstructorProcessor.java @@ -33,7 +33,7 @@ protected boolean validate(@NotNull PsiAnnotation psiAnnotation, @NotNull PsiCla result = super.validate(psiAnnotation, psiClass, builder); final String staticConstructorName = getStaticConstructorName(psiAnnotation); - result &= validateIsConstructorNotDefined(psiClass, staticConstructorName, Collections.emptyList(), builder); + result &= validateIsConstructorNotDefined(psiClass, staticConstructorName, Collections.emptyList(), builder); return result; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/field/AccessorsInfo.java b/src/main/java/de/plushnikov/intellij/plugin/processor/field/AccessorsInfo.java index b3b4e8330..96625633b 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/field/AccessorsInfo.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/field/AccessorsInfo.java @@ -74,7 +74,7 @@ public static AccessorsInfo build(@Nullable PsiClass psiClass) { containingClass = containingClass.getContainingClass(); } - return buildAccessorsInfo(psiClass, null, null, Collections.emptySet()); + return buildAccessorsInfo(psiClass, null, null, Collections.emptySet()); } @NotNull diff --git a/src/main/java/de/plushnikov/intellij/plugin/provider/LombokProcessorProvider.java b/src/main/java/de/plushnikov/intellij/plugin/provider/LombokProcessorProvider.java index 4e4cbe1fb..8b5db755d 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/provider/LombokProcessorProvider.java +++ b/src/main/java/de/plushnikov/intellij/plugin/provider/LombokProcessorProvider.java @@ -80,14 +80,14 @@ private void putProcessor(final Map> map, final K key, f @NotNull public Collection getLombokProcessors(@NotNull Class supportedClass) { final Collection result = lombokTypeProcessors.get(supportedClass); - return result == null ? Collections.emptySet() : result; + return result == null ? Collections.emptySet() : result; } @NotNull public Collection getProcessors(@NotNull PsiAnnotation psiAnnotation) { final String qualifiedName = psiAnnotation.getQualifiedName(); final Collection result = qualifiedName == null ? null : lombokProcessors.get(qualifiedName); - return result == null ? Collections.emptySet() : result; + return result == null ? Collections.emptySet() : result; } private boolean verifyLombokAnnotationPresent(@NotNull PsiClass psiClass) { diff --git a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightModifierList.java b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightModifierList.java index a2cbadca4..800b1a0da 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightModifierList.java +++ b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightModifierList.java @@ -113,11 +113,7 @@ public boolean equals(Object o) { LombokLightModifierList that = (LombokLightModifierList) o; - if (!myAnnotations.equals(that.myAnnotations)) { - return false; - } - - return true; + return myAnnotations.equals(that.myAnnotations); } @Override diff --git a/src/main/java/de/plushnikov/intellij/plugin/quickfix/ChangeAnnotationParameterQuickFix.java b/src/main/java/de/plushnikov/intellij/plugin/quickfix/ChangeAnnotationParameterQuickFix.java index 5182591ec..611244d1c 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/quickfix/ChangeAnnotationParameterQuickFix.java +++ b/src/main/java/de/plushnikov/intellij/plugin/quickfix/ChangeAnnotationParameterQuickFix.java @@ -72,7 +72,7 @@ private void applyFixInner(final Project project) { final Editor editor = CodeInsightUtil.positionCursor(project, file, myAnnotation); if (editor != null) { new WriteCommandAction(project, file) { - protected void run(@NotNull Result result) throws Throwable { + protected void run(@NotNull Result result) { final PsiNameValuePair valuePair = selectAnnotationAttribute(); if (null != valuePair) { diff --git a/src/main/java/de/plushnikov/intellij/plugin/quickfix/CreateFieldQuickFix.java b/src/main/java/de/plushnikov/intellij/plugin/quickfix/CreateFieldQuickFix.java index 789b616fc..10608025f 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/quickfix/CreateFieldQuickFix.java +++ b/src/main/java/de/plushnikov/intellij/plugin/quickfix/CreateFieldQuickFix.java @@ -77,7 +77,7 @@ private void applyFixInner(final Project project) { final Editor editor = CodeInsightUtil.positionCursor(project, psiFile, myClass.getLBrace()); if (editor != null) { new WriteCommandAction(project, psiFile) { - protected void run(@NotNull Result result) throws Throwable { + protected void run(@NotNull Result result) { final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(myClass.getProject()); final PsiField psiField = psiElementFactory.createField(myName, myType); diff --git a/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java b/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java index f2c9fe45d..938202ce3 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java +++ b/src/main/java/de/plushnikov/intellij/plugin/settings/ProjectSettingsPage.java @@ -105,7 +105,7 @@ public boolean isModified() { } @Override - public void apply() throws ConfigurationException { + public void apply() { ProjectSettings.setEnabled(myPropertiesComponent, ProjectSettings.LOMBOK_ENABLED_IN_PROJECT, myEnableLombokInProject.isSelected()); ProjectSettings.setEnabled(myPropertiesComponent, ProjectSettings.IS_VAL_ENABLED, myEnableValSupport.isSelected()); diff --git a/src/main/java/de/plushnikov/intellij/plugin/util/PsiAnnotationSearchUtil.java b/src/main/java/de/plushnikov/intellij/plugin/util/PsiAnnotationSearchUtil.java index 631a82697..c0e3f4037 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/util/PsiAnnotationSearchUtil.java +++ b/src/main/java/de/plushnikov/intellij/plugin/util/PsiAnnotationSearchUtil.java @@ -24,6 +24,11 @@ public static PsiAnnotation findAnnotation(@NotNull PsiModifierListOwner psiModi return findAnnotationQuick(psiModifierListOwner.getModifierList(), annotationFQN); } + @Nullable + public static PsiAnnotation findAnnotation(@NotNull PsiModifierListOwner psiModifierListOwner, @NotNull String... annotationFQNs) { + return findAnnotationQuick(psiModifierListOwner.getModifierList(), annotationFQNs); + } + @Nullable public static PsiAnnotation findAnnotation(@NotNull PsiModifierListOwner psiModifierListOwner, @NotNull final Class annotationType) { return findAnnotationQuick(psiModifierListOwner.getModifierList(), annotationType.getName()); diff --git a/src/main/java/de/plushnikov/intellij/plugin/util/PsiElementUtil.java b/src/main/java/de/plushnikov/intellij/plugin/util/PsiElementUtil.java index 160727b05..715c520c8 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/util/PsiElementUtil.java +++ b/src/main/java/de/plushnikov/intellij/plugin/util/PsiElementUtil.java @@ -76,7 +76,7 @@ public static boolean methodMatches( return true; } - public static boolean typesAreEquivalent( + private static boolean typesAreEquivalent( @Nullable PsiType type1, @Nullable PsiType type2) { if (type1 == null) { return type2 == null; diff --git a/src/main/java/de/plushnikov/intellij/plugin/util/ReflectionUtil.java b/src/main/java/de/plushnikov/intellij/plugin/util/ReflectionUtil.java index ef890d2b8..3f0ecb1c1 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/util/ReflectionUtil.java +++ b/src/main/java/de/plushnikov/intellij/plugin/util/ReflectionUtil.java @@ -25,20 +25,4 @@ public static void setFinalFieldPerReflection(Class clazz, T instance, LOG.error(x); } } - - public static R getFieldPerReflection(Class clazz, T instance, Class fieldClass, String fieldName) { - R result = null; - try { - final Field declaredField = clazz.getDeclaredField(fieldName); - declaredField.setAccessible(true); - result = (R) declaredField.get(instance); - } catch (IllegalArgumentException x) { - LOG.error(x); - } catch (IllegalAccessException x) { - LOG.error(x); - } catch (NoSuchFieldException e) { - LOG.error(e); - } - return result; - } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index c2e5e14be..2b0618585 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -59,6 +59,8 @@ + diff --git a/src/main/resources/messages/lombokBundle.properties b/src/main/resources/messages/lombokBundle.properties index 5bb2cd2c5..b201f74ae 100644 --- a/src/main/resources/messages/lombokBundle.properties +++ b/src/main/resources/messages/lombokBundle.properties @@ -26,7 +26,9 @@ Fixes:
    \ - Fixed (#504): Added Support for Delombok of @EqualsAndHashcode. and @ToString.Exclude/Include annotations
    \ - Fixed (#507): @Value and @FieldDefaults should skip static fields
    \ - Fixed (#472): Lombok should not interfer with java 10 'var'
    \ +- Fixed (#530): Remove explicit type argument leads to error
    \ - Fixed (#531): Inspection for Lombok annotations incorrectly highlights 'var'
    \ +- Better Support for @Cleanup: 'AutoCloseableResource'-Inspection can handle @Cleanup correctly in IntelliJ
    \
    \ If you find my plugin helpful, donate me using
    \ PayPal\ diff --git a/src/test/java/de/plushnikov/intellij/plugin/LombokPluginProjectValidatorComponentTest.java b/src/test/java/de/plushnikov/intellij/plugin/LombokPluginProjectValidatorComponentTest.java index 270e675aa..db11c2ff0 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/LombokPluginProjectValidatorComponentTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/LombokPluginProjectValidatorComponentTest.java @@ -15,61 +15,61 @@ public class LombokPluginProjectValidatorComponentTest { private OrderEntry orderEntry; @Before - public void setUp() throws Exception { + public void setUp() { component = new LombokPluginProjectValidatorComponent(null); orderEntry = mock(OrderEntry.class); } @Test - public void parseLombokVersionFromGradle() throws Exception { + public void parseLombokVersionFromGradle() { when(orderEntry.getPresentableName()).thenReturn("Gradle: org.projectlombok:lombok:1.16.8"); assertEquals("1.16.8", component.parseLombokVersion(orderEntry)); } @Test - public void parseLombokVersionFromMaven() throws Exception { + public void parseLombokVersionFromMaven() { when(orderEntry.getPresentableName()).thenReturn("Maven: org.projectlombok:lombok:1.16.6"); assertEquals("1.16.6", component.parseLombokVersion(orderEntry)); } @Test - public void parseLombokVersionFromUnknown() throws Exception { + public void parseLombokVersionFromUnknown() { when(orderEntry.getPresentableName()).thenReturn("lombok"); assertNull(component.parseLombokVersion(orderEntry)); } @Test - public void compareVersionString1_2() throws Exception { + public void compareVersionString1_2() { assertEquals(-1, component.compareVersionString("1", "2")); } @Test - public void compareVersionString__2() throws Exception { + public void compareVersionString__2() { assertEquals(-1, component.compareVersionString("", "2")); } @Test - public void compareVersionString123_121() throws Exception { + public void compareVersionString123_121() { assertEquals(1, component.compareVersionString("1.2.3", "1.2.1")); } @Test - public void compareVersionString1166_1168() throws Exception { + public void compareVersionString1166_1168() { assertEquals(-1, component.compareVersionString("1.16.6", "1.16.8")); } @Test - public void compareVersionString1168_1168() throws Exception { + public void compareVersionString1168_1168() { assertEquals(0, component.compareVersionString("1.16.8", "1.16.8")); } @Test - public void compareVersionString0102_1168() throws Exception { + public void compareVersionString0102_1168() { assertEquals(-1, component.compareVersionString("0.10.2", "1.16.8")); } @Test - public void compareVersionString1169_1168() throws Exception { + public void compareVersionString1169_1168() { assertEquals(1, component.compareVersionString("1.16.9", "1.16.8")); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/SneakyThrowsTest.java b/src/test/java/de/plushnikov/intellij/plugin/SneakyThrowsTest.java index d742693ca..c0e159c1a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/SneakyThrowsTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/SneakyThrowsTest.java @@ -47,7 +47,7 @@ protected Sdk getProjectJDK() { return JavaSdk.getInstance().createJdk("java 1.7", "lib/mockJDK-1.7", false); } - private static PsiMethodCallExpression createCall(@NonNls final String body) throws Exception { + private static PsiMethodCallExpression createCall(@NonNls final String body) { final PsiFile file = createFile("test.java", "class Test { " + body + "void throwsMyException() throws MyException {}" + "void throwsSomeException() throws SomeException {}" + diff --git a/src/test/java/de/plushnikov/intellij/plugin/action/delombok/DelombokEqualsAndHashcodeActionTest.java b/src/test/java/de/plushnikov/intellij/plugin/action/delombok/DelombokEqualsAndHashcodeActionTest.java index 101d67b10..e5ba31a6c 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/action/delombok/DelombokEqualsAndHashcodeActionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/action/delombok/DelombokEqualsAndHashcodeActionTest.java @@ -33,4 +33,8 @@ public void testEqualsAndHashCodeExclude() throws Exception { public void testEqualsAndHashCodeCallSuper() throws Exception { doTest(); } + + public void testEqualsAndHashCodeIncludeExclude() throws Exception { + doTest(); + } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/configsystem/AbstractLombokConfigSystemTestCase.java b/src/test/java/de/plushnikov/intellij/plugin/configsystem/AbstractLombokConfigSystemTestCase.java index e839ef8d0..6a1b5a7a1 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/configsystem/AbstractLombokConfigSystemTestCase.java +++ b/src/test/java/de/plushnikov/intellij/plugin/configsystem/AbstractLombokConfigSystemTestCase.java @@ -17,7 +17,7 @@ public void doTest() throws IOException { doTest(fullFileName, subPath + "/after/" + fileName); } - protected void doTest(final String beforeFileName, final String afterFileName) throws IOException { + protected void doTest(final String beforeFileName, final String afterFileName) { final PsiFile psiDelombokFile = loadToPsiFile(afterFileName); final PsiFile psiLombokFile = loadToPsiFile(beforeFileName); diff --git a/src/test/java/de/plushnikov/intellij/plugin/configsystem/completion/LoggerCompletionTest.java b/src/test/java/de/plushnikov/intellij/plugin/configsystem/completion/LoggerCompletionTest.java index e932d15c2..1971ccc27 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/configsystem/completion/LoggerCompletionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/configsystem/completion/LoggerCompletionTest.java @@ -19,7 +19,7 @@ protected String getBasePath() { return super.getBasePath() + "/configsystem/completion"; } - public void testLoggerCompletionTest() throws IOException { + public void testLoggerCompletionTest() { doTest("LOGGER1"); } @@ -33,4 +33,4 @@ private void doTest(String... expectedSuggestions) { assertNotNull(autoSuggestions); assertThat("Autocomplete doesn't contain right suggestions", autoSuggestions, CoreMatchers.hasItems(expectedSuggestions)); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/extension/LombokElementFinderTest.java b/src/test/java/de/plushnikov/intellij/plugin/extension/LombokElementFinderTest.java index 4c4d3c800..09c01f725 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/extension/LombokElementFinderTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/extension/LombokElementFinderTest.java @@ -42,12 +42,12 @@ public class LombokElementFinderTest { private GlobalSearchScope scope; @Before - public void setUp() throws Exception { + public void setUp() { doReturn(javaFileManager).when(elementFinder).getServiceManager(any(GlobalSearchScope.class)); } @Test - public void findClass() throws Exception { + public void findClass() { final PsiClass psiBaseClass = mock(PsiClass.class); when(javaFileManager.findClass(BASE_CLASS, scope)).thenReturn(psiBaseClass); @@ -73,11 +73,11 @@ public void findClass() throws Exception { } @Test - public void findClassRecursion() throws Exception { + public void findClassRecursion() { // setup recursive calls of elementFinder when(javaFileManager.findClass(BASE_CLASS, scope)).thenAnswer(new Answer() { @Override - public PsiClass answer(InvocationOnMock invocation) throws Throwable { + public PsiClass answer(InvocationOnMock invocation) { final String fqn = (String) invocation.getArguments()[0]; final GlobalSearchScope searchScope = (GlobalSearchScope) invocation.getArguments()[1]; return elementFinder.findClass(fqn + SOME_CLASS_BUILDER, searchScope); diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/AutoCloseableResourceInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/AutoCloseableResourceInspectionTest.java new file mode 100644 index 000000000..232a8e213 --- /dev/null +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/AutoCloseableResourceInspectionTest.java @@ -0,0 +1,22 @@ +package de.plushnikov.intellij.plugin.inspection; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.resources.AutoCloseableResourceInspection; + +public class AutoCloseableResourceInspectionTest extends LombokInspectionTest { + + @Override + protected String getTestDataPath() { + return TEST_DATA_INSPECTION_DIRECTORY + "/autoCloseableResource"; + } + + @Override + protected InspectionProfileEntry getInspection() { + return new AutoCloseableResourceInspection(); + } + + public void testAutoCloseableCleanup() { + doTest(); + } + +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/BuilderInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/BuilderInspectionTest.java index f62b3865d..5f414e8fe 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/BuilderInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/BuilderInspectionTest.java @@ -14,27 +14,27 @@ protected InspectionProfileEntry getInspection() { return new LombokInspection(); } - public void testBuilderInvalidIdentifier() throws Exception { + public void testBuilderInvalidIdentifier() { doTest(); } - public void testBuilderRightType() throws Exception { + public void testBuilderRightType() { doTest(); } - public void testBuilderInvalidUse() throws Exception { + public void testBuilderInvalidUse() { doTest(); } - public void testBuilderObtainVia() throws Exception { + public void testBuilderObtainVia() { doTest(); } - public void testBuilderDefaultsWarnings() throws Exception { + public void testBuilderDefaultsWarnings() { doTest(); } - public void testBuilderDefaultValue() throws Exception { + public void testBuilderDefaultValue() { doTest(); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/DefaultConstructorInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/DefaultConstructorInspectionTest.java index afed7123d..d3d90c026 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/DefaultConstructorInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/DefaultConstructorInspectionTest.java @@ -14,23 +14,23 @@ protected InspectionProfileEntry getInspection() { return new LombokInspection(); } - public void testClassWithData() throws Exception { + public void testClassWithData() { doTest(); } - public void testClassWithJavaConstructor() throws Exception { + public void testClassWithJavaConstructor() { doTest(); } - public void testClassWithLombokConstructor() throws Exception { + public void testClassWithLombokConstructor() { doTest(); } - public void testClassWithLombokDefaultConstructor() throws Exception { + public void testClassWithLombokDefaultConstructor() { doTest(); } - public void testDataWithParentClassWithoutDefaultConstructor() throws Exception { + public void testDataWithParentClassWithoutDefaultConstructor() { doTest(); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/DelegateInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/DelegateInspectionTest.java index 636224256..7b5bbfc0a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/DelegateInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/DelegateInspectionTest.java @@ -14,19 +14,19 @@ protected InspectionProfileEntry getInspection() { return new LombokInspection(); } - public void testConcreteType() throws Exception { + public void testConcreteType() { doTest(); } - public void testOnMethodWithParameter() throws Exception { + public void testOnMethodWithParameter() { doTest(); } - public void testOnStaticFieldOrMethod() throws Exception { + public void testOnStaticFieldOrMethod() { doTest(); } - public void testRecursionType() throws Exception { + public void testRecursionType() { doTest(); } diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldDefaultsOnEnumInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldDefaultsOnEnumInspectionTest.java index 1c69efa58..771b95428 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldDefaultsOnEnumInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldDefaultsOnEnumInspectionTest.java @@ -14,7 +14,7 @@ protected InspectionProfileEntry getInspection() { return null; } - public void testEnumClass() throws Exception { + public void testEnumClass() { doTest(); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldMayBeFinalInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldMayBeFinalInspectionTest.java index 8622b7aac..90c144a10 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldMayBeFinalInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/FieldMayBeFinalInspectionTest.java @@ -15,27 +15,27 @@ protected InspectionProfileEntry getInspection() { return new FieldMayBeFinalInspection(); } - public void testClassNormal() throws Exception { + public void testClassNormal() { doTest(); } - public void testClassWithData() throws Exception { + public void testClassWithData() { doTest(); } - public void testClassWithFieldSetter() throws Exception { + public void testClassWithFieldSetter() { doTest(); } - public void testClassWithGetter() throws Exception { + public void testClassWithGetter() { doTest(); } - public void testClassWithSetter() throws Exception { + public void testClassWithSetter() { doTest(); } - public void testClassWithValue() throws Exception { + public void testClassWithValue() { doTest(); } diff --git a/src/test/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigDiscoveryTest.java b/src/test/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigDiscoveryTest.java index 370b73247..9aac9e89d 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigDiscoveryTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/lombokconfig/ConfigDiscoveryTest.java @@ -43,7 +43,7 @@ public class ConfigDiscoveryTest { private VirtualFile parentVirtualFile; @Before - public void setUp() throws Exception { + public void setUp() { discovery = new ConfigDiscovery(fileBasedIndex); when(project.getUserData(any(Key.class))).thenReturn(globalSearchScope); @@ -58,14 +58,14 @@ public void setUp() throws Exception { } @Test - public void testDefaultStringConfigProperties() throws Exception { + public void testDefaultStringConfigProperties() { final String property = discovery.getStringLombokConfigProperty(ConfigKey.ACCESSORS_CHAIN, psiClass); assertNotNull(property); assertEquals(ConfigKey.ACCESSORS_CHAIN.getConfigDefaultValue(), property); } @Test - public void testStringConfigPropertySameDirectory() throws Exception { + public void testStringConfigPropertySameDirectory() { final ConfigKey configKey = ConfigKey.ACCESSORS_CHAIN; when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d/e/f", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList(EXPECTED_VALUE)); @@ -76,7 +76,7 @@ public void testStringConfigPropertySameDirectory() throws Exception { } @Test - public void testStringConfigPropertySubDirectory() throws Exception { + public void testStringConfigPropertySubDirectory() { final ConfigKey configKey = ConfigKey.ACCESSORS_CHAIN; when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d/e", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList(EXPECTED_VALUE)); @@ -87,7 +87,7 @@ public void testStringConfigPropertySubDirectory() throws Exception { } @Test - public void testStringConfigPropertySubDirectoryStopBubling() throws Exception { + public void testStringConfigPropertySubDirectoryStopBubling() { final ConfigKey configKey = ConfigKey.ACCESSORS_CHAIN; when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d/e", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList(EXPECTED_VALUE)); @@ -100,14 +100,14 @@ public void testStringConfigPropertySubDirectoryStopBubling() throws Exception { } @Test - public void testMultipleStringConfigProperty() throws Exception { + public void testMultipleStringConfigProperty() { final ConfigKey configKey = ConfigKey.ACCESSORS_PREFIX; when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList("+a;+b")); when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList("-a;+cc")); when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d/e", configKey.getConfigKey()), globalSearchScope)) - .thenReturn(Collections.emptyList()); + .thenReturn(Collections.emptyList()); when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c/d/e/f", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList("+_d;")); @@ -121,7 +121,7 @@ public void testMultipleStringConfigProperty() throws Exception { } @Test - public void testMultipleStringConfigPropertyWithStopBubbling() throws Exception { + public void testMultipleStringConfigPropertyWithStopBubbling() { final ConfigKey configKey = ConfigKey.ACCESSORS_PREFIX; when(fileBasedIndex.getValues(LombokConfigIndex.NAME, new ConfigIndexKey("/a/b/c", configKey.getConfigKey()), globalSearchScope)) .thenReturn(Collections.singletonList("+a;+b")); diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/AccessorsTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/AccessorsTest.java index 6a020a443..55faf98d6 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/AccessorsTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/AccessorsTest.java @@ -7,7 +7,7 @@ */ public class AccessorsTest extends AbstractLombokParsingTestCase { - public void testAccessors$Accessors() throws Exception { + public void testAccessors$Accessors() { doTest(true); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderSingularTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderSingularTest.java index deebae6f5..7dc619661 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderSingularTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderSingularTest.java @@ -16,72 +16,72 @@ public void setUp() throws Exception { myFixture.addClass("package java.util;\n public interface NavigableMap extends java.util.SortedMap {}"); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaBiMap() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaBiMap() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaCollection() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaCollection() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaList() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaList() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaMap() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaMap() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaSet() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaSet() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaSortedMap() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaSortedMap() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaSortedSet() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaSortedSet() { doTest(true); } - public void testBuilder$Singular$Generic$Guava$SingularGuavaTable() throws IOException { + public void testBuilder$Singular$Generic$Guava$SingularGuavaTable() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularCollection() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularCollection() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularIterable() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularIterable() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularList() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularList() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularNavigableSet() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularNavigableSet() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularSet() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularSet() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Collection$SingularSortedSet() throws IOException { + public void testBuilder$Singular$Generic$Util$Collection$SingularSortedSet() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Map$SingularMap() throws IOException { + public void testBuilder$Singular$Generic$Util$Map$SingularMap() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Map$SingularNavigableMap() throws IOException { + public void testBuilder$Singular$Generic$Util$Map$SingularNavigableMap() { doTest(true); } - public void testBuilder$Singular$Generic$Util$Map$SingularSortedMap() throws IOException { + public void testBuilder$Singular$Generic$Util$Map$SingularSortedMap() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderToBuilderTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderToBuilderTest.java index 2c8570b6a..a3590c8cd 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderToBuilderTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/BuilderToBuilderTest.java @@ -15,19 +15,19 @@ public void setUp() throws Exception { myFixture.addClass("package java.util;\n public interface NavigableMap extends java.util.SortedMap {}"); } - public void testBuilder$BuilderWithToBuilder() throws IOException { + public void testBuilder$BuilderWithToBuilder() { doTest(true); } - public void testBuilder$BuilderWithToBuilderOnClass() throws IOException { + public void testBuilder$BuilderWithToBuilderOnClass() { doTest(true); } - public void testBuilder$BuilderWithToBuilderOnConstructor() throws IOException { + public void testBuilder$BuilderWithToBuilderOnConstructor() { doTest(true); } - public void testBuilder$BuilderWithToBuilderOnMethod() throws IOException { + public void testBuilder$BuilderWithToBuilderOnMethod() { doTest(true); } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/ConstructorTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/ConstructorTest.java index 67fcaac22..77b86e1a9 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/ConstructorTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/ConstructorTest.java @@ -9,27 +9,27 @@ */ public class ConstructorTest extends AbstractLombokParsingTestCase { - public void testConstructors$Constructors() throws IOException { + public void testConstructors$Constructors() { doTest(true); } - public void testConstructors$ConflictingStaticConstructorNames() throws IOException { + public void testConstructors$ConflictingStaticConstructorNames() { doTest(true); } - public void testConstructors$NoArgsConstructorForced() throws IOException { + public void testConstructors$NoArgsConstructorForced() { doTest(true); } - public void testConstructors$ConstructorEnum() throws IOException { + public void testConstructors$ConstructorEnum() { doTest(true); } - public void testConstructors$RequiredArgsConstructorWithGeneric136() throws IOException { + public void testConstructors$RequiredArgsConstructorWithGeneric136() { doTest(true); } - public void testConstructors$RequiredArgsConstructorWithGeneric157() throws IOException { + public void testConstructors$RequiredArgsConstructorWithGeneric157() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/DataTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/DataTest.java index 62dd1f311..66dd1293e 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/DataTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/DataTest.java @@ -13,40 +13,40 @@ protected boolean shouldCompareCodeBlocks() { return false; } - public void testData$DataExtended() throws IOException { + public void testData$DataExtended() { doTest(true); } - public void testData$DataIgnore() throws IOException { + public void testData$DataIgnore() { doTest(true); } - public void testData$DataOnEnum() throws IOException { + public void testData$DataOnEnum() { doTest(true); } - public void testData$DataOnLocalClass() throws IOException { + public void testData$DataOnLocalClass() { doTest(true); } - public void testData$DataPlain() throws IOException { + public void testData$DataPlain() { doTest(true); } - public void testData$DataWithGetter() throws IOException { + public void testData$DataWithGetter() { doTest(true); } - public void testData$DataWithGetterNone() throws IOException { + public void testData$DataWithGetterNone() { doTest(true); } - public void testData$DataStaticConstructor() throws IOException { + public void testData$DataStaticConstructor() { // Test for issue #9 doTest(true); } - public void testData$DataWithGeneric176() throws IOException { + public void testData$DataWithGeneric176() { doTest(true); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/DelegateTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/DelegateTest.java index 55da36f3e..4db889602 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/DelegateTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/DelegateTest.java @@ -7,36 +7,36 @@ */ public class DelegateTest extends AbstractLombokParsingTestCase { - public void ignore_testDelegate$DelegateOnGetter() throws Exception { + public void ignore_testDelegate$DelegateOnGetter() { //TODO known problem, try to fix later doTest(true); } - public void testDelegate$DelegateOnGetterNone() throws Exception { + public void testDelegate$DelegateOnGetterNone() { doTest(true); } - public void testDelegate$DelegateOnMethods() throws Exception { + public void testDelegate$DelegateOnMethods() { doTest(true); } - public void testDelegate$DelegateRecursion() throws Exception { + public void testDelegate$DelegateRecursion() { doTest(true); } - public void testDelegate$DelegateTypesAndExcludes() throws Exception { + public void testDelegate$DelegateTypesAndExcludes() { doTest(true); } - public void testDelegate$DelegateWithDeprecated() throws Exception { + public void testDelegate$DelegateWithDeprecated() { doTest(true); } - public void testDelegate$DelegateWithException() throws Exception { + public void testDelegate$DelegateWithException() { doTest(true); } - public void testDelegate$DelegateGenericInterfaceIssue88() throws Exception { + public void testDelegate$DelegateGenericInterfaceIssue88() { doTest(true); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/FieldNameConstantsTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/FieldNameConstantsTest.java index 1477486f0..acfe5e46a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/FieldNameConstantsTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/FieldNameConstantsTest.java @@ -9,11 +9,11 @@ */ public class FieldNameConstantsTest extends AbstractLombokParsingTestCase { - public void testFieldnameconstants$FieldNameConstantsBasic() throws IOException { + public void testFieldnameconstants$FieldNameConstantsBasic() { doTest(true); } - public void testFieldnameconstants$FieldNameConstantsWeird() throws IOException { + public void testFieldnameconstants$FieldNameConstantsWeird() { doTest(true); } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/GetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/GetterTest.java index 2def81ba7..a3f240b7f 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/GetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/GetterTest.java @@ -13,95 +13,95 @@ protected boolean shouldCompareCodeBlocks() { return false; } - public void testGetter$GetterAccessLevel() throws IOException { + public void testGetter$GetterAccessLevel() { doTest(true); } - public void testGetter$GetterAlreadyExists() throws IOException { + public void testGetter$GetterAlreadyExists() { doTest(true); } - public void testGetter$GetterBoolean() throws IOException { + public void testGetter$GetterBoolean() { doTest(true); } - public void testGetter$GetterDeprecated() throws IOException { + public void testGetter$GetterDeprecated() { doTest(true); } - public void testGetter$GetterEnum() throws IOException { + public void testGetter$GetterEnum() { doTest(true); } - public void ignore_testGetter$GetterLazy() throws IOException { + public void ignore_testGetter$GetterLazy() { //TODO known problem, try to fix later doTest(true); } - public void ignore_testGetter$GetterLazyBoolean() throws IOException { + public void ignore_testGetter$GetterLazyBoolean() { //TODO known problem, try to fix later doTest(true); } - public void ignore_testGetter$GetterLazyEahcToString() throws IOException { + public void ignore_testGetter$GetterLazyEahcToString() { //TODO known problem, try to fix later doTest(true); } - public void testGetter$GetterLazyInvalid() throws IOException { + public void testGetter$GetterLazyInvalid() { doTest(true); } - public void ignore_testGetter$GetterLazyNative() throws IOException { + public void ignore_testGetter$GetterLazyNative() { //TODO known problem, try to fix later doTest(true); } - public void testGetter$GetterNone() throws IOException { + public void testGetter$GetterNone() { doTest(true); } - public void testGetter$GetterOnClass() throws IOException { + public void testGetter$GetterOnClass() { doTest(true); } - public void testGetter$GetterOnMethod() throws IOException { + public void testGetter$GetterOnMethod() { doTest(true); } - public void testGetter$GetterOnMethodErrors() throws IOException { + public void testGetter$GetterOnMethodErrors() { doTest(true); } - public void testGetter$GetterOnMethodErrors2() throws IOException { + public void testGetter$GetterOnMethodErrors2() { doTest(true); } - public void testGetter$GetterOnStatic() throws IOException { + public void testGetter$GetterOnStatic() { doTest(true); } - public void testGetter$GetterPlain() throws IOException { + public void testGetter$GetterPlain() { doTest(true); } - public void testGetter$GetterWithDollar() throws IOException { + public void testGetter$GetterWithDollar() { doTest(true); } - public void testGetter$MultiFieldGetter() throws IOException { + public void testGetter$MultiFieldGetter() { doTest(true); } - public void testGetter$TrickyTypeResolution() throws IOException { + public void testGetter$TrickyTypeResolution() { doTest(true); } - public void testGetter$ClassNamedAfterGetter() throws IOException { + public void testGetter$ClassNamedAfterGetter() { doTest(true); } - public void testGetter$CommentsInterspersed() throws IOException { + public void testGetter$CommentsInterspersed() { doTest(true); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/LoggerTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/LoggerTest.java index 23206f9bc..5a4e62550 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/LoggerTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/LoggerTest.java @@ -9,51 +9,51 @@ */ public class LoggerTest extends AbstractLombokParsingTestCase { - public void testLogger$LoggerCommons() throws IOException { + public void testLogger$LoggerCommons() { doTest(true); } - public void testLogger$LoggerJul() throws IOException { + public void testLogger$LoggerJul() { doTest(true); } - public void testLogger$LoggerLog4j() throws IOException { + public void testLogger$LoggerLog4j() { doTest(true); } - public void testLogger$LoggerLog4j2() throws IOException { + public void testLogger$LoggerLog4j2() { doTest(true); } - public void testLogger$LoggerSlf4j() throws IOException { + public void testLogger$LoggerSlf4j() { doTest(true); } - public void testLogger$LoggerSlf4jAlreadyExists() throws IOException { + public void testLogger$LoggerSlf4jAlreadyExists() { doTest(true); } - public void testLogger$LoggerSlf4jOnNonType() throws IOException { + public void testLogger$LoggerSlf4jOnNonType() { doTest(true); } - public void testLogger$LoggerSlf4jTypes() throws IOException { + public void testLogger$LoggerSlf4jTypes() { doTest(true); } - public void testLogger$LoggerSlf4jWithPackage() throws IOException { + public void testLogger$LoggerSlf4jWithPackage() { doTest(true); } - public void testLogger$LoggerXSlf4j() throws IOException { + public void testLogger$LoggerXSlf4j() { doTest(true); } - public void testLogger$LoggerJBossLog() throws IOException { + public void testLogger$LoggerJBossLog() { doTest(true); } - public void testLogger$LoggerFlogger() throws IOException { + public void testLogger$LoggerFlogger() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/SetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/SetterTest.java index c8cbd4b1e..2a86ddb1f 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/SetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/SetterTest.java @@ -9,35 +9,35 @@ */ public class SetterTest extends AbstractLombokParsingTestCase { - public void testSetter$SetterAccessLevel() throws IOException { + public void testSetter$SetterAccessLevel() { doTest(true); } - public void testSetter$SetterAlreadyExists() throws IOException { + public void testSetter$SetterAlreadyExists() { doTest(true); } - public void testSetter$SetterDeprecated() throws IOException { + public void testSetter$SetterDeprecated() { doTest(true); } - public void testSetter$SetterOnClass() throws IOException { + public void testSetter$SetterOnClass() { doTest(true); } - public void testSetter$SetterOnMethodOnParam() throws IOException { + public void testSetter$SetterOnMethodOnParam() { doTest(true); } - public void testSetter$SetterOnStatic() throws IOException { + public void testSetter$SetterOnStatic() { doTest(true); } - public void testSetter$SetterPlain() throws IOException { + public void testSetter$SetterPlain() { doTest(true); } - public void testSetter$SetterWithDollar() throws IOException { + public void testSetter$SetterWithDollar() { doTest(true); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/UtilityClassTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/UtilityClassTest.java index 9159919fb..309521e38 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/UtilityClassTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/UtilityClassTest.java @@ -6,7 +6,7 @@ public class UtilityClassTest extends AbstractLombokParsingTestCase { - public void testUtilityclass$UtilityClassPlain() throws IOException { + public void testUtilityclass$UtilityClassPlain() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/ValTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/ValTest.java index 444cdaa9e..9fa95d1b8 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/ValTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/ValTest.java @@ -9,27 +9,27 @@ public class ValTest extends AbstractLombokLightCodeInsightTestCase { - public void testSimpleInt() throws Exception { + public void testSimpleInt() { configureClass("100"); verifyLocalVariableType("int"); } - public void testSimpleString() throws Exception { + public void testSimpleString() { configureClass("\"\""); verifyLocalVariableType("java.lang.String"); } - public void testNewString() throws Exception { + public void testNewString() { configureClass("new java.lang.String(\"Hello World\")"); verifyLocalVariableType("java.lang.String"); } - public void testDoubleExpression() throws Exception { + public void testDoubleExpression() { configureClass("10.0 + 20.0"); verifyLocalVariableType("double"); } - public void testIntParameter() throws Exception { + public void testIntParameter() { myFixture.configureByText("a.java", "import lombok.val;\n" + "abstract class Test {\n" + " private void test() {\n" + @@ -48,22 +48,22 @@ public void testIntParameter() throws Exception { assertEquals(type.getCanonicalText(), true, type.equalsToText("int")); } - public void testBooleanExpression() throws Exception { + public void testBooleanExpression() { configureClass("10 == 10"); verifyLocalVariableType("boolean"); } - public void testGenericCollection() throws Exception { + public void testGenericCollection() { configureClass("java.util.Arrays.asList(\"a\",\"b\")"); verifyLocalVariableType("java.util.List"); } - public void testGenericNewCollection() throws Exception { + public void testGenericNewCollection() { configureClass("new java.util.ArrayList()"); verifyLocalVariableType("java.util.ArrayList"); } - public void testGenericMethod168() throws Exception { + public void testGenericMethod168() { configureClass("forClass(Integer.class)", "public static java.util.List forClass(Class clazz) {\n" + " return new java.util.ArrayList();\n" + @@ -71,7 +71,7 @@ public void testGenericMethod168() throws Exception { verifyLocalVariableType("java.util.List"); } - public void testConditionalExpressionThen260() throws Exception { + public void testConditionalExpressionThen260() { configureClass("TYPE_ID_MAPPINGS.containsKey(\"key\") ? newHashSet(TYPE_ID_MAPPINGS.get(\"key\")) : MULTIPLE_SEARCH_TYPES", "private static java.util.Map TYPE_ID_MAPPINGS = new java.util.HashMap<>();\n" + " private static java.util.Set MULTIPLE_SEARCH_TYPES = new java.util.HashSet<>();\n" + @@ -81,7 +81,7 @@ public void testConditionalExpressionThen260() throws Exception { verifyLocalVariableType("java.util.Collection"); } - public void testConditionalExpressionElse260() throws Exception { + public void testConditionalExpressionElse260() { configureClass("TYPE_ID_MAPPINGS.containsKey(\"key\") ? newHashSet(TYPE_ID_MAPPINGS.get(\"key\")) : MULTIPLE_SEARCH_TYPES", "private static java.util.Map TYPE_ID_MAPPINGS = new java.util.HashMap<>();\n" + " private static java.util.Set MULTIPLE_SEARCH_TYPES = new java.util.HashSet<>();\n" + diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/ValueTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/ValueTest.java index 4e3f12c1c..5f8338e19 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/ValueTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/ValueTest.java @@ -10,47 +10,47 @@ protected boolean shouldCompareCodeBlocks() { return false; } - public void testValue$ValueIssue78() throws IOException { + public void testValue$ValueIssue78() { doTest(true); } - public void testValue$ValueIssue94() throws IOException { + public void testValue$ValueIssue94() { doTest(true); } - public void testValue$ValuePlain() throws IOException { + public void testValue$ValuePlain() { doTest(true); } - public void testValue$ValueExperimental() throws IOException { + public void testValue$ValueExperimental() { doTest(true); } - public void testValue$ValueExperimentalStarImport() throws IOException { + public void testValue$ValueExperimentalStarImport() { doTest(true); } - public void testValue$ValueBuilder() throws IOException { + public void testValue$ValueBuilder() { doTest(true); } - public void testValue$ValueAndBuilder93() throws IOException { + public void testValue$ValueAndBuilder93() { doTest(true); } - public void testValue$ValueAndWither() throws IOException { + public void testValue$ValueAndWither() { doTest(true); } - public void testValue$ValueAndWitherAndRequiredConstructor() throws IOException { + public void testValue$ValueAndWitherAndRequiredConstructor() { doTest(true); } - public void testValue$ValueWithGeneric176() throws IOException { + public void testValue$ValueWithGeneric176() { doTest(true); } - public void testValue$ValueWithPackagePrivate() throws IOException { + public void testValue$ValueWithPackagePrivate() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/VarTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/VarTest.java index 808459d96..6a1507c8a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/VarTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/VarTest.java @@ -4,27 +4,27 @@ import de.plushnikov.intellij.plugin.AbstractLombokLightCodeInsightTestCase; public class VarTest extends AbstractLombokLightCodeInsightTestCase { - public void testSimpleInt() throws Exception { + public void testSimpleInt() { configureClass("100"); verifyLocalVariableType("int"); } - public void testSimpleString() throws Exception { + public void testSimpleString() { configureClass("\"\""); verifyLocalVariableType("java.lang.String"); } - public void testNewString() throws Exception { + public void testNewString() { configureClass("new java.lang.String(\"Hello World\")"); verifyLocalVariableType("java.lang.String"); } - public void testDoubleExpression() throws Exception { + public void testDoubleExpression() { configureClass("10.0 + 20.0"); verifyLocalVariableType("double"); } - public void testIntParameter() throws Exception { + public void testIntParameter() { myFixture.configureByText("a.java", "import lombok.experimental.var;\n" + "abstract class Test {\n" + " private void test() {\n" + @@ -42,22 +42,22 @@ public void testIntParameter() throws Exception { assertEquals(type.getCanonicalText(), true, type.equalsToText("int")); } - public void testBooleanExpression() throws Exception { + public void testBooleanExpression() { configureClass("10 == 10"); verifyLocalVariableType("boolean"); } - public void testGenericCollection() throws Exception { + public void testGenericCollection() { configureClass("java.util.Arrays.asList(\"a\",\"b\")"); verifyLocalVariableType("java.util.List"); } - public void testGenericNewCollection() throws Exception { + public void testGenericNewCollection() { configureClass("new java.util.ArrayList()"); verifyLocalVariableType("java.util.ArrayList"); } - public void testGenericMethod168() throws Exception { + public void testGenericMethod168() { configureClass("forClass(Integer.class)", "public static java.util.List forClass(Class clazz) {\n" + " return new java.util.ArrayList();\n" + diff --git a/src/test/java/de/plushnikov/intellij/plugin/processor/WitherTest.java b/src/test/java/de/plushnikov/intellij/plugin/processor/WitherTest.java index 698afeb22..84ca446b9 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/processor/WitherTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/processor/WitherTest.java @@ -10,47 +10,47 @@ protected boolean shouldCompareCodeBlocks() { return false; } - public void testWither$WitherAccessLevel() throws IOException { + public void testWither$WitherAccessLevel() { doTest(true); } - public void testWither$WitherAlreadyExists() throws IOException { + public void testWither$WitherAlreadyExists() { doTest(true); } - public void testWither$WitherAndAccessors() throws IOException { + public void testWither$WitherAndAccessors() { doTest(true); } - public void testWither$WitherAndAllArgsConstructor() throws IOException { + public void testWither$WitherAndAllArgsConstructor() { doTest(true); } - public void testWither$WitherDeprecated() throws IOException { + public void testWither$WitherDeprecated() { doTest(true); } - public void testWither$WitherOnClass() throws IOException { + public void testWither$WitherOnClass() { doTest(true); } - public void testWither$WitherOnStatic() throws IOException { + public void testWither$WitherOnStatic() { doTest(true); } - public void testWither$WitherPlain() throws IOException { + public void testWither$WitherPlain() { doTest(true); } - public void testWither$WitherWithDollar() throws IOException { + public void testWither$WitherWithDollar() { doTest(true); } - public void testWither$WitherWithGenerics() throws IOException { + public void testWither$WitherWithGenerics() { doTest(true); } - public void testWither$WitherWithAbstract() throws IOException { + public void testWither$WitherWithAbstract() { doTest(true); } } diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokHandlerUtil.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokHandlerUtil.java index 125bcb258..1da5a70e3 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokHandlerUtil.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokHandlerUtil.java @@ -243,7 +243,7 @@ private static List toAllAccessorNames(AccessorsInfo accessors, CharSequ } if (!isBoolean) { String accessorName = toAccessorName(accessors, fieldName, false, booleanPrefix, normalPrefix, adhereToFluent); - return (accessorName == null) ? Collections.emptyList() : Collections.singletonList(accessorName); + return (accessorName == null) ? Collections.emptyList() : Collections.singletonList(accessorName); } boolean explicitPrefix = accessors != null && false;//accessors.isExplicit("prefix"); diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllGetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllGetterTest.java index 10ea39e94..7210c1f26 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllGetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllGetterTest.java @@ -27,56 +27,56 @@ private void makeResults(String fieldName, boolean isBoolean, AccessorsInfo acce } @Test - public void testToAllGetterNames_NonBoolean() throws Exception { + public void testToAllGetterNames_NonBoolean() { makeResults("myField", false, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getMyField"))); } @Test - public void testToAllGetterNames_NonBoolean_Uppercase() throws Exception { + public void testToAllGetterNames_NonBoolean_Uppercase() { makeResults("myField", false, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getMyField"))); } @Test - public void testToAllGetterNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToAllGetterNames_NonBoolean_Uppercase_Multiple() { makeResults("MYField", false, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getMYField"))); } @Test - public void testToAllGetterNames_Boolean() throws Exception { + public void testToAllGetterNames_Boolean() { makeResults("myField", true, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getMyField", "isMyField"))); } @Test - public void testToAllGetterNames_Boolean_Uppercase() throws Exception { + public void testToAllGetterNames_Boolean_Uppercase() { makeResults("MyField", true, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getMyField", "isMyField"))); } @Test - public void testToAllGetterNames_Boolean_is_Lowercase() throws Exception { + public void testToAllGetterNames_Boolean_is_Lowercase() { makeResults("ismyField", true, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("isIsmyField", "getIsmyField"))); } @Test - public void testToAllGetterNames_Boolean_is_Uppercase() throws Exception { + public void testToAllGetterNames_Boolean_is_Uppercase() { makeResults("isMyField", true, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("isIsMyField", "getIsMyField", "getMyField", "isMyField"))); } @Test - public void testToAllGetterNames_Boolean_IS() throws Exception { + public void testToAllGetterNames_Boolean_IS() { makeResults("ISmyField", true, DEFAULT_ACCESSORS); assertThat(result, is(Arrays.asList("getISmyField", "isISmyField"))); @@ -84,9 +84,9 @@ public void testToAllGetterNames_Boolean_IS() throws Exception { @Test - public void testToAllGetterNames_NonBoolean_Fluent() throws Exception { + public void testToAllGetterNames_NonBoolean_Fluent() { makeResults("myField", false, AccessorsInfo.build(true, false, false)); assertThat(result, is(Arrays.asList("myField"))); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllSetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllSetterTest.java index 6010e126a..2411c1da3 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllSetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllSetterTest.java @@ -27,59 +27,59 @@ private void makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToAllSetterNames_NonBoolean() throws Exception { + public void testToAllSetterNames_NonBoolean() { makeResults("myField", false); assertThat(result, is(Arrays.asList("setMyField"))); } @Test - public void testToAllSetterNames_NonBoolean_Uppercase() throws Exception { + public void testToAllSetterNames_NonBoolean_Uppercase() { makeResults("myField", false); assertThat(result, is(Arrays.asList("setMyField"))); } @Test - public void testToAllSetterNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToAllSetterNames_NonBoolean_Uppercase_Multiple() { makeResults("MYField", false); assertThat(result, is(Arrays.asList("setMYField"))); } @Test - public void testToAllSetterNames_Boolean() throws Exception { + public void testToAllSetterNames_Boolean() { makeResults("myField", true); assertThat(result, is(Arrays.asList("setMyField"))); } @Test - public void testToAllSetterNames_Boolean_Uppercase() throws Exception { + public void testToAllSetterNames_Boolean_Uppercase() { makeResults("MyField", true); assertThat(result, is(Arrays.asList("setMyField"))); } @Test - public void testToAllSetterNames_Boolean_is_Lowercase() throws Exception { + public void testToAllSetterNames_Boolean_is_Lowercase() { makeResults("ismyField", true); assertThat(result, is(Arrays.asList("setIsmyField"))); } @Test - public void testToAllSetterNames_Boolean_is_Uppercase() throws Exception { + public void testToAllSetterNames_Boolean_is_Uppercase() { makeResults("isMyField", true); assertThat(result, is(Arrays.asList("setMyField", "setIsMyField"))); } @Test - public void testToAllSetterNames_Boolean_IS() throws Exception { + public void testToAllSetterNames_Boolean_IS() { makeResults("ISmyField", true); assertThat(result, is(Arrays.asList("setISmyField"))); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllWitherTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllWitherTest.java index 28e5bd11f..6ff169dbb 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllWitherTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsAllWitherTest.java @@ -27,56 +27,56 @@ private void makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToAllWitherNames_NonBoolean() throws Exception { + public void testToAllWitherNames_NonBoolean() { makeResults("myField", false); assertThat(result, is(Arrays.asList("withMyField"))); } @Test - public void testToAllWitherNames_NonBoolean_Uppercase() throws Exception { + public void testToAllWitherNames_NonBoolean_Uppercase() { makeResults("myField", false); assertThat(result, is(Arrays.asList("withMyField"))); } @Test - public void testToAllWitherNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToAllWitherNames_NonBoolean_Uppercase_Multiple() { makeResults("MYField", false); assertThat(result, is(Arrays.asList("withMYField"))); } @Test - public void testToAllWitherNames_Boolean() throws Exception { + public void testToAllWitherNames_Boolean() { makeResults("myField", true); assertThat(result, is(Arrays.asList("withMyField"))); } @Test - public void testToAllWitherNames_Boolean_Uppercase() throws Exception { + public void testToAllWitherNames_Boolean_Uppercase() { makeResults("MyField", true); assertThat(result, is(Arrays.asList("withMyField"))); } @Test - public void testToAllWitherNames_Boolean_is_Lowercase() throws Exception { + public void testToAllWitherNames_Boolean_is_Lowercase() { makeResults("ismyField", true); assertThat(result, is(Arrays.asList("withIsmyField"))); } @Test - public void testToAllWitherNames_Boolean_is_Uppercase() throws Exception { + public void testToAllWitherNames_Boolean_is_Uppercase() { makeResults("isMyField", true); assertThat(result, is(Arrays.asList("withIsMyField", "withMyField"))); } @Test - public void testToAllWitherNames_Boolean_IS() throws Exception { + public void testToAllWitherNames_Boolean_IS() { makeResults("ISmyField", true); assertThat(result, is(Arrays.asList("withISmyField"))); diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsGetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsGetterTest.java index 335f175c1..820a889d4 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsGetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsGetterTest.java @@ -20,73 +20,73 @@ private String makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToGetterNames_dValue() throws Exception { + public void testToGetterNames_dValue() { String result = makeResults("dValue", false); assertThat(result, equalTo("getDValue")); } @Test - public void testToGetterNames_Value() throws Exception { + public void testToGetterNames_Value() { String result = makeResults("Value", false); assertThat(result, equalTo("getValue")); } @Test - public void testToGetterNames_NonBoolean() throws Exception { + public void testToGetterNames_NonBoolean() { String result = makeResults("myField", false); assertThat(result, equalTo("getMyField")); } @Test - public void testToGetterNames_NonBoolean_Uppercase() throws Exception { + public void testToGetterNames_NonBoolean_Uppercase() { String result = makeResults("myField", false); assertThat(result, equalTo("getMyField")); } @Test - public void testToGetterNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToGetterNames_NonBoolean_Uppercase_Multiple() { String result = makeResults("MYField", false); assertThat(result, equalTo("getMYField")); } @Test - public void testToGetterNames_Boolean() throws Exception { + public void testToGetterNames_Boolean() { String result = makeResults("myField", true); assertThat(result, equalTo("isMyField")); } @Test - public void testToGetterNames_Boolean_Uppercase() throws Exception { + public void testToGetterNames_Boolean_Uppercase() { String result = makeResults("MyField", true); assertThat(result, equalTo("isMyField")); } @Test - public void testToGetterNames_Boolean_is_Lowercase() throws Exception { + public void testToGetterNames_Boolean_is_Lowercase() { String result = makeResults("ismyField", true); assertThat(result, equalTo("isIsmyField")); } @Test - public void testToGetterNames_Boolean_is_Uppercase() throws Exception { + public void testToGetterNames_Boolean_is_Uppercase() { String result = makeResults("isMyField", true); assertThat(result, equalTo("isMyField")); } @Test - public void testToGetterNames_Boolean_IS() throws Exception { + public void testToGetterNames_Boolean_IS() { String result = makeResults("ISmyField", true); assertThat(result, equalTo("isISmyField")); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsPrefixedFluentTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsPrefixedFluentTest.java index 2035ed2df..fbf5e6fa8 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsPrefixedFluentTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsPrefixedFluentTest.java @@ -20,73 +20,73 @@ private String makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToGetterNames_mValue() throws Exception { + public void testToGetterNames_mValue() { String result = makeResults("mValue", false); assertThat(result, equalTo("value")); } @Test - public void testToGetterNames_Value() throws Exception { + public void testToGetterNames_Value() { String result = makeResults("Value", false); assertThat(result, equalTo("Value")); } @Test - public void testToGetterNames_NonBoolean() throws Exception { + public void testToGetterNames_NonBoolean() { String result = makeResults("myField", false); assertThat(result, equalTo("myField")); } @Test - public void testToGetterNames_NonBoolean_Uppercase() throws Exception { + public void testToGetterNames_NonBoolean_Uppercase() { String result = makeResults("mYField", false); assertThat(result, equalTo("yField")); } @Test - public void testToGetterNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToGetterNames_NonBoolean_Uppercase_Multiple() { String result = makeResults("MYField", false); assertThat(result, equalTo("MYField")); } @Test - public void testToGetterNames_Boolean() throws Exception { + public void testToGetterNames_Boolean() { String result = makeResults("myField", true); assertThat(result, equalTo("myField")); } @Test - public void testToGetterNames_Boolean_Uppercase() throws Exception { + public void testToGetterNames_Boolean_Uppercase() { String result = makeResults("MYField", true); assertThat(result, equalTo("MYField")); } @Test - public void testToGetterNames_Boolean_is_Lowercase() throws Exception { + public void testToGetterNames_Boolean_is_Lowercase() { String result = makeResults("ismyField", true); assertThat(result, equalTo("ismyField")); } @Test - public void testToGetterNames_Boolean_is_Uppercase() throws Exception { + public void testToGetterNames_Boolean_is_Uppercase() { String result = makeResults("isMyField", true); assertThat(result, equalTo("isMyField")); } @Test - public void testToGetterNames_Boolean_IS() throws Exception { + public void testToGetterNames_Boolean_IS() { String result = makeResults("ISmyField", true); assertThat(result, equalTo("ISmyField")); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsSetterTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsSetterTest.java index f6fcdbeaf..cb30cc21e 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsSetterTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsSetterTest.java @@ -19,73 +19,73 @@ private String makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToSetterNames_dValue() throws Exception { + public void testToSetterNames_dValue() { String result = makeResults("dValue", false); assertThat(result, equalTo("setDValue")); } @Test - public void testToSetterNames_Value() throws Exception { + public void testToSetterNames_Value() { String result = makeResults("Value", false); assertThat(result, equalTo("setValue")); } @Test - public void testToSetterNames_NonBoolean() throws Exception { + public void testToSetterNames_NonBoolean() { String result = makeResults("myField", false); assertThat(result, equalTo("setMyField")); } @Test - public void testToSetterNames_NonBoolean_Uppercase() throws Exception { + public void testToSetterNames_NonBoolean_Uppercase() { String result = makeResults("myField", false); assertThat(result, equalTo("setMyField")); } @Test - public void testToSetterNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToSetterNames_NonBoolean_Uppercase_Multiple() { String result = makeResults("MYField", false); assertThat(result, equalTo("setMYField")); } @Test - public void testToSetterNames_Boolean() throws Exception { + public void testToSetterNames_Boolean() { String result = makeResults("myField", true); assertThat(result, equalTo("setMyField")); } @Test - public void testToSetterNames_Boolean_Uppercase() throws Exception { + public void testToSetterNames_Boolean_Uppercase() { String result = makeResults("MyField", true); assertThat(result, equalTo("setMyField")); } @Test - public void testToSetterNames_Boolean_is_Lowercase() throws Exception { + public void testToSetterNames_Boolean_is_Lowercase() { String result = makeResults("ismyField", true); assertThat(result, equalTo("setIsmyField")); } @Test - public void testToSetterNames_Boolean_is_Uppercase() throws Exception { + public void testToSetterNames_Boolean_is_Uppercase() { String result = makeResults("isMyField", true); assertThat(result, equalTo("setMyField")); } @Test - public void testToSetterNames_Boolean_IS() throws Exception { + public void testToSetterNames_Boolean_IS() { String result = makeResults("ISmyField", true); assertThat(result, equalTo("setISmyField")); } -} \ No newline at end of file +} diff --git a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsWitherTest.java b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsWitherTest.java index 8e00bde20..cdef62dea 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsWitherTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/thirdparty/LombokUtilsWitherTest.java @@ -19,70 +19,70 @@ private String makeResults(String fieldName, boolean isBoolean) { } @Test - public void testToWitherNames_dValue() throws Exception { + public void testToWitherNames_dValue() { String result = makeResults("dValue", false); assertThat(result, equalTo("withDValue")); } @Test - public void testToWitherNames_Value() throws Exception { + public void testToWitherNames_Value() { String result = makeResults("Value", false); assertThat(result, equalTo("withValue")); } @Test - public void testToWitherNames_NonBoolean() throws Exception { + public void testToWitherNames_NonBoolean() { String result = makeResults("myField", false); assertThat(result, equalTo("withMyField")); } @Test - public void testToWitherNames_NonBoolean_Uppercase() throws Exception { + public void testToWitherNames_NonBoolean_Uppercase() { String result = makeResults("myField", false); assertThat(result, equalTo("withMyField")); } @Test - public void testToWitherNames_NonBoolean_Uppercase_Multiple() throws Exception { + public void testToWitherNames_NonBoolean_Uppercase_Multiple() { String result = makeResults("MYField", false); assertThat(result, equalTo("withMYField")); } @Test - public void testToWitherNames_Boolean() throws Exception { + public void testToWitherNames_Boolean() { String result = makeResults("myField", true); assertThat(result, equalTo("withMyField")); } @Test - public void testToWitherNames_Boolean_Uppercase() throws Exception { + public void testToWitherNames_Boolean_Uppercase() { String result = makeResults("MyField", true); assertThat(result, equalTo("withMyField")); } @Test - public void testToWitherNames_Boolean_is_Lowercase() throws Exception { + public void testToWitherNames_Boolean_is_Lowercase() { String result = makeResults("ismyField", true); assertThat(result, equalTo("withIsmyField")); } @Test - public void testToWitherNames_Boolean_is_Uppercase() throws Exception { + public void testToWitherNames_Boolean_is_Uppercase() { String result = makeResults("isMyField", true); assertThat(result, equalTo("withMyField")); } @Test - public void testToWitherNames_Boolean_IS() throws Exception { + public void testToWitherNames_Boolean_IS() { String result = makeResults("ISmyField", true); assertThat(result, equalTo("withISmyField")); diff --git a/test-manual/src/main/java/de/plushnikov/refactor/Issue512.java b/test-manual/src/main/java/de/plushnikov/refactor/Issue512.java new file mode 100644 index 000000000..d0d933384 --- /dev/null +++ b/test-manual/src/main/java/de/plushnikov/refactor/Issue512.java @@ -0,0 +1,28 @@ +package de.plushnikov.refactor; + +import com.google.common.collect.ComparisonChain; +import lombok.NonNull; +import lombok.Value; + +public class Issue512 { + class Tile { + int id; + + int getId() { + return id; + } + } + + @Value // <-- This needs to be Lombok supplied + private static class TileIdFormatAndBaseLevel implements Comparable { + @NonNull + Tile tile; // <-- If you rename this 'tile' to 'xyz', the o.getTile() below becomes this.getXYZ() + + @Override + public int compareTo(@NonNull final TileIdFormatAndBaseLevel o) { + return ComparisonChain.start() + .compare(o.getTile().getId(), tile.getId()) + .result(); + } + } +} diff --git a/testData/action/delombok/equalsandhashcode/afterEqualsAndHashCodeIncludeExclude.java b/testData/action/delombok/equalsandhashcode/afterEqualsAndHashCodeIncludeExclude.java new file mode 100644 index 000000000..1c75bb74c --- /dev/null +++ b/testData/action/delombok/equalsandhashcode/afterEqualsAndHashCodeIncludeExclude.java @@ -0,0 +1,42 @@ +public class EqualsAndHashCodeIncludeExclude { + int x; + boolean bool; + String a; + + int getX() { + return x; + } + + boolean isBool() { + return bool; + } + + String getA() { + return a; + } + + public boolean equals(final Object o) { + if (o == this) return true; + if (!(o instanceof EqualsAndHashCodeIncludeExclude)) return false; + final EqualsAndHashCodeIncludeExclude other = (EqualsAndHashCodeIncludeExclude) o; + if (!other.canEqual((Object) this)) return false; + if (this.getX() != other.getX()) return false; + final Object this$aaa = this.getA(); + final Object other$aaa = other.getA(); + if (this$aaa == null ? other$aaa != null : !this$aaa.equals(other$aaa)) return false; + return true; + } + + protected boolean canEqual(final Object other) { + return other instanceof EqualsAndHashCodeIncludeExclude; + } + + public int hashCode() { + final int PRIME = 59; + int result = 1; + result = result * PRIME + this.getX(); + final Object $aaa = this.getA(); + result = result * PRIME + ($aaa == null ? 43 : $aaa.hashCode()); + return result; + } +} diff --git a/testData/action/delombok/equalsandhashcode/beforeEqualsAndHashCodeIncludeExclude.java b/testData/action/delombok/equalsandhashcode/beforeEqualsAndHashCodeIncludeExclude.java new file mode 100644 index 000000000..8e647bf0f --- /dev/null +++ b/testData/action/delombok/equalsandhashcode/beforeEqualsAndHashCodeIncludeExclude.java @@ -0,0 +1,20 @@ +@lombok.EqualsAndHashCode +public class EqualsAndHashCodeIncludeExclude { + int x; + @lombok.EqualsAndHashCode.Exclude + boolean bool; + @lombok.EqualsAndHashCode.Include(replaces = "aaa") + String a; + + int getX() { + return x; + } + + boolean isBool() { + return bool; + } + + String getA() { + return a; + } +} diff --git a/testData/inspection/autoCloseableResource/AutoCloseableCleanup.java b/testData/inspection/autoCloseableResource/AutoCloseableCleanup.java new file mode 100644 index 000000000..90da237d5 --- /dev/null +++ b/testData/inspection/autoCloseableResource/AutoCloseableCleanup.java @@ -0,0 +1,24 @@ +package inspection.autoCloseableResource; + +import lombok.Cleanup; + +import java.io.IOException; +import java.io.InputStream; + +public class AutoCloseableCleanup { + + public static void main(String[] args) throws IOException { + withoutCleanUp(); + withCleanUp(); + } + + private static void withCleanUp() throws IOException { + @Cleanup InputStream profile = Thread.currentThread().getContextClassLoader().getResourceAsStream("/someFile"); + System.out.println(profile.read()); + } + + private static void withoutCleanUp() throws IOException { + InputStream profile = Thread.currentThread().getContextClassLoader().getResourceAsStream("/someFile"); + System.out.println(profile.read()); + } +}