From 1b11c3050ed184c489fa5eb884e2804f24027577 Mon Sep 17 00:00:00 2001 From: Michail Plushnikov Date: Sat, 2 Jan 2021 11:44:15 +0100 Subject: [PATCH] merged changes from IntelliJ-Master --- .../plugin/psi/LombokLightFieldBuilder.java | 35 ++++++------------- .../plugin/psi/LombokLightParameter.java | 9 ++++- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightFieldBuilder.java b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightFieldBuilder.java index e4a6a01c5..5f7edbde2 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightFieldBuilder.java +++ b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightFieldBuilder.java @@ -17,28 +17,20 @@ * @author Plushnikov Michail */ public class LombokLightFieldBuilder extends LightFieldBuilder implements SyntheticElement { - private String myName; private final LombokLightIdentifier myNameIdentifier; - private final LombokLightModifierList myModifierList; public LombokLightFieldBuilder(@NotNull PsiManager manager, @NotNull String name, @NotNull PsiType type) { super(manager, name, type); - myName = name; + super.setModifierList(new LombokLightModifierList(manager)); myNameIdentifier = new LombokLightIdentifier(manager, name); - myModifierList = new LombokLightModifierList(manager); setBaseIcon(LombokIcons.FIELD_ICON); } - @Override - @NotNull - public LombokLightModifierList getModifierList() { - return myModifierList; - } - @Override public LombokLightFieldBuilder setModifiers(String... modifiers) { - myModifierList.clearModifiers(); - Stream.of(modifiers).forEach(myModifierList::addModifier); + final LombokLightModifierList lombokLightModifierList = (LombokLightModifierList)getModifierList(); + lombokLightModifierList.clearModifiers(); + Stream.of(modifiers).forEach(lombokLightModifierList::addModifier); return this; } @@ -48,23 +40,18 @@ public LombokLightFieldBuilder setModifierList(LightModifierList modifierList) { return this; } - @Override - public boolean hasModifierProperty(@NonNls @NotNull String name) { - return myModifierList.hasModifierProperty(name); - } - public LombokLightFieldBuilder withContainingClass(PsiClass psiClass) { setContainingClass(psiClass); return this; } public LombokLightFieldBuilder withImplicitModifier(@PsiModifier.ModifierConstant @NotNull @NonNls String modifier) { - myModifierList.addImplicitModifierProperty(modifier); + ((LombokLightModifierList)getModifierList()).addImplicitModifierProperty(modifier); return this; } public LombokLightFieldBuilder withModifier(@PsiModifier.ModifierConstant @NotNull @NonNls String modifier) { - myModifierList.addModifier(modifier); + ((LombokLightModifierList)getModifierList()).addModifier(modifier); return this; } @@ -76,13 +63,12 @@ public LombokLightFieldBuilder withNavigationElement(PsiElement navigationElemen @NotNull @Override public String getName() { - return myName; + return myNameIdentifier.getText(); } @Override public PsiElement setName(@NotNull String name) { - myName = name; - myNameIdentifier.setText(myName); + myNameIdentifier.setText(name); return this; } @@ -151,14 +137,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; LombokLightFieldBuilder that = (LombokLightFieldBuilder) o; return - Objects.equals(myName, that.myName) && Objects.equals(myNameIdentifier, that.myNameIdentifier) && - Objects.equals(myModifierList, that.myModifierList) && + Objects.equals(getModifierList(), that.getModifierList()) && Objects.equals(getContainingClass(), that.getContainingClass()); } @Override public int hashCode() { - return Objects.hash(myName, myNameIdentifier, myModifierList, getContainingClass()); + return Objects.hash(myNameIdentifier, getModifierList(), getContainingClass()); } } diff --git a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightParameter.java b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightParameter.java index bfb02a6c2..0a1aa9747 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightParameter.java +++ b/src/main/java/de/plushnikov/intellij/plugin/psi/LombokLightParameter.java @@ -6,6 +6,7 @@ import com.intellij.psi.PsiIdentifier; import com.intellij.psi.PsiType; import com.intellij.psi.SyntheticElement; +import com.intellij.psi.impl.light.LightModifierList; import com.intellij.psi.impl.light.LightParameter; import org.jetbrains.annotations.NotNull; @@ -19,8 +20,8 @@ public class LombokLightParameter extends LightParameter implements SyntheticEle public LombokLightParameter(@NotNull String name, @NotNull PsiType type, PsiElement declarationScope, Language language) { super(name, type, declarationScope, language); + super.setModifierList(new LombokLightModifierList(declarationScope.getManager(), language)); myNameIdentifier = new LombokLightIdentifier(declarationScope.getManager(), name); - setModifierList(new LombokLightModifierList(declarationScope.getManager(), language)); } @NotNull @@ -54,6 +55,12 @@ public LombokLightParameter setModifiers(String... modifiers) { return this; } + @Override + public LombokLightParameter setModifierList(LightModifierList modifierList) { + setModifiers(modifierList.getModifiers()); + return this; + } + @Override public boolean equals(Object o) { if (this == o) {