mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Mark callSite parameter in PyTypeProvider.getCallType as not null (PY-29577)
This commit is contained in:
@@ -45,7 +45,7 @@ public interface PyTypeProvider {
|
||||
Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context);
|
||||
|
||||
@Nullable
|
||||
Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context);
|
||||
Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context);
|
||||
|
||||
@Nullable
|
||||
PyType getContextManagerVariableType(PyClass contextManager, PyExpression withExpression, TypeEvalContext context);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class PyTypeProviderBase implements PyTypeProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
final ReturnTypeDescriptor descriptor;
|
||||
synchronized (myMethodToReturnTypeMap) {
|
||||
descriptor = myMethodToReturnTypeMap.get(function.getName());
|
||||
|
||||
@@ -203,7 +203,7 @@ public class NumpyDocStringTypeProvider extends PyTypeProviderBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
if (isApplicable(function)) {
|
||||
final PyExpression callee = callSite instanceof PyCallExpression ? ((PyCallExpression)callSite).getCallee() : null;
|
||||
final NumpyDocString docString = forFunction(function, callee);
|
||||
@@ -408,15 +408,6 @@ public class NumpyDocStringTypeProvider extends PyTypeProviderBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
|
||||
return Optional
|
||||
.ofNullable(PyUtil.as(callable, PyFunction.class))
|
||||
.map(function -> getCallType(function, null, context))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ref<PyType> getReferenceType(@NotNull PsiElement referenceTarget, @NotNull TypeEvalContext context, @Nullable PsiElement anchor) {
|
||||
if (referenceTarget instanceof PyFunction) {
|
||||
|
||||
@@ -132,7 +132,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
final String qname = function.getQualifiedName();
|
||||
if (qname != null) {
|
||||
if (OPEN_FUNCTIONS.contains(qname) && callSite instanceof PyCallExpression) {
|
||||
|
||||
@@ -374,7 +374,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
final String functionQName = function.getQualifiedName();
|
||||
|
||||
if ("typing.cast".equals(functionQName)) {
|
||||
|
||||
+2
-2
@@ -20,9 +20,9 @@ public final class PyCollectionTypeByModificationsProvider extends PyTypeProvide
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
String qualifiedName = function.getQualifiedName();
|
||||
if (qualifiedName != null && PyCollectionTypeUtil.INSTANCE.getCOLLECTION_CONSTRUCTORS().contains(qualifiedName) && callSite != null) {
|
||||
if (qualifiedName != null && PyCollectionTypeUtil.INSTANCE.getCOLLECTION_CONSTRUCTORS().contains(qualifiedName)) {
|
||||
PyExpression target = PyCollectionTypeUtil.INSTANCE.getTargetForValueInAssignment(callSite);
|
||||
if (target instanceof PyTargetExpression) {
|
||||
List<PyExpression> arguments = callSite.getArguments(null);
|
||||
|
||||
@@ -81,18 +81,14 @@ public class PyiTypeProvider extends PyTypeProviderBase {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
if (callSite != null) {
|
||||
final PsiElement pythonStub = PyiUtil.getPythonStub(function);
|
||||
public Ref<PyType> getCallType(@NotNull PyFunction function, @NotNull PyCallSiteExpression callSite, @NotNull TypeEvalContext context) {
|
||||
final PsiElement pythonStub = PyiUtil.getPythonStub(function);
|
||||
|
||||
if (pythonStub instanceof PyFunction) {
|
||||
return getOverloadedCallType((PyFunction)pythonStub, callSite, context);
|
||||
}
|
||||
|
||||
return getOverloadedCallType(function, callSite, context);
|
||||
if (pythonStub instanceof PyFunction) {
|
||||
return getOverloadedCallType((PyFunction)pythonStub, callSite, context);
|
||||
}
|
||||
|
||||
return null;
|
||||
return getOverloadedCallType(function, callSite, context);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user