mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace rename: check for rename element even if it is valid (reparse surprises)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
public class ResourceLocator {
|
||||
private ContentContainsChecker myContentContainsChecker;
|
||||
private DeltaI<caret>nfoGetter myDeltaInfoGetter;
|
||||
|
||||
|
||||
private class ContentContainsChecker {
|
||||
|
||||
}
|
||||
|
||||
private class RevisionInfoContainsChecker {
|
||||
}
|
||||
|
||||
private class DeltaInfoGetter {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class ResourceLocator {
|
||||
private ContentContainsChecker myContentContainsChecker;
|
||||
private NEW_NAME myNEWNAME;
|
||||
|
||||
|
||||
private class ContentContainsChecker {
|
||||
|
||||
}
|
||||
|
||||
private class RevisionInfoContainsChecker {
|
||||
}
|
||||
|
||||
private class NEW_NAME {
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,10 @@ public class RenameMembersInplaceTest extends LightCodeInsightTestCase {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testInnerClass() throws Exception {
|
||||
doTestInplaceRename("NEW_NAME");
|
||||
}
|
||||
|
||||
public void testConstructor() throws Exception {
|
||||
doTestInplaceRename("Bar");
|
||||
}
|
||||
|
||||
+5
-1
@@ -50,6 +50,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -407,7 +408,10 @@ public abstract class InplaceRefactoring {
|
||||
|
||||
@Nullable
|
||||
protected PsiNamedElement getVariable() {
|
||||
if (myElementToRename != null && myElementToRename.isValid()) return myElementToRename;
|
||||
if (myElementToRename != null && myElementToRename.isValid()) {
|
||||
if (Comparing.strEqual(myOldName, myElementToRename.getName())) return myElementToRename;
|
||||
return PsiTreeUtil.getParentOfType(myElementToRename.getContainingFile().findElementAt(myRenameOffset.getStartOffset()), PsiNameIdentifierOwner.class);
|
||||
}
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
|
||||
if (psiFile != null) {
|
||||
return PsiTreeUtil.getParentOfType(psiFile.findElementAt(myRenameOffset.getStartOffset()), PsiNameIdentifierOwner.class);
|
||||
|
||||
+10
-1
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -240,7 +241,15 @@ public class MemberInplaceRenamer extends VariableInplaceRenamer {
|
||||
|
||||
@Nullable
|
||||
public PsiElement getSubstituted() {
|
||||
if (mySubstituted != null && mySubstituted.isValid()) return mySubstituted;
|
||||
if (mySubstituted != null && mySubstituted.isValid()){
|
||||
if (mySubstituted instanceof PsiNameIdentifierOwner) {
|
||||
if (Comparing.strEqual(myOldName, ((PsiNameIdentifierOwner)mySubstituted).getName())) return mySubstituted;
|
||||
|
||||
final RangeMarker rangeMarker = mySubstitutedRange != null ? mySubstitutedRange : myRenameOffset;
|
||||
return PsiTreeUtil.getParentOfType(mySubstituted.getContainingFile().findElementAt(rangeMarker.getStartOffset()), PsiNameIdentifierOwner.class);
|
||||
}
|
||||
return mySubstituted;
|
||||
}
|
||||
if (mySubstitutedRange != null) {
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
|
||||
if (psiFile != null) {
|
||||
|
||||
Reference in New Issue
Block a user