From b5c92ae0ba1ee1964a0e18b02eb49ceafaf8679e Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Thu, 26 Feb 2015 13:27:06 +0300 Subject: [PATCH] Rename com.jetbrains.python.psi.Callable to PyCallable so as not to clash with java.util.concurrent.Callable --- .../com/jetbrains/python/psi/Property.java | 8 +-- .../python/psi/PyCallExpression.java | 8 +-- .../psi/{Callable.java => PyCallable.java} | 2 +- .../src/com/jetbrains/python/psi/PyClass.java | 2 +- .../com/jetbrains/python/psi/PyFunction.java | 2 +- .../python/psi/PyLambdaExpression.java | 2 +- .../python/psi/impl/PyTypeProvider.java | 4 +- .../python/psi/types/PyTypeProviderBase.java | 4 +- .../python/psi/types/TypeEvalContext.java | 14 ++--- .../NumpyDocStringTypeProvider.java | 2 +- .../com/jetbrains/pyqt/PyQtTypeProvider.java | 6 +- .../python/PyParameterInfoHandler.java | 2 +- .../codeInsight/PyTypingTypeProvider.java | 2 +- .../SpecifyTypeInDocstringIntention.java | 2 +- .../SpecifyTypeInPy3AnnotationsIntention.java | 2 +- .../codeInsight/intentions/TypeIntention.java | 4 +- .../stdlib/PyStdlibTypeProvider.java | 2 +- .../PyUserSkeletonsTypeProvider.java | 13 ++-- .../documentation/PyDocumentationBuilder.java | 4 +- .../PyArgumentEqualDefaultInspection.java | 4 +- .../inspections/PyArgumentListInspection.java | 4 +- .../inspections/PyCallByClassInspection.java | 2 +- .../PyNoneFunctionAssignmentInspection.java | 2 +- .../PyPropertyAccessInspection.java | 2 +- .../PyPropertyDefinitionInspection.java | 18 +++--- .../inspections/PyStringFormatInspection.java | 5 +- .../PyUnusedLocalInspectionVisitor.java | 4 +- .../PyUpdatePropertySignatureQuickFix.java | 2 +- .../PyUnresolvedReferencesInspection.java | 2 +- .../python/patterns/PythonPatterns.java | 6 +- .../src/com/jetbrains/python/psi/PyUtil.java | 10 +-- .../psi/impl/PyCallExpressionHelper.java | 28 ++++----- .../python/psi/impl/PyCallExpressionImpl.java | 5 +- .../python/psi/impl/PyClassImpl.java | 62 +++++++++---------- .../python/psi/impl/PyDecoratorImpl.java | 2 +- .../psi/impl/PyPrefixExpressionImpl.java | 4 +- .../impl/PySubscriptionExpressionImpl.java | 4 +- .../PyOverridingMethodsSearchExecutor.java | 2 +- .../search/PySuperMethodsSearchExecutor.java | 2 +- .../python/psi/types/PyClassTypeImpl.java | 4 +- .../python/psi/types/PyFunctionType.java | 8 +-- .../python/psi/types/PyTypeChecker.java | 12 ++-- .../membersManager/PropertiesManager.java | 12 ++-- .../rename/RenamePyFunctionProcessor.java | 4 +- .../env/python/PythonSkeletonsTest.java | 2 +- .../python/PyClassicPropertyTest.java | 8 +-- .../python/PyDecoratedPropertyTest.java | 6 +- .../com/jetbrains/python/PyStubsTest.java | 4 +- 48 files changed, 159 insertions(+), 156 deletions(-) rename python/psi-api/src/com/jetbrains/python/psi/{Callable.java => PyCallable.java} (96%) diff --git a/python/psi-api/src/com/jetbrains/python/psi/Property.java b/python/psi-api/src/com/jetbrains/python/psi/Property.java index d5b1c4e4a5ff..1d3084dc02ef 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/Property.java +++ b/python/psi-api/src/com/jetbrains/python/psi/Property.java @@ -35,19 +35,19 @@ public interface Property { * @return the setter: a method or null if defined, or something else callable if undefined. */ @NotNull - Maybe getSetter(); + Maybe getSetter(); /** * @return the getter: a method or null if defined, or something else callable if undefined. */ @NotNull - Maybe getGetter(); + Maybe getGetter(); /** * @return the deleter: a method or null if defined, or something else callable if undefined. */ @NotNull - Maybe getDeleter(); + Maybe getDeleter(); /** * @return doc string as known to property() call. If null, see getter's doc. @@ -66,7 +66,7 @@ public interface Property { * @return getter, setter, or deleter. */ @NotNull - Maybe getByDirection(@NotNull AccessDirection direction); + Maybe getByDirection(@NotNull AccessDirection direction); /** * Get the return type of the property getter. diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java b/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java index fab3b1cb8277..a2e0a1cb6a42 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyCallExpression.java @@ -104,7 +104,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param resolveContext the reference resolve context */ @Nullable - Callable resolveCalleeFunction(PyResolveContext resolveContext); + PyCallable resolveCalleeFunction(PyResolveContext resolveContext); /** * @@ -135,7 +135,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * Couples function with a flag describing the way it is called. */ class PyMarkedCallee { - @NotNull final Callable myCallable; + @NotNull final PyCallable myCallable; PyFunction.Modifier myModifier; int myImplicitOffset; boolean myImplicitlyResolved; @@ -148,7 +148,7 @@ public interface PyCallExpression extends PyCallSiteExpression { * @param offset implicit argument offset; parameters up to this are implicitly filled in the call. * @param implicitlyResolved value for {@link #isImplicitlyResolved()} */ - public PyMarkedCallee(@NotNull Callable function, PyFunction.Modifier modifier, int offset, boolean implicitlyResolved) { + public PyMarkedCallee(@NotNull PyCallable function, PyFunction.Modifier modifier, int offset, boolean implicitlyResolved) { myCallable = function; myModifier = modifier; myImplicitOffset = offset; @@ -156,7 +156,7 @@ public interface PyCallExpression extends PyCallSiteExpression { } @NotNull - public Callable getCallable() { + public PyCallable getCallable() { return myCallable; } diff --git a/python/psi-api/src/com/jetbrains/python/psi/Callable.java b/python/psi-api/src/com/jetbrains/python/psi/PyCallable.java similarity index 96% rename from python/psi-api/src/com/jetbrains/python/psi/Callable.java rename to python/psi-api/src/com/jetbrains/python/psi/PyCallable.java index 94972120cd83..5f64cc638a70 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/Callable.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyCallable.java @@ -27,7 +27,7 @@ import java.util.Map; * @author dcheryasov */ -public interface Callable extends PyTypedElement, PyQualifiedNameOwner { +public interface PyCallable extends PyTypedElement, PyQualifiedNameOwner { /** * @return a list of parameters passed to this callable, possibly empty. diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyClass.java b/python/psi-api/src/com/jetbrains/python/psi/PyClass.java index 4abdca72a436..3a0e20c56258 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyClass.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyClass.java @@ -215,7 +215,7 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, NameDefine * @return the property, or null */ @Nullable - Property findPropertyByCallable(Callable callable); + Property findPropertyByCallable(PyCallable callable); /** * @param parent diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyFunction.java b/python/psi-api/src/com/jetbrains/python/psi/PyFunction.java index 7337c756eb88..afd1bfcb543c 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyFunction.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyFunction.java @@ -36,7 +36,7 @@ import java.util.List; public interface PyFunction extends PsiNamedElement, StubBasedPsiElement, - PsiNameIdentifierOwner, PyStatement, Callable, NameDefiner, PyDocStringOwner, ScopeOwner, PyDecoratable, PyTypedElement, + PsiNameIdentifierOwner, PyStatement, PyCallable, NameDefiner, PyDocStringOwner, ScopeOwner, PyDecoratable, PyTypedElement, PyStatementListContainer{ PyFunction[] EMPTY_ARRAY = new PyFunction[0]; diff --git a/python/psi-api/src/com/jetbrains/python/psi/PyLambdaExpression.java b/python/psi-api/src/com/jetbrains/python/psi/PyLambdaExpression.java index fff5774abe06..e19e7f1dcec4 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/PyLambdaExpression.java +++ b/python/psi-api/src/com/jetbrains/python/psi/PyLambdaExpression.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; /** * @author yole */ -public interface PyLambdaExpression extends PyExpression, Callable, ScopeOwner { +public interface PyLambdaExpression extends PyExpression, PyCallable, ScopeOwner { @Nullable PyExpression getBody(); } diff --git a/python/psi-api/src/com/jetbrains/python/psi/impl/PyTypeProvider.java b/python/psi-api/src/com/jetbrains/python/psi/impl/PyTypeProvider.java index 614bf2703aec..e60a5ce19c4d 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/impl/PyTypeProvider.java +++ b/python/psi-api/src/com/jetbrains/python/psi/impl/PyTypeProvider.java @@ -39,7 +39,7 @@ public interface PyTypeProvider { PyType getParameterType(@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull TypeEvalContext context); @Nullable - PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context); + PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context); @Nullable PyType getCallType(@NotNull PyFunction function, @Nullable PyCallSiteExpression callSite, @NotNull TypeEvalContext context); @@ -48,5 +48,5 @@ public interface PyTypeProvider { PyType getContextManagerVariableType(PyClass contextManager, PyExpression withExpression, TypeEvalContext context); @Nullable - PyType getCallableType(@NotNull Callable callable, @NotNull TypeEvalContext context); + PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context); } diff --git a/python/psi-api/src/com/jetbrains/python/psi/types/PyTypeProviderBase.java b/python/psi-api/src/com/jetbrains/python/psi/types/PyTypeProviderBase.java index 368059138d9f..00768cdd69af 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/types/PyTypeProviderBase.java +++ b/python/psi-api/src/com/jetbrains/python/psi/types/PyTypeProviderBase.java @@ -98,7 +98,7 @@ public class PyTypeProviderBase implements PyTypeProvider { @Nullable @Override - public PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { return null; } @@ -123,7 +123,7 @@ public class PyTypeProviderBase implements PyTypeProvider { @Nullable @Override - public PyType getCallableType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { return null; } diff --git a/python/psi-api/src/com/jetbrains/python/psi/types/TypeEvalContext.java b/python/psi-api/src/com/jetbrains/python/psi/types/TypeEvalContext.java index 41a2a16c82cb..71655096756b 100644 --- a/python/psi-api/src/com/jetbrains/python/psi/types/TypeEvalContext.java +++ b/python/psi-api/src/com/jetbrains/python/psi/types/TypeEvalContext.java @@ -19,7 +19,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; -import com.jetbrains.python.psi.Callable; +import com.jetbrains.python.psi.PyCallable; import com.jetbrains.python.psi.PyTypedElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,17 +51,17 @@ public class TypeEvalContext { private String myTraceIndent = ""; private final Map myEvaluated = new HashMap(); - private final Map myEvaluatedReturn = new HashMap(); + private final Map myEvaluatedReturn = new HashMap(); private final ThreadLocal> myEvaluating = new ThreadLocal>() { @Override protected Set initialValue() { return new HashSet(); } }; - private final ThreadLocal> myEvaluatingReturn = new ThreadLocal>() { + private final ThreadLocal> myEvaluatingReturn = new ThreadLocal>() { @Override - protected Set initialValue() { - return new HashSet(); + protected Set initialValue() { + return new HashSet(); } }; @@ -203,8 +203,8 @@ public class TypeEvalContext { } @Nullable - public PyType getReturnType(@NotNull final Callable callable) { - final Set evaluating = myEvaluatingReturn.get(); + public PyType getReturnType(@NotNull final PyCallable callable) { + final Set evaluating = myEvaluatingReturn.get(); if (evaluating.contains(callable)) { return null; } diff --git a/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java b/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java index a0e196237cc7..2d6dcb6a7379 100644 --- a/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java +++ b/python/src/com/jetbrains/numpy/codeInsight/NumpyDocStringTypeProvider.java @@ -173,7 +173,7 @@ public class NumpyDocStringTypeProvider extends PyTypeProviderBase { @Nullable @Override - public PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { if (callable instanceof PyFunction) { return getCallType((PyFunction)callable, null, context); } diff --git a/python/src/com/jetbrains/pyqt/PyQtTypeProvider.java b/python/src/com/jetbrains/pyqt/PyQtTypeProvider.java index 179f81ceb9c0..3ee223aea642 100644 --- a/python/src/com/jetbrains/pyqt/PyQtTypeProvider.java +++ b/python/src/com/jetbrains/pyqt/PyQtTypeProvider.java @@ -17,7 +17,7 @@ package com.jetbrains.pyqt; import com.intellij.psi.util.QualifiedName; import com.jetbrains.python.PyNames; -import com.jetbrains.python.psi.Callable; +import com.jetbrains.python.psi.PyCallable; import com.jetbrains.python.psi.PyClass; import com.jetbrains.python.psi.PyFunction; import com.jetbrains.python.psi.stubs.PyClassNameIndex; @@ -36,7 +36,7 @@ public class PyQtTypeProvider extends PyTypeProviderBase { private static final String ourQt4Signal = "pyqtSignal"; @Override - public PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { if (PyNames.INIT.equals(callable.getName()) && callable instanceof PyFunction) { final PyFunction function = (PyFunction)callable; final PyClass containingClass = function.getContainingClass(); @@ -56,7 +56,7 @@ public class PyQtTypeProvider extends PyTypeProviderBase { @Nullable @Override - public PyType getCallableType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { if (callable instanceof PyFunction) { final String qualifiedName = callable.getQualifiedName(); if (qualifiedName != null && qualifiedName.startsWith("PyQt")){ diff --git a/python/src/com/jetbrains/python/PyParameterInfoHandler.java b/python/src/com/jetbrains/python/PyParameterInfoHandler.java index 2fbf151b3f7e..28ab2002f027 100644 --- a/python/src/com/jetbrains/python/PyParameterInfoHandler.java +++ b/python/src/com/jetbrains/python/PyParameterInfoHandler.java @@ -135,7 +135,7 @@ public class PyParameterInfoHandler implements ParameterInfoHandler parameterList = PyUtil.getParameters(callable, typeEvalContext); final List namedParameters = new ArrayList(parameterList.size()); diff --git a/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java index f03befac6c14..92212f6d8f8f 100644 --- a/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/PyTypingTypeProvider.java @@ -65,7 +65,7 @@ public class PyTypingTypeProvider extends PyTypeProviderBase { @Nullable @Override - public PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { if (callable instanceof PyFunction) { final PyFunction function = (PyFunction)callable; final PyAnnotation annotation = function.getAnnotation(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java index ce47f358ffce..25242e4d2945 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInDocstringIntention.java @@ -62,7 +62,7 @@ public class SpecifyTypeInDocstringIntention extends TypeIntention { PyParameter parameter = getParameter(problemElement, resolved); String kind = parameter != null ? "type" : "rtype"; - final Callable callable; + final PyCallable callable; if (parameter != null) { callable = PsiTreeUtil.getParentOfType(parameter, PyFunction.class); } diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java index db54d2d96d38..a1e22b488264 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/SpecifyTypeInPy3AnnotationsIntention.java @@ -102,7 +102,7 @@ public class SpecifyTypeInPy3AnnotationsIntention extends TypeIntention { private void annotateReturnType(Project project, PsiElement resolved) { PyElementGenerator elementGenerator = PyElementGenerator.getInstance(project); - Callable callable = getCallable(resolved); + PyCallable callable = getCallable(resolved); if (callable instanceof PyFunction) { final String functionSignature = "def " + callable.getName() + callable.getParameterList().getText(); diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java index 025318fb2424..f5197ecc8ba7 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/TypeIntention.java @@ -169,11 +169,11 @@ public abstract class TypeIntention implements IntentionAction { } @Nullable - protected Callable getCallable(PsiElement elementAt) { + protected PyCallable getCallable(PsiElement elementAt) { PyCallExpression callExpression = getCallExpression(elementAt); if (callExpression != null && elementAt != null) { - final Callable callable = callExpression.resolveCalleeFunction(getResolveContext(elementAt)); + final PyCallable callable = callExpression.resolveCalleeFunction(getResolveContext(elementAt)); return callable == null ? PsiTreeUtil.getParentOfType(elementAt, PyFunction.class) : callable; } return PsiTreeUtil.getParentOfType(elementAt, PyFunction.class); diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index 7ab4b1a395a4..4359ada93bce 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -235,7 +235,7 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { final PyCallExpression call = (PyCallExpression)value; final PyCallExpression.PyMarkedCallee callee = call.resolveCallee(PyResolveContext.noImplicits()); if (callee != null) { - final Callable callable = callee.getCallable(); + final PyCallable callable = callee.getCallable(); if (PyNames.COLLECTIONS_NAMEDTUPLE.equals(callable.getQualifiedName())) { return PyNamedTupleType.fromCall(call, 1); } diff --git a/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsTypeProvider.java b/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsTypeProvider.java index 71591669c2dc..16f7f59fcb5e 100644 --- a/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsTypeProvider.java +++ b/python/src/com/jetbrains/python/codeInsight/userSkeletons/PyUserSkeletonsTypeProvider.java @@ -16,7 +16,10 @@ package com.jetbrains.python.codeInsight.userSkeletons; import com.intellij.psi.PsiElement; -import com.jetbrains.python.psi.*; +import com.jetbrains.python.psi.PyCallable; +import com.jetbrains.python.psi.PyFunction; +import com.jetbrains.python.psi.PyNamedParameter; +import com.jetbrains.python.psi.PyTargetExpression; import com.jetbrains.python.psi.types.PyType; import com.jetbrains.python.psi.types.PyTypeProviderBase; import com.jetbrains.python.psi.types.TypeEvalContext; @@ -44,8 +47,8 @@ public class PyUserSkeletonsTypeProvider extends PyTypeProviderBase { @Nullable @Override - public PyType getReturnType(@NotNull Callable callable, @NotNull TypeEvalContext context) { - final Callable callableSkeleton = PyUserSkeletonsUtil.getUserSkeleton(callable); + public PyType getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { + final PyCallable callableSkeleton = PyUserSkeletonsUtil.getUserSkeleton(callable); if (callableSkeleton != null) { return context.getReturnType(callableSkeleton); } @@ -65,8 +68,8 @@ public class PyUserSkeletonsTypeProvider extends PyTypeProviderBase { @Nullable @Override - public PyType getCallableType(@NotNull Callable callable, @NotNull TypeEvalContext context) { - final Callable callableSkeleton = PyUserSkeletonsUtil.getUserSkeleton(callable); + public PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { + final PyCallable callableSkeleton = PyUserSkeletonsUtil.getUserSkeleton(callable); if (callableSkeleton != null) { return context.getType(callableSkeleton); } diff --git a/python/src/com/jetbrains/python/documentation/PyDocumentationBuilder.java b/python/src/com/jetbrains/python/documentation/PyDocumentationBuilder.java index 962b2eff227b..ee28f45e0364 100644 --- a/python/src/com/jetbrains/python/documentation/PyDocumentationBuilder.java +++ b/python/src/com/jetbrains/python/documentation/PyDocumentationBuilder.java @@ -99,7 +99,7 @@ class PyDocumentationBuilder { if (property != null) { is_property = true; final AccessDirection dir = AccessDirection.of((PyElement)outer); - Maybe accessor = property.getByDirection(dir); + Maybe accessor = property.getByDirection(dir); myProlog .addItem("property ").addWith(TagBold, $().addWith(TagCode, $(elementName))) .addItem(" of ").add(PythonDocumentationProvider.describeClass(cls, TagCode, true, true)) @@ -108,7 +108,7 @@ class PyDocumentationBuilder { myBody.addItem(": ").addItem(property.getDoc()).addItem(BR); } else { - final Callable getter = property.getGetter().valueOrNull(); + final PyCallable getter = property.getGetter().valueOrNull(); if (getter != null && getter != myElement && getter instanceof PyFunction) { // not in getter, getter's doc comment may be useful PyStringLiteralExpression docstring = ((PyFunction)getter).getDocStringExpression(); diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java index 81746f1c6760..e2c51d1b5ab7 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java @@ -73,7 +73,7 @@ public class PyArgumentEqualDefaultInspection extends PyInspection { if (list == null) { return; } - Callable func = node.resolveCalleeFunction(getResolveContext()); + PyCallable func = node.resolveCalleeFunction(getResolveContext()); if (func != null && hasSpecialCasedDefaults(func, node)) { return; } @@ -81,7 +81,7 @@ public class PyArgumentEqualDefaultInspection extends PyInspection { checkArguments(result, node.getArguments()); } - private static boolean hasSpecialCasedDefaults(Callable callable, PsiElement anchor) { + private static boolean hasSpecialCasedDefaults(PyCallable callable, PsiElement anchor) { final String name = callable.getName(); final PyBuiltinCache cache = PyBuiltinCache.getInstance(anchor); if ("getattr".equals(name) && cache.isBuiltin(callable)) { diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java index ab5dbac29eb8..320ca265f72a 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java @@ -78,7 +78,7 @@ public class PyArgumentListInspection extends PyInspection { if (deco.hasArgumentList()) continue; final PyCallExpression.PyMarkedCallee markedCallee = deco.resolveCallee(getResolveContext()); if (markedCallee != null && !markedCallee.isImplicitlyResolved()) { - final Callable callable = markedCallee.getCallable(); + final PyCallable callable = markedCallee.getCallable(); int firstParamOffset = markedCallee.getImplicitOffset(); final List params = PyUtil.getParameters(callable, myTypeEvalContext); final PyNamedParameter allegedFirstParam = params.size() < firstParamOffset ? @@ -111,7 +111,7 @@ public class PyArgumentListInspection extends PyInspection { CallArgumentsMapping result = node.analyzeCall(PyResolveContext.noImplicits().withTypeEvalContext(context), implicitOffset); final PyCallExpression.PyMarkedCallee callee = result.getMarkedCallee(); if (callee != null) { - final Callable callable = callee.getCallable(); + final PyCallable callable = callee.getCallable(); // Decorate functions may have different parameter lists. We don't match arguments with parameters of decorators yet if (callable instanceof PyFunction && PyUtil.hasCustomDecorators((PyFunction)callable)) { return; diff --git a/python/src/com/jetbrains/python/inspections/PyCallByClassInspection.java b/python/src/com/jetbrains/python/inspections/PyCallByClassInspection.java index 772c7219e6a9..c9ebf1f25e83 100644 --- a/python/src/com/jetbrains/python/inspections/PyCallByClassInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyCallByClassInspection.java @@ -114,7 +114,7 @@ public class PyCallByClassInspection extends PyInspection { if (first_arg_class != qual_class) { // delegating to a parent is fine if (markedCallee.getCallable() instanceof PyFunction) { - Callable callable = PsiTreeUtil.getParentOfType(call, Callable.class); + PyCallable callable = PsiTreeUtil.getParentOfType(call, PyCallable.class); if (callable != null) { PyFunction method = callable.asMethod(); if (method != null) { diff --git a/python/src/com/jetbrains/python/inspections/PyNoneFunctionAssignmentInspection.java b/python/src/com/jetbrains/python/inspections/PyNoneFunctionAssignmentInspection.java index 9ba96950e2e2..8237d5cbc969 100644 --- a/python/src/com/jetbrains/python/inspections/PyNoneFunctionAssignmentInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyNoneFunctionAssignmentInspection.java @@ -74,7 +74,7 @@ public class PyNoneFunctionAssignmentInspection extends PyInspection { if (type instanceof PyNoneType && callee != null) { final PyTypeChecker.AnalyzeCallResults analyzeCallResults = PyTypeChecker.analyzeCall(((PyCallExpression)value), myTypeEvalContext); if (analyzeCallResults != null) { - final Callable callable = analyzeCallResults.getCallable(); + final PyCallable callable = analyzeCallResults.getCallable(); if (PySdkUtil.isElementInSkeletons(callable)) { return; } diff --git a/python/src/com/jetbrains/python/inspections/PyPropertyAccessInspection.java b/python/src/com/jetbrains/python/inspections/PyPropertyAccessInspection.java index 68b74b6c3897..36cfea4589ce 100644 --- a/python/src/com/jetbrains/python/inspections/PyPropertyAccessInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyPropertyAccessInspection.java @@ -106,7 +106,7 @@ public class PyPropertyAccessInspection extends PyInspection { } private void checkAccessor(PyExpression node, String name, AccessDirection dir, Property property) { - final Maybe accessor = property.getByDirection(dir); + final Maybe accessor = property.getByDirection(dir); if (accessor.isDefined() && accessor.value() == null) { final String message; if (dir == AccessDirection.WRITE) { diff --git a/python/src/com/jetbrains/python/inspections/PyPropertyDefinitionInspection.java b/python/src/com/jetbrains/python/inspections/PyPropertyDefinitionInspection.java index e52134dbfad9..fa76714f1546 100644 --- a/python/src/com/jetbrains/python/inspections/PyPropertyDefinitionInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyPropertyDefinitionInspection.java @@ -130,7 +130,7 @@ public class PyPropertyDefinitionInspection extends PyInspection { else { // @property; we only check getter, others are checked by visitPyFunction // getter is always present with this form - final Callable callable = property.getGetter().valueOrNull(); + final PyCallable callable = property.getGetter().valueOrNull(); if (callable instanceof PyFunction) { checkGetter(callable, getFunctionMarkingElement((PyFunction)callable)); } @@ -142,12 +142,12 @@ public class PyPropertyDefinitionInspection extends PyInspection { private void checkPropertyCallArgument(String paramName, PyExpression argument, PsiFile containingFile) { assert argument != null : "Parameter mapped to null argument"; - Callable callable = null; + PyCallable callable = null; if (argument instanceof PyReferenceExpression) { final PsiPolyVariantReference reference = ((PyReferenceExpression)argument).getReference(getResolveContext()); PsiElement resolved = reference.resolve(); - if (resolved instanceof Callable) { - callable = (Callable)resolved; + if (resolved instanceof PyCallable) { + callable = (PyCallable)resolved; } else { reportNonCallableArg(resolved, argument); @@ -246,14 +246,14 @@ public class PyPropertyDefinitionInspection extends PyInspection { } - private void checkGetter(Callable callable, PsiElement beingChecked) { + private void checkGetter(PyCallable callable, PsiElement beingChecked) { if (callable != null) { checkOneParameter(callable, beingChecked, true); checkReturnValueAllowed(callable, beingChecked, true, PyBundle.message("INSP.getter.return.smth")); } } - private void checkSetter(Callable callable, PsiElement beingChecked) { + private void checkSetter(PyCallable callable, PsiElement beingChecked) { if (callable != null) { // signature: at least two params, more optionals ok; first arg 'self' final PyParameterList paramList = callable.getParameterList(); @@ -266,14 +266,14 @@ public class PyPropertyDefinitionInspection extends PyInspection { } } - private void checkDeleter(Callable callable, PsiElement beingChecked) { + private void checkDeleter(PyCallable callable, PsiElement beingChecked) { if (callable != null) { checkOneParameter(callable, beingChecked, false); checkReturnValueAllowed(callable, beingChecked, false, PyBundle.message("INSP.deleter.should.not.return")); } } - private void checkOneParameter(Callable callable, PsiElement beingChecked, boolean isGetter) { + private void checkOneParameter(PyCallable callable, PsiElement beingChecked, boolean isGetter) { final PyParameterList parameterList = callable.getParameterList(); if (myOneParamFunction != null && !PyUtil.isSignatureCompatibleTo(callable, myOneParamFunction, myTypeEvalContext)) { if (isGetter) { @@ -299,7 +299,7 @@ public class PyPropertyDefinitionInspection extends PyInspection { } } - private void checkReturnValueAllowed(Callable callable, PsiElement beingChecked, boolean allowed, String message) { + private void checkReturnValueAllowed(PyCallable callable, PsiElement beingChecked, boolean allowed, String message) { // TODO: use a real flow analysis to check all exit points boolean hasReturns; if (callable instanceof PyFunction) { diff --git a/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java b/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java index 187803f4cfa3..fa9e6cfbe14f 100644 --- a/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyStringFormatInspection.java @@ -25,7 +25,6 @@ import com.intellij.psi.PsiFile; import com.intellij.util.containers.HashMap; import com.jetbrains.python.PyBundle; import com.jetbrains.python.PyNames; -import com.jetbrains.python.PyTokenTypes; import com.jetbrains.python.inspections.quickfix.PyAddSpecifierToFormatQuickFix; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.impl.PyBuiltinCache; @@ -137,8 +136,8 @@ public class PyStringFormatInspection extends PyInspection { return inspectArguments((PyExpression)pyElement, problemTarget); } else if (rightExpression instanceof PyCallExpression) { - final Callable callable = ((PyCallExpression)rightExpression).resolveCalleeFunction(resolveContext); - // TODO: Switch to Callable.getCallType() + final PyCallable callable = ((PyCallExpression)rightExpression).resolveCalleeFunction(resolveContext); + // TODO: Switch to PyCallable.getCallType() if (callable instanceof PyFunction && myTypeEvalContext.maySwitchToAST(callable)) { PyStatementList statementList = ((PyFunction)callable).getStatementList(); PyReturnStatement[] returnStatements = PyUtil.getAllChildrenOfType(statementList, PyReturnStatement.class); diff --git a/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java b/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java index ee23f5adccc6..14e5c78e8c81 100644 --- a/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java +++ b/python/src/com/jetbrains/python/inspections/PyUnusedLocalInspectionVisitor.java @@ -275,7 +275,7 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor { if (namedParameter.isSelf()) { continue; } - if (myIgnoreLambdaParameters && PsiTreeUtil.getParentOfType(element, Callable.class) instanceof PyLambdaExpression) { + if (myIgnoreLambdaParameters && PsiTreeUtil.getParentOfType(element, PyCallable.class) instanceof PyLambdaExpression) { continue; } boolean mayBeField = false; @@ -341,7 +341,7 @@ public class PyUnusedLocalInspectionVisitor extends PyInspectionVisitor { } PyCallExpression expr = (PyCallExpression) source; if (expr.isCalleeText("range", "xrange")) { - final Callable callee = expr.resolveCalleeFunction(PyResolveContext.noImplicits().withTypeEvalContext(myTypeEvalContext)); + final PyCallable callee = expr.resolveCalleeFunction(PyResolveContext.noImplicits().withTypeEvalContext(myTypeEvalContext)); if (callee != null && PyBuiltinCache.getInstance(forStatement).isBuiltin(callee)) { return true; } diff --git a/python/src/com/jetbrains/python/inspections/quickfix/PyUpdatePropertySignatureQuickFix.java b/python/src/com/jetbrains/python/inspections/quickfix/PyUpdatePropertySignatureQuickFix.java index a02a02ab9cdc..c737e16df572 100644 --- a/python/src/com/jetbrains/python/inspections/quickfix/PyUpdatePropertySignatureQuickFix.java +++ b/python/src/com/jetbrains/python/inspections/quickfix/PyUpdatePropertySignatureQuickFix.java @@ -46,7 +46,7 @@ public class PyUpdatePropertySignatureQuickFix implements LocalQuickFix { @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); - final Callable function = PsiTreeUtil.getParentOfType(element, Callable.class, false); + final PyCallable function = PsiTreeUtil.getParentOfType(element, PyCallable.class, false); assert function != null; final PyParameterList parameterList = function.getParameterList(); final PyParameter[] parameters = parameterList.getParameters(); diff --git a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java index 693b8dce7a47..4c8391ef689d 100644 --- a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java +++ b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java @@ -743,7 +743,7 @@ public class PyUnresolvedReferencesInspection extends PyInspection { if (hasUnresolvedDynamicMember((PyClassType)type, reference, name)) return true; } if (type instanceof PyFunctionType) { - final Callable callable = ((PyFunctionType)type).getCallable(); + final PyCallable callable = ((PyFunctionType)type).getCallable(); if (callable instanceof PyFunction && PyKnownDecoratorUtil.hasNonBuiltinDecorator((PyFunction)callable, myTypeEvalContext)) { return true; } diff --git a/python/src/com/jetbrains/python/patterns/PythonPatterns.java b/python/src/com/jetbrains/python/patterns/PythonPatterns.java index 3f2263b27f4b..5f7d6b9ca64a 100644 --- a/python/src/com/jetbrains/python/patterns/PythonPatterns.java +++ b/python/src/com/jetbrains/python/patterns/PythonPatterns.java @@ -70,7 +70,7 @@ public class PythonPatterns extends PlatformPatterns { public static PyElementPattern.Capture pyModuleFunctionArgument(final String functionName, final int index, final String moduleName) { return new PyElementPattern.Capture(new InitialPatternCondition(PyExpression.class) { public boolean accepts(@Nullable final Object o, final ProcessingContext context) { - Callable function = resolveCalledFunction(o, functionName, index); + PyCallable function = resolveCalledFunction(o, functionName, index); if (!(function instanceof PyFunction)) { return false; } @@ -86,7 +86,7 @@ public class PythonPatterns extends PlatformPatterns { public static PyElementPattern.Capture pyMethodArgument(final String functionName, final int index, final String classQualifiedName) { return new PyElementPattern.Capture(new InitialPatternCondition(PyExpression.class) { public boolean accepts(@Nullable final Object o, final ProcessingContext context) { - Callable function = resolveCalledFunction(o, functionName, index); + PyCallable function = resolveCalledFunction(o, functionName, index); if (!(function instanceof PyFunction)) { return false; } @@ -99,7 +99,7 @@ public class PythonPatterns extends PlatformPatterns { }); } - private static Callable resolveCalledFunction(Object o, String functionName, int index) { + private static PyCallable resolveCalledFunction(Object o, String functionName, int index) { if (!isCallArgument(o, functionName, index)) { return null; } diff --git a/python/src/com/jetbrains/python/psi/PyUtil.java b/python/src/com/jetbrains/python/psi/PyUtil.java index 7de9741b4a16..316f7feb9eb1 100644 --- a/python/src/com/jetbrains/python/psi/PyUtil.java +++ b/python/src/com/jetbrains/python/psi/PyUtil.java @@ -1081,7 +1081,7 @@ public class PyUtil { PsiElement parent = PsiTreeUtil.getStubOrPsiParent(elt); boolean jump_over = false; while (parent != null) { - if (parent instanceof PyClass || parent instanceof Callable) { + if (parent instanceof PyClass || parent instanceof PyCallable) { if (jump_over) { jump_over = false; } @@ -1599,7 +1599,7 @@ public class PyUtil { } @NotNull - public static List getParameters(@NotNull Callable callable, @NotNull TypeEvalContext context) { + public static List getParameters(@NotNull PyCallable callable, @NotNull TypeEvalContext context) { PyType type = context.getType(callable); if (type instanceof PyUnionType) { type = ((PyUnionType)type).excludeNull(context); @@ -1626,7 +1626,7 @@ public class PyUtil { return Arrays.asList(callable.getParameterList().getParameters()); } - public static boolean isSignatureCompatibleTo(@NotNull Callable callable, @NotNull Callable otherCallable, + public static boolean isSignatureCompatibleTo(@NotNull PyCallable callable, @NotNull PyCallable otherCallable, @NotNull TypeEvalContext context) { final List parameters = getParameters(callable, context); final List otherParameters = getParameters(otherCallable, context); @@ -1655,11 +1655,11 @@ public class PyUtil { return n; } - private static int requiredParametersCount(@NotNull Callable callable, @NotNull List parameters) { + private static int requiredParametersCount(@NotNull PyCallable callable, @NotNull List parameters) { return parameters.size() - optionalParametersCount(parameters) - specialParametersCount(callable, parameters); } - private static int specialParametersCount(@NotNull Callable callable, @NotNull List parameters) { + private static int specialParametersCount(@NotNull PyCallable callable, @NotNull List parameters) { int n = 0; if (hasPositionalContainer(parameters)) { n++; diff --git a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java index 13c8a417c8ca..c070311d5a17 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java +++ b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java @@ -128,7 +128,7 @@ public class PyCallExpressionHelper { } @Nullable - public static Callable resolveCalleeFunction(PyCallExpression call, PyResolveContext resolveContext) { + public static PyCallable resolveCalleeFunction(PyCallExpression call, PyResolveContext resolveContext) { PsiElement resolved; PyExpression callee = call.getCallee(); if (callee instanceof PyReferenceExpression) { @@ -150,8 +150,8 @@ public class PyCallExpressionHelper { resolved = wrapperInfo.getSecond(); } } - if (resolved instanceof Callable) { - return (Callable)resolved; + if (resolved instanceof PyCallable) { + return (PyCallable)resolved; } return null; } @@ -215,18 +215,18 @@ public class PyCallExpressionHelper { } } } - if (resolved instanceof Callable) { + if (resolved instanceof PyCallable) { PyFunction.Modifier modifier = resolved instanceof PyFunction ? ((PyFunction)resolved).getModifier() : null; if (modifier == null && wrappedModifier != null) { modifier = wrappedModifier; } - boolean isByInstance = isConstructorCall || isQualifiedByInstance((Callable)resolved, qualifiers, context) + boolean isByInstance = isConstructorCall || isQualifiedByInstance((PyCallable)resolved, qualifiers, context) || resolved instanceof PyBoundFunction; PyExpression lastQualifier = qualifiers != null && qualifiers.isEmpty() ? null : qualifiers.get(qualifiers.size() - 1); - boolean isByClass = lastQualifier == null ? false : isQualifiedByClass((Callable)resolved, lastQualifier, context); - final Callable callable = (Callable)resolved; + boolean isByClass = lastQualifier == null ? false : isQualifiedByClass((PyCallable)resolved, lastQualifier, context); + final PyCallable callable = (PyCallable)resolved; implicitOffset += getImplicitArgumentCount(callable, modifier, isConstructorCall, isByInstance, isByClass); implicitOffset = implicitOffset < 0 ? 0 : implicitOffset; // wrong source can trigger strange behaviour @@ -247,7 +247,7 @@ public class PyCallExpressionHelper { } /** - * Calls the {@link #getImplicitArgumentCount(PyExpression, Callable, com.jetbrains.python.psi.PyFunction.Modifier, EnumSet< com.jetbrains.python.psi.PyFunction.Modifier >, boolean) full version} + * Calls the {@link #getImplicitArgumentCount(PyExpression, com.jetbrains.python.psi.PyCallable, com.jetbrains.python.psi.PyFunction.Modifier, EnumSet< com.jetbrains.python.psi.PyFunction.Modifier >, boolean) full version} * with null flags and with isByInstance inferred directly from call site (won't work with reassigned bound methods). * * @param callReference the call site, where arguments are given. @@ -279,7 +279,7 @@ public class PyCallExpressionHelper { * because one parameter ('self') is implicit. */ private static int getImplicitArgumentCount( - Callable callable, + PyCallable callable, PyFunction.Modifier modifier, boolean isConstructorCall, boolean isByInstance, @@ -318,7 +318,7 @@ public class PyCallExpressionHelper { return implicit_offset; } - private static boolean isQualifiedByInstance(Callable resolved, List qualifiers, TypeEvalContext context) { + private static boolean isQualifiedByInstance(PyCallable resolved, List qualifiers, TypeEvalContext context) { PyDocStringOwner owner = PsiTreeUtil.getStubOrPsiParentOfType(resolved, PyDocStringOwner.class); if (!(owner instanceof PyClass)) { return false; @@ -335,7 +335,7 @@ public class PyCallExpressionHelper { return false; } - private static boolean isQualifiedByInstance(Callable resolved, PyExpression qualifier, TypeEvalContext context) { + private static boolean isQualifiedByInstance(PyCallable resolved, PyExpression qualifier, TypeEvalContext context) { if (isQualifiedByClass(resolved, qualifier, context)) { return false; } @@ -347,7 +347,7 @@ public class PyCallExpressionHelper { return true; // NOTE. best guess: unknown qualifier is more probably an instance. } - private static boolean isQualifiedByClass(Callable resolved, PyExpression qualifier, TypeEvalContext context) { + private static boolean isQualifiedByClass(PyCallable resolved, PyExpression qualifier, TypeEvalContext context) { PyType qtype = context.getType(qualifier); if (qtype instanceof PyClassType) { if (((PyClassType)qtype).isDefinition()) { @@ -521,8 +521,8 @@ public class PyCallExpressionHelper { if (providedType instanceof PyCallableType) { return Ref.create(((PyCallableType)providedType).getCallType(context, call)); } - if (target instanceof Callable) { - final Callable callable = (Callable)target; + if (target instanceof PyCallable) { + final PyCallable callable = (PyCallable)target; return Ref.create(callable.getCallType(context, call)); } /*PyCallExpression.PyMarkedCallee markedCallee = call.resolveCallee(PyResolveContext.defaultContext().withTypeEvalContext(context)); diff --git a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionImpl.java index 58dbadceace1..722b769da580 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyCallExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyCallExpressionImpl.java @@ -22,7 +22,8 @@ import com.jetbrains.python.FunctionParameter; import com.jetbrains.python.nameResolver.FQNamesProvider; import com.jetbrains.python.psi.*; import com.jetbrains.python.psi.resolve.PyResolveContext; -import com.jetbrains.python.psi.types.*; +import com.jetbrains.python.psi.types.PyType; +import com.jetbrains.python.psi.types.TypeEvalContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -93,7 +94,7 @@ public class PyCallExpressionImpl extends PyElementImpl implements PyCallExpress } @Override - public Callable resolveCalleeFunction(PyResolveContext resolveContext) { + public PyCallable resolveCalleeFunction(PyResolveContext resolveContext) { return PyCallExpressionHelper.resolveCalleeFunction(this, resolveContext); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java index 6bf348210791..dd30ab957aa8 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyClassImpl.java @@ -553,8 +553,8 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla return proc.getResult(); } - private final static Maybe UNKNOWN_CALL = new Maybe(); // denotes _not_ a PyFunction, actually - private final static Maybe NONE = new Maybe(null); // denotes an explicit None + private final static Maybe UNKNOWN_CALL = new Maybe(); // denotes _not_ a PyFunction, actually + private final static Maybe NONE = new Maybe(null); // denotes an explicit None /** * @param name name of the property @@ -602,9 +602,9 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla } } for (Map.Entry> entry : grouped.entrySet()) { - Maybe getter = NONE; - Maybe setter = NONE; - Maybe deleter = NONE; + Maybe getter = NONE; + Maybe setter = NONE; + Maybe deleter = NONE; String doc = null; final String decoratorName = entry.getKey(); for (PyFunction method : entry.getValue()) { @@ -621,16 +621,16 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla } } if (PyNames.PROPERTY.equals(decoName)) { - getter = new Maybe(method); + getter = new Maybe(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) { - getter = new Maybe(method); + getter = new Maybe(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.SETTER)) { - setter = new Maybe(method); + setter = new Maybe(method); } else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.DELETER)) { - deleter = new Maybe(method); + deleter = new Maybe(method); } } } @@ -645,14 +645,14 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla return null; } - private Maybe fromPacked(Maybe maybeName) { + private Maybe fromPacked(Maybe maybeName) { if (maybeName.isDefined()) { final String value = maybeName.value(); if (value == null || PyNames.NONE.equals(value)) { return NONE; } PyFunction method = findMethodByName(value, true); - if (method != null) return new Maybe(method); + if (method != null) return new Maybe(method); } return UNKNOWN_CALL; } @@ -666,9 +666,9 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla final PyTargetExpressionStub targetStub = (PyTargetExpressionStub)subStub; PropertyStubStorage prop = targetStub.getCustomStub(PropertyStubStorage.class); if (prop != null && (name == null || name.equals(targetStub.getName()))) { - Maybe getter = fromPacked(prop.getGetter()); - Maybe setter = fromPacked(prop.getSetter()); - Maybe deleter = fromPacked(prop.getDeleter()); + Maybe getter = fromPacked(prop.getGetter()); + Maybe setter = fromPacked(prop.getSetter()); + Maybe deleter = fromPacked(prop.getDeleter()); String doc = prop.getDoc(); if (getter != NONE || setter != NONE || deleter != NONE) { final PropertyImpl property = new PropertyImpl(targetStub.getName(), getter, setter, deleter, doc, targetStub.getPsi()); @@ -703,7 +703,7 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla } @Override - public Property findPropertyByCallable(Callable callable) { + public Property findPropertyByCallable(PyCallable callable) { initProperties(); for (Property property : myPropertyCache.values()) { if (property.getGetter().valueOrNull() == callable || @@ -774,13 +774,13 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla return null; } - private static class PropertyImpl extends PropertyBunch implements Property { + private static class PropertyImpl extends PropertyBunch implements Property { private final String myName; private PropertyImpl(String name, - Maybe getter, - Maybe setter, - Maybe deleter, + Maybe getter, + Maybe setter, + Maybe deleter, String doc, PyTargetExpression site) { myName = name; @@ -793,19 +793,19 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla @NotNull @Override - public Maybe getGetter() { + public Maybe getGetter() { return filterNonStubExpression(myGetter); } @NotNull @Override - public Maybe getSetter() { + public Maybe getSetter() { return filterNonStubExpression(mySetter); } @NotNull @Override - public Maybe getDeleter() { + public Maybe getDeleter() { return filterNonStubExpression(myDeleter); } @@ -819,7 +819,7 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla @NotNull @Override - public Maybe getByDirection(@NotNull AccessDirection direction) { + public Maybe getByDirection(@NotNull AccessDirection direction) { switch (direction) { case READ: return getGetter(); @@ -840,7 +840,7 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla return targetDocStringType; } } - final Callable callable = myGetter.valueOrNull(); + final PyCallable callable = myGetter.valueOrNull(); if (callable != null) { // Ignore return types of non stub-based elements if we are not allowed to use AST if (!(callable instanceof StubBasedPsiElement) && !context.maySwitchToAST(callable)) { @@ -853,27 +853,27 @@ public class PyClassImpl extends PyBaseElementImpl implements PyCla @NotNull @Override - protected Maybe translate(@Nullable PyExpression expr) { + protected Maybe translate(@Nullable PyExpression expr) { if (expr == null) { return NONE; } if (PyNames.NONE.equals(expr.getName())) return NONE; // short-circuit a common case - if (expr instanceof Callable) { - return new Maybe((Callable)expr); + if (expr instanceof PyCallable) { + return new Maybe((PyCallable)expr); } final PsiReference ref = expr.getReference(); if (ref != null) { PsiElement something = ref.resolve(); - if (something instanceof Callable) { - return new Maybe((Callable)something); + if (something instanceof PyCallable) { + return new Maybe((PyCallable)something); } } return NONE; } @NotNull - private static Maybe filterNonStubExpression(@NotNull Maybe maybeCallable) { - final Callable callable = maybeCallable.valueOrNull(); + private static Maybe filterNonStubExpression(@NotNull Maybe maybeCallable) { + final PyCallable callable = maybeCallable.valueOrNull(); if (callable != null) { if (!(callable instanceof StubBasedPsiElement)) { return UNKNOWN_CALL; diff --git a/python/src/com/jetbrains/python/psi/impl/PyDecoratorImpl.java b/python/src/com/jetbrains/python/psi/impl/PyDecoratorImpl.java index d88d2231a55f..6aba3ea3658b 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyDecoratorImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyDecoratorImpl.java @@ -158,7 +158,7 @@ public class PyDecoratorImpl extends StubBasedPsiElementBase im } @Override - public Callable resolveCalleeFunction(PyResolveContext resolveContext) { + public PyCallable resolveCalleeFunction(PyResolveContext resolveContext) { return PyCallExpressionHelper.resolveCalleeFunction(this, resolveContext); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyPrefixExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PyPrefixExpressionImpl.java index d18137481b81..177d0c40f651 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyPrefixExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PyPrefixExpressionImpl.java @@ -83,9 +83,9 @@ public class PyPrefixExpressionImpl extends PyElementImpl implements PyPrefixExp } final PsiReference ref = getReference(PyResolveContext.noImplicits().withTypeEvalContext(context)); final PsiElement resolved = ref.resolve(); - if (resolved instanceof Callable) { + if (resolved instanceof PyCallable) { // TODO: Make PyPrefixExpression a PyCallSiteExpression, use getCallType() here and analyze it in PyTypeChecker.analyzeCallSite() - return ((Callable)resolved).getReturnType(context, key); + return ((PyCallable)resolved).getReturnType(context, key); } return null; } diff --git a/python/src/com/jetbrains/python/psi/impl/PySubscriptionExpressionImpl.java b/python/src/com/jetbrains/python/psi/impl/PySubscriptionExpressionImpl.java index 905dd24d76f6..a882b31633e6 100644 --- a/python/src/com/jetbrains/python/psi/impl/PySubscriptionExpressionImpl.java +++ b/python/src/com/jetbrains/python/psi/impl/PySubscriptionExpressionImpl.java @@ -73,8 +73,8 @@ public class PySubscriptionExpressionImpl extends PyElementImpl implements PySub final List members = new ArrayList(); for (PsiElement resolved : PyUtil.multiResolveTopPriority(reference)) { PyType res = null; - if (resolved instanceof Callable) { - res = ((Callable)resolved).getCallType(context, this); + if (resolved instanceof PyCallable) { + res = ((PyCallable)resolved).getCallType(context, this); } if (PyTypeChecker.isUnknown(res) || res instanceof PyNoneType) { final PyExpression indexExpression = getIndexExpression(); diff --git a/python/src/com/jetbrains/python/psi/search/PyOverridingMethodsSearchExecutor.java b/python/src/com/jetbrains/python/psi/search/PyOverridingMethodsSearchExecutor.java index cc53cf9b2f26..908cccd92117 100644 --- a/python/src/com/jetbrains/python/psi/search/PyOverridingMethodsSearchExecutor.java +++ b/python/src/com/jetbrains/python/psi/search/PyOverridingMethodsSearchExecutor.java @@ -40,7 +40,7 @@ public class PyOverridingMethodsSearchExecutor implements QueryExecutor resultRef = null; Property property = myClass.findProperty(name, inherited); if (property != null) { - Maybe accessor = property.getByDirection(direction); + Maybe accessor = property.getByDirection(direction); if (accessor.isDefined()) { - Callable accessor_code = accessor.value(); + PyCallable accessor_code = accessor.value(); ResolveResultList ret = new ResolveResultList(); if (accessor_code != null) ret.poke(accessor_code, RatedResolveResult.RATE_NORMAL); PyTargetExpression site = property.getDefinitionSite(); diff --git a/python/src/com/jetbrains/python/psi/types/PyFunctionType.java b/python/src/com/jetbrains/python/psi/types/PyFunctionType.java index fde4e18fabe4..263ef6026bad 100644 --- a/python/src/com/jetbrains/python/psi/types/PyFunctionType.java +++ b/python/src/com/jetbrains/python/psi/types/PyFunctionType.java @@ -36,14 +36,14 @@ import static com.jetbrains.python.psi.PyFunction.Modifier.STATICMETHOD; import static com.jetbrains.python.psi.PyUtil.as; /** - * Type of a particular function that is represented as a {@link Callable} in the PSI tree. + * Type of a particular function that is represented as a {@link com.jetbrains.python.psi.PyCallable} in the PSI tree. * * @author vlan */ public class PyFunctionType implements PyCallableType { - @NotNull private final Callable myCallable; + @NotNull private final PyCallable myCallable; - public PyFunctionType(@NotNull Callable callable) { + public PyFunctionType(@NotNull PyCallable callable) { myCallable = callable; } @@ -173,7 +173,7 @@ public class PyFunctionType implements PyCallableType { } @NotNull - public Callable getCallable() { + public PyCallable getCallable() { return myCallable; } diff --git a/python/src/com/jetbrains/python/psi/types/PyTypeChecker.java b/python/src/com/jetbrains/python/psi/types/PyTypeChecker.java index 7acdb114b036..66803ec00c5e 100644 --- a/python/src/com/jetbrains/python/psi/types/PyTypeChecker.java +++ b/python/src/com/jetbrains/python/psi/types/PyTypeChecker.java @@ -459,7 +459,7 @@ public class PyTypeChecker { final Map arguments = mapping.getPlainMappedParams(); final PyCallExpression.PyMarkedCallee markedCallee = mapping.getMarkedCallee(); if (markedCallee != null) { - final Callable callable = markedCallee.getCallable(); + final PyCallable callable = markedCallee.getCallable(); if (callable instanceof PyFunction) { final PyFunction function = (PyFunction)callable; final PyExpression receiver; @@ -493,7 +493,7 @@ public class PyTypeChecker { if (!(type instanceof PyFunctionType)) { return null; } - final Callable callable = ((PyFunctionType)type).getCallable(); + final PyCallable callable = ((PyFunctionType)type).getCallable(); final String operatorName = typedElement.getName(); final boolean isRight = PyNames.isRightOperatorName(operatorName); final PyExpression arg = isRight ? expr.getLeftExpression() : expr.getRightExpression(); @@ -529,7 +529,7 @@ public class PyTypeChecker { if (resolved instanceof PyTypedElement) { final PyType type = context.getType((PyTypedElement)resolved); if (type instanceof PyFunctionType) { - final Callable callable = ((PyFunctionType)type).getCallable(); + final PyCallable callable = ((PyFunctionType)type).getCallable(); final PyParameter[] parameters = callable.getParameterList().getParameters(); if (parameters.length == 2) { final PyNamedParameter param = parameters[1].getAsNamed(); @@ -614,11 +614,11 @@ public class PyTypeChecker { } public static class AnalyzeCallResults { - @NotNull private final Callable myCallable; + @NotNull private final PyCallable myCallable; @Nullable private final PyExpression myReceiver; @NotNull private final Map myArguments; - public AnalyzeCallResults(@NotNull Callable callable, @Nullable PyExpression receiver, + public AnalyzeCallResults(@NotNull PyCallable callable, @Nullable PyExpression receiver, @NotNull Map arguments) { myCallable = callable; myReceiver = receiver; @@ -626,7 +626,7 @@ public class PyTypeChecker { } @NotNull - public Callable getCallable() { + public PyCallable getCallable() { return myCallable; } diff --git a/python/src/com/jetbrains/python/refactoring/classes/membersManager/PropertiesManager.java b/python/src/com/jetbrains/python/refactoring/classes/membersManager/PropertiesManager.java index 1c14f1d1d46e..d70cad32018d 100644 --- a/python/src/com/jetbrains/python/refactoring/classes/membersManager/PropertiesManager.java +++ b/python/src/com/jetbrains/python/refactoring/classes/membersManager/PropertiesManager.java @@ -52,9 +52,9 @@ class PropertiesManager extends MembersManager { @NotNull private static PyElement getElement(@NotNull final Property property) { - final Callable getter = property.getGetter().valueOrNull(); - final Callable setter = property.getSetter().valueOrNull(); - final Callable deleter = property.getDeleter().valueOrNull(); + final PyCallable getter = property.getGetter().valueOrNull(); + final PyCallable setter = property.getSetter().valueOrNull(); + final PyCallable deleter = property.getDeleter().valueOrNull(); if (getter != null) { return getter; @@ -111,9 +111,9 @@ class PropertiesManager extends MembersManager { @NotNull private static Collection getAllFunctions(@NotNull final Property property) { final Collection result = new ArrayList(3); - final Callable getter = property.getGetter().valueOrNull(); - final Callable setter = property.getSetter().valueOrNull(); - final Callable deleter = property.getDeleter().valueOrNull(); + final PyCallable getter = property.getGetter().valueOrNull(); + final PyCallable setter = property.getSetter().valueOrNull(); + final PyCallable deleter = property.getDeleter().valueOrNull(); if (getter instanceof PyFunction) { result.add((PyFunction)getter); diff --git a/python/src/com/jetbrains/python/refactoring/rename/RenamePyFunctionProcessor.java b/python/src/com/jetbrains/python/refactoring/rename/RenamePyFunctionProcessor.java index 29d287d3ae93..026cd3a4a641 100644 --- a/python/src/com/jetbrains/python/refactoring/rename/RenamePyFunctionProcessor.java +++ b/python/src/com/jetbrains/python/refactoring/rename/RenamePyFunctionProcessor.java @@ -128,8 +128,8 @@ public class RenamePyFunctionProcessor extends RenamePyElementProcessor { } } - private static void addRename(Map renames, String newName, Maybe accessor) { - final Callable callable = accessor.valueOrNull(); + private static void addRename(Map renames, String newName, Maybe accessor) { + final PyCallable callable = accessor.valueOrNull(); if (callable instanceof PyFunction) { renames.put(callable, newName); } diff --git a/python/testSrc/com/jetbrains/env/python/PythonSkeletonsTest.java b/python/testSrc/com/jetbrains/env/python/PythonSkeletonsTest.java index 04cccab0122d..0c6482c1cc6c 100644 --- a/python/testSrc/com/jetbrains/env/python/PythonSkeletonsTest.java +++ b/python/testSrc/com/jetbrains/env/python/PythonSkeletonsTest.java @@ -167,7 +167,7 @@ public class PythonSkeletonsTest extends PyEnvTestCase { }); } - private void assertIsNotNull(Maybe accessor) { + private void assertIsNotNull(Maybe accessor) { if (accessor.isDefined()) { assertNotNull(accessor.valueOrNull()); } diff --git a/python/testSrc/com/jetbrains/python/PyClassicPropertyTest.java b/python/testSrc/com/jetbrains/python/PyClassicPropertyTest.java index 71d2498b39f8..7687037daf63 100644 --- a/python/testSrc/com/jetbrains/python/PyClassicPropertyTest.java +++ b/python/testSrc/com/jetbrains/python/PyClassicPropertyTest.java @@ -37,7 +37,7 @@ public class PyClassicPropertyTest extends PyTestCase { public void testV1() throws Exception { Property p; - Maybe accessor; + Maybe accessor; p = myClass.findProperty("v1", true); assertNotNull(p); assertNull(p.getDoc()); @@ -61,7 +61,7 @@ public class PyClassicPropertyTest extends PyTestCase { public void testV2() throws Exception { Property p; - Maybe accessor; + Maybe accessor; p = myClass.findProperty("v2", true); assertNotNull(p); assertEquals("doc of v2", p.getDoc()); @@ -85,7 +85,7 @@ public class PyClassicPropertyTest extends PyTestCase { } public void testV3() throws Exception { - Maybe accessor; + Maybe accessor; Property p = myClass.findProperty("v3", true); assertNotNull(p); assertNull(p.getDoc()); @@ -111,7 +111,7 @@ public class PyClassicPropertyTest extends PyTestCase { /* NOTE: we don't support this yet public void testV4() throws Exception { Property p; - Maybe accessor; + Maybe accessor; p = myClass.findProperty("v4"); assertNotNull(p); assertEquals("otherworldly", p.getDoc()); diff --git a/python/testSrc/com/jetbrains/python/PyDecoratedPropertyTest.java b/python/testSrc/com/jetbrains/python/PyDecoratedPropertyTest.java index ac9f83afce6a..d5805e6d55a3 100644 --- a/python/testSrc/com/jetbrains/python/PyDecoratedPropertyTest.java +++ b/python/testSrc/com/jetbrains/python/PyDecoratedPropertyTest.java @@ -33,7 +33,7 @@ public class PyDecoratedPropertyTest extends PyTestCase { public void testW1() throws Exception { Property p; - Maybe accessor; + Maybe accessor; final String name = "w1"; p = myClass.findProperty(name, true); assertNotNull(p); @@ -58,7 +58,7 @@ public class PyDecoratedPropertyTest extends PyTestCase { public void testW2() throws Exception { Property p; - Maybe accessor; + Maybe accessor; final String name = "w2"; p = myClass.findProperty(name, true); assertNotNull(p); @@ -67,7 +67,7 @@ public class PyDecoratedPropertyTest extends PyTestCase { accessor = p.getGetter(); assertTrue(accessor.isDefined()); - final Callable callable = accessor.value(); + final PyCallable callable = accessor.value(); assertNotNull(callable); assertEquals("w2", callable.getName()); assertInstanceOf(callable, PyFunction.class); diff --git a/python/testSrc/com/jetbrains/python/PyStubsTest.java b/python/testSrc/com/jetbrains/python/PyStubsTest.java index 82539fef5457..b51527de4dc0 100644 --- a/python/testSrc/com/jetbrains/python/PyStubsTest.java +++ b/python/testSrc/com/jetbrains/python/PyStubsTest.java @@ -120,12 +120,12 @@ public class PyStubsTest extends PyTestCase { assertEquals("BarClass", pyClass.getName()); Property prop = pyClass.findProperty("value", true); - Maybe maybe_function = prop.getGetter(); + Maybe maybe_function = prop.getGetter(); assertTrue(maybe_function.isDefined()); assertEquals(pyClass.getMethods(false)[0], maybe_function.value()); Property setvalueProp = pyClass.findProperty("setvalue", true); - Maybe setter = setvalueProp.getSetter(); + Maybe setter = setvalueProp.getSetter(); assertTrue(setter.isDefined()); assertEquals("__set", setter.value().getName());