mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'python-fixes'
This commit is contained in:
@@ -24,7 +24,7 @@ public class TypeEvalContext {
|
||||
private final boolean myAllowStubToAST;
|
||||
private List<String> myTrace;
|
||||
private String myTraceIndent = "";
|
||||
private final PsiFile myOrigin;
|
||||
@Nullable private final PsiFile myOrigin;
|
||||
|
||||
private final Map<PyTypedElement, PyType> myEvaluated = new HashMap<PyTypedElement, PyType>();
|
||||
private final ThreadLocal<Set<PyTypedElement>> myEvaluating = new ThreadLocal<Set<PyTypedElement>>() {
|
||||
@@ -34,7 +34,7 @@ public class TypeEvalContext {
|
||||
}
|
||||
};
|
||||
|
||||
private TypeEvalContext(boolean allowDataFlow, boolean allowStubToAST, PsiFile origin) {
|
||||
private TypeEvalContext(boolean allowDataFlow, boolean allowStubToAST, @Nullable PsiFile origin) {
|
||||
myAllowDataFlow = allowDataFlow;
|
||||
myAllowStubToAST = allowStubToAST;
|
||||
myOrigin = origin;
|
||||
@@ -139,4 +139,9 @@ public class TypeEvalContext {
|
||||
public boolean maySwitchToAST(@NotNull StubBasedPsiElement element) {
|
||||
return myAllowStubToAST || (element.getStub() == null && (myOrigin == null || myOrigin == element.getContainingFile()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiFile getOrigin() {
|
||||
return myOrigin;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,16 @@ public class PyQualifiedReference extends PyReferenceImpl {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ResolveResult result : copyWithoutImplicits().multiResolve(false)) {
|
||||
PyResolveContext resolveContext = myContext.withoutImplicits();
|
||||
if (resolveContext.getTypeEvalContext().getOrigin() == null) {
|
||||
final PsiFile containingFile = myElement.getContainingFile();
|
||||
if (containingFile instanceof StubBasedPsiElement) {
|
||||
assert ((StubBasedPsiElement)containingFile).getStub() == null : "Stub origin for type eval context in isReferenceTo()";
|
||||
}
|
||||
final TypeEvalContext context = TypeEvalContext.fastStubOnly(containingFile);
|
||||
resolveContext = resolveContext.withTypeEvalContext(context);
|
||||
}
|
||||
for (ResolveResult result : copyWithResolveContext(resolveContext).multiResolve(false)) {
|
||||
LOG.assertTrue(!(result instanceof ImplicitResolveResult));
|
||||
PsiElement resolveResult = result.getElement();
|
||||
if (isResolvedToResult(element, resolveResult)) {
|
||||
@@ -399,8 +408,9 @@ public class PyQualifiedReference extends PyReferenceImpl {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected PyQualifiedReference copyWithoutImplicits() {
|
||||
return new PyQualifiedReference(myElement, myContext.withoutImplicits());
|
||||
@NotNull
|
||||
protected PyQualifiedReference copyWithResolveContext(PyResolveContext context) {
|
||||
return new PyQualifiedReference(myElement, context);
|
||||
}
|
||||
|
||||
private boolean isResolvedToResult(PsiElement element, PsiElement resolveResult) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class С:
|
||||
def __init__(self, x=None):
|
||||
if x is None:
|
||||
self.foo = {
|
||||
'A': {
|
||||
'x': 0,
|
||||
'y': 0,
|
||||
},
|
||||
}
|
||||
else: # init was given the previous state
|
||||
assert isinstance(x, С)
|
||||
self.foo = {
|
||||
'A': {
|
||||
'x': x.f<caret>oo['A']['x'],
|
||||
'y': x.foo['A']['y'],
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class С:
|
||||
def __init__(self, x=None):
|
||||
if x is None:
|
||||
self.bar = {
|
||||
'A': {
|
||||
'x': 0,
|
||||
'y': 0,
|
||||
},
|
||||
}
|
||||
else: # init was given the previous state
|
||||
assert isinstance(x, С)
|
||||
self.bar = {
|
||||
'A': {
|
||||
'x': x.bar['A']['x'],
|
||||
'y': x.bar['A']['y'],
|
||||
},
|
||||
}
|
||||
@@ -168,6 +168,11 @@ public class PyRenameTest extends PyTestCase {
|
||||
doMultiFileTest("bar.py");
|
||||
}
|
||||
|
||||
// PY-9047
|
||||
public void testRenameSelfAndParameterAttribute() {
|
||||
doTest("bar");
|
||||
}
|
||||
|
||||
private void doRenameConflictTest(String newName, String expectedConflict) {
|
||||
myFixture.configureByFile(RENAME_DATA_PATH + getTestName(true) + ".py");
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user