Skip to content

Commit

Permalink
Hacked FBP accessor refactoring
Browse files Browse the repository at this point in the history
Fixes #1720
See #1730

(cherry picked from commit fc1875a)
  • Loading branch information
hurricup committed Feb 18, 2018
1 parent eabe12f commit 7b1879f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
import com.intellij.refactoring.rename.PsiElementRenameHandler;
import com.intellij.refactoring.rename.RenamePsiElementProcessor;
import com.perl5.PerlIcons;
import com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod;
import com.perl5.lang.perl.psi.PerlGlobVariable;
import com.perl5.lang.perl.psi.PerlSubElement;
import com.perl5.lang.perl.util.PerlSubUtil;
import com.perl5.lang.pod.PodLanguage;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;
import java.util.Set;

/**
* Created by hurricup on 03.10.2015.
Expand Down Expand Up @@ -67,6 +70,18 @@ public void prepareRenaming(PsiElement element, String newName, Map<PsiElement,
allRenames.put(overridingSub, newName);
}
}

// following is the hack until #1730 is fixed
Set<PsiElement> allElements = new THashSet<>(allRenames.keySet());
allElements.stream()
.filter(e -> e instanceof PerlClassAccessorMethod)
.forEach(e -> {
PerlClassAccessorMethod pairedMethod = ((PerlClassAccessorMethod)e).getPairedMethod();
if (pairedMethod != null && allRenames.containsKey(e)) {
allRenames.remove(pairedMethod);
}
});

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.intellij.psi.PsiElement;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.perl5.lang.perl.extensions.PerlRenameUsagesHelper;
import com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement;
import com.perl5.lang.perl.psi.light.PerlLightMethodDefinitionElement;
Expand Down Expand Up @@ -144,9 +143,4 @@ else if (getSetterName().equals(currentValue)) {
public boolean isInplaceRefactoringAllowed() {
return !isFollowBestPractice();
}

@Override
public PsiElement setName(@NotNull String newBaseName) throws IncorrectOperationException {
return isValid() ? super.setName(newBaseName) : null;
}
}

0 comments on commit 7b1879f

Please sign in to comment.