mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
rename: do not qualify refs to fields with this in static context
This commit is contained in:
@@ -43,8 +43,9 @@ class JavaResolveSnapshot extends ResolveSnapshotProvider.ResolveSnapshot {
|
||||
scope.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override public void visitReferenceExpression(PsiReferenceExpression refExpr) {
|
||||
if (!refExpr.isQualified()) {
|
||||
PsiElement resolved = refExpr.resolve();
|
||||
if (resolved instanceof PsiField) {
|
||||
JavaResolveResult resolveResult = refExpr.advancedResolve(false);
|
||||
final PsiElement resolved = resolveResult.getElement();
|
||||
if (resolved instanceof PsiField && resolveResult.isStaticsScopeCorrect()) {
|
||||
SmartPsiElementPointer key = pointerManager.createSmartPsiElementPointer(refExpr);
|
||||
SmartPsiElementPointer value = pointers.get(resolved);
|
||||
if (value == null) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
String myFoo;
|
||||
static {
|
||||
String f<caret>oo = "";
|
||||
System.out.println(myFoo);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Test {
|
||||
String myFoo;
|
||||
static {
|
||||
String myFoo = "";
|
||||
System.out.println(myFoo);
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,10 @@ public class RenameLocalTest extends LightRefactoringTestCase {
|
||||
doTestInplaceRename("r1");
|
||||
}
|
||||
|
||||
public void testRenameToFieldNameInStaticContext() throws Exception {
|
||||
doTestInplaceRename("myFoo");
|
||||
}
|
||||
|
||||
public void testRenameInPlaceInStaticContextWithConflictingField() throws Exception {
|
||||
doTestInplaceRename("s");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user