mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace rename: static context processing (IDEA-81427)
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -79,8 +80,12 @@ class JavaResolveSnapshot extends ResolveSnapshotProvider.ResolveSnapshot {
|
||||
PsiTreeUtil.isAncestor(refereeClass, referentClass, false)) {
|
||||
if (refereeClass == referentClass ||
|
||||
refereeClass.getName() != null) { //otherwise cannot qualify anonymous referee class
|
||||
@NonNls String qualifer = refereeClass == referentClass ? "this" :
|
||||
refereeClass.getName() + ".this";
|
||||
@NonNls String qualifer;
|
||||
if (RefactoringUtil.isInStaticContext(ref, refereeClass)) {
|
||||
qualifer = refereeClass.getName();
|
||||
} else {
|
||||
qualifer = refereeClass == referentClass ? "this" : refereeClass.getName() + ".this";
|
||||
}
|
||||
String qualifiedRefText = qualifer + "." + ref.getText();
|
||||
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(referentClass.getProject()).getElementFactory();
|
||||
try {
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class X {
|
||||
public static final String s = "s";
|
||||
|
||||
public static void main(String... args) {
|
||||
String s<caret>1 = s;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class X {
|
||||
public static final String s = "s";
|
||||
|
||||
public static void main(String... args) {
|
||||
String s = X.s;
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,10 @@ public class RenameLocalTest extends LightRefactoringTestCase {
|
||||
doTestInplaceRename("r1");
|
||||
}
|
||||
|
||||
public void testRenameInPlaceInStaticContextWithConflictingField() throws Exception {
|
||||
doTestInplaceRename("s");
|
||||
}
|
||||
|
||||
private void doTestInplaceRename(final String newName) throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user