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

Commit

Permalink
merged changes from IntelliJ-Master
Browse files Browse the repository at this point in the history
  • Loading branch information
mplushnikov committed Jan 2, 2021
1 parent 87abf42 commit 1b11c30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

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

Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1b11c30

Please sign in to comment.