mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Renamed Callable.getReturnType() to getCallType()
This commit is contained in:
@@ -34,10 +34,10 @@ public interface Callable extends PyTypedElement, PyQualifiedNameOwner {
|
||||
PyParameterList getParameterList();
|
||||
|
||||
/**
|
||||
* @return the type of returned value.
|
||||
* Returns the type of the call to the callable.
|
||||
*/
|
||||
@Nullable
|
||||
PyType getReturnType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite);
|
||||
PyType getCallType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite);
|
||||
|
||||
/**
|
||||
* @return a methods returns itself, non-method callables return null.
|
||||
|
||||
@@ -225,7 +225,7 @@ public class PyOverrideImplementUtil {
|
||||
statementBody.append(PyNames.PASS);
|
||||
}
|
||||
else {
|
||||
if (!PyNames.INIT.equals(baseFunction.getName()) && baseFunction.getReturnType(context, null) != PyNoneType.INSTANCE) {
|
||||
if (!PyNames.INIT.equals(baseFunction.getName()) && baseFunction.getCallType(context, null) != PyNoneType.INSTANCE) {
|
||||
statementBody.append("return ");
|
||||
}
|
||||
if (baseClass.isNewStyleClass()) {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class PyUserSkeletonsTypeProvider extends PyTypeProviderBase {
|
||||
public PyType getReturnType(@NotNull PyFunction function, @Nullable PyQualifiedExpression callSite, @NotNull TypeEvalContext context) {
|
||||
final PyFunction functionSkeleton = PyUserSkeletonsUtil.getUserSkeleton(function);
|
||||
if (functionSkeleton != null) {
|
||||
return functionSkeleton.getReturnType(context, callSite);
|
||||
return functionSkeleton.getCallType(context, callSite);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public class PyPropertyDefinitionInspection extends PyInspection {
|
||||
}
|
||||
else {
|
||||
PyReferenceExpression callSite = being_checked instanceof PyReferenceExpression ? (PyReferenceExpression) being_checked : null;
|
||||
hasReturns = !(callable.getReturnType(myTypeEvalContext, callSite) instanceof PyNoneType);
|
||||
hasReturns = !(callable.getCallType(myTypeEvalContext, callSite) instanceof PyNoneType);
|
||||
}
|
||||
if (allowed ^ hasReturns) {
|
||||
if (allowed && callable instanceof PyFunction) {
|
||||
|
||||
@@ -149,7 +149,7 @@ public class PyStringFormatInspection extends PyInspection {
|
||||
}
|
||||
else if (rightExpression instanceof PyCallExpression) {
|
||||
final Callable callable = ((PyCallExpression)rightExpression).resolveCalleeFunction(resolveContext);
|
||||
// TODO: Switch to Callable.getReturnType()
|
||||
// TODO: Switch to Callable.getCallType()
|
||||
if (callable instanceof PyFunction && myTypeEvalContext.maySwitchToAST((PyFunction) callable)) {
|
||||
PyStatementList statementList = ((PyFunction)callable).getStatementList();
|
||||
if (statementList == null) {
|
||||
|
||||
@@ -137,7 +137,7 @@ public class PyBinaryExpressionImpl extends PyElementImpl implements PyBinaryExp
|
||||
}
|
||||
final PyTypeChecker.AnalyzeCallResults results = PyTypeChecker.analyzeCall(this, context);
|
||||
if (results != null) {
|
||||
final PyType type = results.getCallable().getReturnType(context, this);
|
||||
final PyType type = results.getCallable().getCallType(context, this);
|
||||
if (!PyTypeChecker.isUnknown(type) && !(type instanceof PyNoneType)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class PyCallExpressionHelper {
|
||||
final PyFunction function = (PyFunction)resolved;
|
||||
final Property property = function.getProperty();
|
||||
if (property != null && isQualifiedByInstance(function, qualifiers, context)) {
|
||||
final PyType type = function.getReturnType(context, null);
|
||||
final PyType type = function.getCallType(context, null);
|
||||
if (type instanceof PyFunctionType) {
|
||||
resolved = ((PyFunctionType)type).getCallable();
|
||||
}
|
||||
@@ -424,7 +424,7 @@ public class PyCallExpressionHelper {
|
||||
}
|
||||
}
|
||||
if (init != null) {
|
||||
final PyType t = init.getReturnType(context, (PyReferenceExpression)callee);
|
||||
final PyType t = init.getCallType(context, (PyReferenceExpression)callee);
|
||||
if (cls != null) {
|
||||
if (init.getContainingClass() != cls) {
|
||||
if (t instanceof PyCollectionType) {
|
||||
@@ -453,7 +453,7 @@ public class PyCallExpressionHelper {
|
||||
}
|
||||
if (target instanceof Callable) {
|
||||
final Callable callable = (Callable)target;
|
||||
return callable.getReturnType(context, (PyReferenceExpression)callee);
|
||||
return callable.getCallType(context, (PyReferenceExpression)callee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ public class PyClassImpl extends PyPresentableElementImpl<PyClassStub> implement
|
||||
if (!(callable instanceof StubBasedPsiElement) && !context.maySwitchToAST(callable)) {
|
||||
return null;
|
||||
}
|
||||
return callable.getReturnType(context, null);
|
||||
return callable.getCallType(context, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class PyFunctionImpl extends PyPresentableElementImpl<PyFunctionStub> imp
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PyType getReturnType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite) {
|
||||
public PyType getCallType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite) {
|
||||
PyType type = getGenericReturnType(context, callSite);
|
||||
if (callSite == null) {
|
||||
return type;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PyLambdaExpressionImpl extends PyElementImpl implements PyLambdaExp
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PyType getReturnType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite) {
|
||||
public PyType getCallType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite) {
|
||||
final PyExpression body = getBody();
|
||||
if (body != null) return context.getType(body);
|
||||
else return null;
|
||||
|
||||
@@ -208,7 +208,7 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
|
||||
PyType initType = null;
|
||||
final PyFunction init = containingClass.findInitOrNew(true);
|
||||
if (init != null && init != func) {
|
||||
initType = init.getReturnType(context, null);
|
||||
initType = init.getCallType(context, null);
|
||||
if (init.getContainingClass() != containingClass) {
|
||||
if (initType instanceof PyCollectionType) {
|
||||
final PyType elementType = ((PyCollectionType)initType).getElementType(context);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PyPrefixExpressionImpl extends PyElementImpl implements PyPrefixExp
|
||||
if (ref != null) {
|
||||
final PsiElement resolved = ref.resolve();
|
||||
if (resolved instanceof Callable) {
|
||||
return ((Callable)resolved).getReturnType(context, this);
|
||||
return ((Callable)resolved).getCallType(context, this);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PySubscriptionExpressionImpl extends PyElementImpl implements PySub
|
||||
if (ref != null) {
|
||||
final PsiElement resolved = ref.resolve();
|
||||
if (resolved instanceof Callable) {
|
||||
res = ((Callable)resolved).getReturnType(context, this);
|
||||
res = ((Callable)resolved).getCallType(context, this);
|
||||
}
|
||||
}
|
||||
if (PyTypeChecker.isUnknown(res) || res instanceof PyNoneType) {
|
||||
|
||||
@@ -441,7 +441,7 @@ public class PyTargetExpressionImpl extends PyPresentableElementImpl<PyTargetExp
|
||||
if (function instanceof PyFunctionImpl) {
|
||||
return ((PyFunctionImpl)function).getReturnTypeWithoutCallSite(context, source);
|
||||
}
|
||||
return function.getReturnType(context, null);
|
||||
return function.getCallType(context, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -48,13 +48,13 @@ public class PyFunctionType implements PyCallableType {
|
||||
@Override
|
||||
public PyType getReturnType(@NotNull TypeEvalContext context) {
|
||||
// TODO: Make Callable.getReturnType() call site independent, extract getCallType()
|
||||
return myCallable.getReturnType(context, null);
|
||||
return myCallable.getCallType(context, null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PyType getCallType(@NotNull TypeEvalContext context, @Nullable PyQualifiedExpression callSite) {
|
||||
return myCallable.getReturnType(context, callSite);
|
||||
return myCallable.getCallType(context, callSite);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.psi.PsiPolyVariantReference;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.ResolveResult;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.codeInsight.stdlib.PyStdlibTypeProvider;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.resolve.RatedResolveResult;
|
||||
@@ -352,7 +351,7 @@ public class PyTypeChecker {
|
||||
final PyFunction init = cls.findInitOrNew(true);
|
||||
// Unify generics in constructor
|
||||
if (init != null) {
|
||||
final PyType initType = init.getReturnType(context, null);
|
||||
final PyType initType = init.getCallType(context, null);
|
||||
if (initType != null) {
|
||||
match(initType, qualifierType, context, substitutions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user