diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/CleanupProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/CleanupProcessor.java index 7f5cbc0b2..e8b332122 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/CleanupProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/CleanupProcessor.java @@ -80,7 +80,7 @@ private void validateCleanUpMethodExists(@NotNull PsiLocalVariable psiVariable, } private void validateInitializerExist(@NotNull ProblemNewBuilder problemNewBuilder, @NotNull PsiLocalVariable psiVariable) { - if (null == psiVariable.getInitializer()) { + if (!psiVariable.hasInitializer()) { problemNewBuilder.addError("'@Cleanup' variable declarations need to be initialized."); } } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/ValProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/ValProcessor.java index f85bcd0b9..4925d764d 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/ValProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/ValProcessor.java @@ -58,7 +58,7 @@ public static boolean isVar(@NotNull PsiVariable psiVariable) { } public static boolean isVal(@NotNull PsiLocalVariable psiLocalVariable) { - if (psiLocalVariable.getInitializer() != null) { + if (psiLocalVariable.hasInitializer()) { final PsiTypeElement typeElement = psiLocalVariable.getTypeElement(); return isPossibleVal(typeElement.getText()) && isVal(resolveQualifiedName(typeElement)); } @@ -66,7 +66,7 @@ public static boolean isVal(@NotNull PsiLocalVariable psiLocalVariable) { } public static boolean isVar(@NotNull PsiLocalVariable psiLocalVariable) { - if (psiLocalVariable.getInitializer() != null) { + if (psiLocalVariable.hasInitializer()) { final PsiTypeElement typeElement = psiLocalVariable.getTypeElement(); return isPossibleVar(typeElement.getText()) && isVar(resolveQualifiedName(typeElement)); } @@ -74,7 +74,7 @@ public static boolean isVar(@NotNull PsiLocalVariable psiLocalVariable) { } private static boolean isValOrVar(@NotNull PsiLocalVariable psiLocalVariable) { - if (psiLocalVariable.getInitializer() != null) { + if (psiLocalVariable.hasInitializer()) { final PsiTypeElement typeElement = psiLocalVariable.getTypeElement(); return isPossibleValOrVar(typeElement.getText()) && isValOrVar(resolveQualifiedName(typeElement)); } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/AbstractConstructorClassProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/AbstractConstructorClassProcessor.java index db62551bc..0595d068c 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/AbstractConstructorClassProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/clazz/constructor/AbstractConstructorClassProcessor.java @@ -177,7 +177,7 @@ protected Collection getAllNotInitializedAndNotStaticFields(@NotNull P boolean isFinal = isFieldFinal(psiField, modifierList, classAnnotatedWithValue); // skip initialized final fields - addField &= (!isFinal || null == psiField.getInitializer() || + addField &= (!isFinal || !psiField.hasInitializer() || PsiAnnotationSearchUtil.findAnnotation(psiField, BUILDER_DEFAULT_ANNOTATION) != null); } @@ -204,7 +204,7 @@ public Collection getRequiredFields(@NotNull PsiClass psiClass) { final boolean isFinal = isFieldFinal(psiField, modifierList, classAnnotatedWithValue); final boolean isNonNull = PsiAnnotationSearchUtil.isAnnotatedWith(psiField, LombokUtils.NON_NULL_PATTERN); // accept initialized final or nonnull fields - if ((isFinal || isNonNull) && null == psiField.getInitializer()) { + if ((isFinal || isNonNull) && !psiField.hasInitializer()) { result.add(psiField); } } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/field/GetterFieldProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/field/GetterFieldProcessor.java index b2a5e39ef..a12817462 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/field/GetterFieldProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/field/GetterFieldProcessor.java @@ -53,7 +53,7 @@ protected boolean validate(@NotNull PsiAnnotation psiAnnotation, @NotNull PsiFie PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.FINAL, true, false)); result = false; } - if (null == psiField.getInitializer()) { + if (!psiField.hasInitializer()) { builder.addError("'lazy' requires field initialization."); result = false; } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java b/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java index f0afb77fb..3b7ece43f 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/field/WitherFieldProcessor.java @@ -84,7 +84,7 @@ private boolean validNonFinalInitialized(@NotNull PsiField psiField, @NotNull Pr final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass && psiField.hasModifierProperty(PsiModifier.FINAL) && !PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.VALUE) && - psiField.getInitializer() != null && !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, LombokClassNames.BUILDER_DEFAULT)) { + psiField.hasInitializer() && !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, LombokClassNames.BUILDER_DEFAULT)) { builder.addWarning("Not generating wither for this field: Withers cannot be generated for final, initialized fields.", PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.FINAL, false, false)); return false; @@ -152,7 +152,7 @@ private Collection filterFields(@NotNull PsiClass psiClass) { if (classField.hasModifierProperty(PsiModifier.STATIC)) { continue; } - if (classField.hasModifierProperty(PsiModifier.FINAL) && null != classField.getInitializer()) { + if (classField.hasModifierProperty(PsiModifier.FINAL) && classField.hasInitializer()) { continue; } diff --git a/src/test/java/de/plushnikov/intellij/plugin/AbstractLombokLightCodeInsightTestCase.java b/src/test/java/de/plushnikov/intellij/plugin/AbstractLombokLightCodeInsightTestCase.java index 8c05c8205..342aca30a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/AbstractLombokLightCodeInsightTestCase.java +++ b/src/test/java/de/plushnikov/intellij/plugin/AbstractLombokLightCodeInsightTestCase.java @@ -1,5 +1,6 @@ package de.plushnikov.intellij.plugin; +import com.intellij.openapi.util.RecursionManager; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -35,6 +36,9 @@ public void setUp() throws Exception { super.setUp(); loadLombokLibrary(); + + //TODO disable assertions for the moment + RecursionManager.disableMissedCacheAssertions(myFixture.getProjectDisposable()); } protected void loadLombokLibrary() { diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/DataFlowWithDisabledCachingInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/DataFlowWithDisabledCachingInspectionTest.java index c49589b66..60d913f8a 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/DataFlowWithDisabledCachingInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/DataFlowWithDisabledCachingInspectionTest.java @@ -2,7 +2,6 @@ import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.dataFlow.DataFlowInspection; -import com.intellij.openapi.util.RecursionManager; public class DataFlowWithDisabledCachingInspectionTest extends LombokInspectionTest { diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/LombokInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/LombokInspectionTest.java index 12b8cc2ea..2a59b3a44 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/LombokInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/LombokInspectionTest.java @@ -1,5 +1,6 @@ package de.plushnikov.intellij.plugin.inspection; +import com.intellij.openapi.util.RecursionManager; import com.intellij.openapi.util.registry.Registry; import com.intellij.testFramework.LightProjectDescriptor; import com.siyeh.ig.LightJavaInspectionTestCase; @@ -16,6 +17,9 @@ public void setUp() throws Exception { LombokTestUtil.loadLombokLibrary(myFixture.getProjectDisposable(), getModule()); Registry.get("platform.random.idempotence.check.rate").setValue(1, getTestRootDisposable()); + + //TODO disable assertions for the moment + RecursionManager.disableMissedCacheAssertions(myFixture.getProjectDisposable()); } @NotNull diff --git a/src/test/java/de/plushnikov/intellij/plugin/inspection/PointlessBooleanExpressionInspectionTest.java b/src/test/java/de/plushnikov/intellij/plugin/inspection/PointlessBooleanExpressionInspectionTest.java index 975d4bf5e..02657bc7b 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/inspection/PointlessBooleanExpressionInspectionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/inspection/PointlessBooleanExpressionInspectionTest.java @@ -1,7 +1,6 @@ package de.plushnikov.intellij.plugin.inspection; import com.intellij.codeInspection.InspectionProfileEntry; -import com.intellij.openapi.util.RecursionManager; import com.siyeh.ig.controlflow.PointlessBooleanExpressionInspection; /** diff --git a/src/test/java/de/plushnikov/intellij/plugin/intention/LombokIntentionActionTest.java b/src/test/java/de/plushnikov/intellij/plugin/intention/LombokIntentionActionTest.java index 03f7a015a..28df23aed 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/intention/LombokIntentionActionTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/intention/LombokIntentionActionTest.java @@ -13,11 +13,6 @@ protected String getBasePath() { return TEST_DATA_INTENTION_DIRECTORY; } - @Override - public void setUp() throws Exception { - super.setUp(); - } - public abstract IntentionAction getIntentionAction(); public abstract boolean wasInvocationSuccessful(); diff --git a/src/test/java/de/plushnikov/intellij/plugin/postfix/LombokVarPostfixTemplateTest.java b/src/test/java/de/plushnikov/intellij/plugin/postfix/LombokVarPostfixTemplateTest.java index b00c4f9ac..65180c2dc 100644 --- a/src/test/java/de/plushnikov/intellij/plugin/postfix/LombokVarPostfixTemplateTest.java +++ b/src/test/java/de/plushnikov/intellij/plugin/postfix/LombokVarPostfixTemplateTest.java @@ -3,6 +3,7 @@ import de.plushnikov.intellij.plugin.AbstractLombokLightCodeInsightTestCase; public class LombokVarPostfixTemplateTest extends AbstractLombokLightCodeInsightTestCase { + public void testSimpleVarl() { doTest("/postfix/varl/"); }