Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'backport_intellij_2020.1' into backport_intellij_2019.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/test/java/de/plushnikov/intellij/plugin/intention/LombokIntentionActionTest.java
#	src/test/java/de/plushnikov/intellij/plugin/postfix/LombokVarPostfixTemplateTest.java
#	src/test/java/de/plushnikov/intellij/plugin/processor/modifier/ValModifierTest.java
  • Loading branch information
mplushnikov committed Oct 27, 2020
2 parents 9551122 + d8b6847 commit c7469ec
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ 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));
}
return false;
}

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));
}
return false;
}

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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected Collection<PsiField> 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);
}

Expand All @@ -204,7 +204,7 @@ public Collection<PsiField> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -152,7 +152,7 @@ private Collection<PsiField> 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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.plushnikov.intellij.plugin.AbstractLombokLightCodeInsightTestCase;

public class LombokVarPostfixTemplateTest extends AbstractLombokLightCodeInsightTestCase {

public void testSimpleVarl() {
doTest("/postfix/varl/");
}
Expand Down

0 comments on commit c7469ec

Please sign in to comment.