mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Added TypeEvalContext.Key to PyTypedElement.getType to statically force type evaluation via TypeEvalContext only
This commit is contained in:
@@ -177,7 +177,7 @@ public class PyDynamicMember {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public PyType getType(@NotNull TypeEvalContext context) {
|
||||
public PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key) {
|
||||
if (myTypeCallback != null) {
|
||||
return myTypeCallback.fun(myContext);
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public interface PyTypedElement extends PyElement {
|
||||
@Nullable
|
||||
PyType getType(@NotNull TypeEvalContext context);
|
||||
PyType getType(@NotNull TypeEvalContext context, @NotNull TypeEvalContext.Key key);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PyTypeProviderBase implements PyTypeProvider {
|
||||
final ReturnTypeCallback typeCallback = myStringToReturnTypeMap.get(containingClass.getQualifiedName());
|
||||
if (typeCallback != null) {
|
||||
final PyExpression qualifier = callSite != null ? callSite.getQualifier() : null;
|
||||
PyType qualifierType = qualifier != null ? qualifier.getType(context) : null;
|
||||
PyType qualifierType = qualifier != null ? context.getType(qualifier) : null;
|
||||
return typeCallback.getType(callSite, qualifierType, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@ import java.util.*;
|
||||
* @author yole
|
||||
*/
|
||||
public class TypeEvalContext {
|
||||
public static class Key {
|
||||
private static final Key INSTANCE = new Key();
|
||||
|
||||
private Key() {}
|
||||
}
|
||||
|
||||
private final boolean myAllowDataFlow;
|
||||
private final boolean myAllowStubToAST;
|
||||
private List<String> myTrace;
|
||||
@@ -116,7 +122,7 @@ public class TypeEvalContext {
|
||||
}
|
||||
evaluating.add(element);
|
||||
try {
|
||||
PyType result = element.getType(this);
|
||||
PyType result = element.getType(this, Key.INSTANCE);
|
||||
if (result != null) {
|
||||
result.assertValid(element.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user