Rename com.jetbrains.python.psi.Callable to PyCallable so as not to clash with java.util.concurrent.Callable

This commit is contained in:
Mikhail Golubev
2015-02-27 15:14:34 +03:00
parent 52163e5a68
commit b5c92ae0ba
48 changed files with 159 additions and 156 deletions
@@ -35,19 +35,19 @@ public interface Property {
* @return the setter: a method or null if defined, or something else callable if undefined.
*/
@NotNull
Maybe<Callable> getSetter();
Maybe<PyCallable> getSetter();
/**
* @return the getter: a method or null if defined, or something else callable if undefined.
*/
@NotNull
Maybe<Callable> getGetter();
Maybe<PyCallable> getGetter();
/**
* @return the deleter: a method or null if defined, or something else callable if undefined.
*/
@NotNull
Maybe<Callable> getDeleter();
Maybe<PyCallable> 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<Callable> getByDirection(@NotNull AccessDirection direction);
Maybe<PyCallable> getByDirection(@NotNull AccessDirection direction);
/**
* Get the return type of the property getter.
@@ -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;
}
@@ -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.
@@ -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
@@ -36,7 +36,7 @@ import java.util.List;
public interface PyFunction
extends
PsiNamedElement, StubBasedPsiElement<PyFunctionStub>,
PsiNameIdentifierOwner, PyStatement, Callable, NameDefiner, PyDocStringOwner, ScopeOwner, PyDecoratable, PyTypedElement,
PsiNameIdentifierOwner, PyStatement, PyCallable, NameDefiner, PyDocStringOwner, ScopeOwner, PyDecoratable, PyTypedElement,
PyStatementListContainer{
PyFunction[] EMPTY_ARRAY = new PyFunction[0];
@@ -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();
}
@@ -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);
}
@@ -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;
}
@@ -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<PyTypedElement, PyType> myEvaluated = new HashMap<PyTypedElement, PyType>();
private final Map<Callable, PyType> myEvaluatedReturn = new HashMap<Callable, PyType>();
private final Map<PyCallable, PyType> myEvaluatedReturn = new HashMap<PyCallable, PyType>();
private final ThreadLocal<Set<PyTypedElement>> myEvaluating = new ThreadLocal<Set<PyTypedElement>>() {
@Override
protected Set<PyTypedElement> initialValue() {
return new HashSet<PyTypedElement>();
}
};
private final ThreadLocal<Set<Callable>> myEvaluatingReturn = new ThreadLocal<Set<Callable>>() {
private final ThreadLocal<Set<PyCallable>> myEvaluatingReturn = new ThreadLocal<Set<PyCallable>>() {
@Override
protected Set<Callable> initialValue() {
return new HashSet<Callable>();
protected Set<PyCallable> initialValue() {
return new HashSet<PyCallable>();
}
};
@@ -203,8 +203,8 @@ public class TypeEvalContext {
}
@Nullable
public PyType getReturnType(@NotNull final Callable callable) {
final Set<Callable> evaluating = myEvaluatingReturn.get();
public PyType getReturnType(@NotNull final PyCallable callable) {
final Set<PyCallable> evaluating = myEvaluatingReturn.get();
if (evaluating.contains(callable)) {
return null;
}
@@ -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);
}
@@ -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")){
@@ -135,7 +135,7 @@ public class PyParameterInfoHandler implements ParameterInfoHandler<PyArgumentLi
final CallArgumentsMapping argumentsMapping = argList.analyzeCall(resolveContext);
final PyMarkedCallee marked = argumentsMapping.getMarkedCallee();
if (marked == null) return; // resolution failed
final Callable callable = marked.getCallable();
final PyCallable callable = marked.getCallable();
final List<PyParameter> parameterList = PyUtil.getParameters(callable, typeEvalContext);
final List<PyNamedParameter> namedParameters = new ArrayList<PyNamedParameter>(parameterList.size());
@@ -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();
@@ -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);
}
@@ -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();
@@ -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);
@@ -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);
}
@@ -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);
}
@@ -99,7 +99,7 @@ class PyDocumentationBuilder {
if (property != null) {
is_property = true;
final AccessDirection dir = AccessDirection.of((PyElement)outer);
Maybe<Callable> accessor = property.getByDirection(dir);
Maybe<PyCallable> 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();
@@ -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)) {
@@ -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<PyParameter> 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;
@@ -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) {
@@ -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;
}
@@ -106,7 +106,7 @@ public class PyPropertyAccessInspection extends PyInspection {
}
private void checkAccessor(PyExpression node, String name, AccessDirection dir, Property property) {
final Maybe<Callable> accessor = property.getByDirection(dir);
final Maybe<PyCallable> accessor = property.getByDirection(dir);
if (accessor.isDefined() && accessor.value() == null) {
final String message;
if (dir == AccessDirection.WRITE) {
@@ -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) {
@@ -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);
@@ -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;
}
@@ -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();
@@ -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;
}
@@ -70,7 +70,7 @@ public class PythonPatterns extends PlatformPatterns {
public static PyElementPattern.Capture<PyExpression> pyModuleFunctionArgument(final String functionName, final int index, final String moduleName) {
return new PyElementPattern.Capture<PyExpression>(new InitialPatternCondition<PyExpression>(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<PyExpression> pyMethodArgument(final String functionName, final int index, final String classQualifiedName) {
return new PyElementPattern.Capture<PyExpression>(new InitialPatternCondition<PyExpression>(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;
}
@@ -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<PyParameter> getParameters(@NotNull Callable callable, @NotNull TypeEvalContext context) {
public static List<PyParameter> 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<PyParameter> parameters = getParameters(callable, context);
final List<PyParameter> otherParameters = getParameters(otherCallable, context);
@@ -1655,11 +1655,11 @@ public class PyUtil {
return n;
}
private static int requiredParametersCount(@NotNull Callable callable, @NotNull List<PyParameter> parameters) {
private static int requiredParametersCount(@NotNull PyCallable callable, @NotNull List<PyParameter> parameters) {
return parameters.size() - optionalParametersCount(parameters) - specialParametersCount(callable, parameters);
}
private static int specialParametersCount(@NotNull Callable callable, @NotNull List<PyParameter> parameters) {
private static int specialParametersCount(@NotNull PyCallable callable, @NotNull List<PyParameter> parameters) {
int n = 0;
if (hasPositionalContainer(parameters)) {
n++;
@@ -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<PyExpression> qualifiers, TypeEvalContext context) {
private static boolean isQualifiedByInstance(PyCallable resolved, List<PyExpression> 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));
@@ -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);
}
@@ -553,8 +553,8 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
return proc.getResult();
}
private final static Maybe<Callable> UNKNOWN_CALL = new Maybe<Callable>(); // denotes _not_ a PyFunction, actually
private final static Maybe<Callable> NONE = new Maybe<Callable>(null); // denotes an explicit None
private final static Maybe<PyCallable> UNKNOWN_CALL = new Maybe<PyCallable>(); // denotes _not_ a PyFunction, actually
private final static Maybe<PyCallable> NONE = new Maybe<PyCallable>(null); // denotes an explicit None
/**
* @param name name of the property
@@ -602,9 +602,9 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
}
}
for (Map.Entry<String, List<PyFunction>> entry : grouped.entrySet()) {
Maybe<Callable> getter = NONE;
Maybe<Callable> setter = NONE;
Maybe<Callable> deleter = NONE;
Maybe<PyCallable> getter = NONE;
Maybe<PyCallable> setter = NONE;
Maybe<PyCallable> deleter = NONE;
String doc = null;
final String decoratorName = entry.getKey();
for (PyFunction method : entry.getValue()) {
@@ -621,16 +621,16 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
}
}
if (PyNames.PROPERTY.equals(decoName)) {
getter = new Maybe<Callable>(method);
getter = new Maybe<PyCallable>(method);
}
else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.GETTER)) {
getter = new Maybe<Callable>(method);
getter = new Maybe<PyCallable>(method);
}
else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.SETTER)) {
setter = new Maybe<Callable>(method);
setter = new Maybe<PyCallable>(method);
}
else if (useAdvancedSyntax && qname.matches(decoratorName, PyNames.DELETER)) {
deleter = new Maybe<Callable>(method);
deleter = new Maybe<PyCallable>(method);
}
}
}
@@ -645,14 +645,14 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
return null;
}
private Maybe<Callable> fromPacked(Maybe<String> maybeName) {
private Maybe<PyCallable> fromPacked(Maybe<String> 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<Callable>(method);
if (method != null) return new Maybe<PyCallable>(method);
}
return UNKNOWN_CALL;
}
@@ -666,9 +666,9 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
final PyTargetExpressionStub targetStub = (PyTargetExpressionStub)subStub;
PropertyStubStorage prop = targetStub.getCustomStub(PropertyStubStorage.class);
if (prop != null && (name == null || name.equals(targetStub.getName()))) {
Maybe<Callable> getter = fromPacked(prop.getGetter());
Maybe<Callable> setter = fromPacked(prop.getSetter());
Maybe<Callable> deleter = fromPacked(prop.getDeleter());
Maybe<PyCallable> getter = fromPacked(prop.getGetter());
Maybe<PyCallable> setter = fromPacked(prop.getSetter());
Maybe<PyCallable> 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<PyClassStub> 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<PyClassStub> implements PyCla
return null;
}
private static class PropertyImpl extends PropertyBunch<Callable> implements Property {
private static class PropertyImpl extends PropertyBunch<PyCallable> implements Property {
private final String myName;
private PropertyImpl(String name,
Maybe<Callable> getter,
Maybe<Callable> setter,
Maybe<Callable> deleter,
Maybe<PyCallable> getter,
Maybe<PyCallable> setter,
Maybe<PyCallable> deleter,
String doc,
PyTargetExpression site) {
myName = name;
@@ -793,19 +793,19 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
@NotNull
@Override
public Maybe<Callable> getGetter() {
public Maybe<PyCallable> getGetter() {
return filterNonStubExpression(myGetter);
}
@NotNull
@Override
public Maybe<Callable> getSetter() {
public Maybe<PyCallable> getSetter() {
return filterNonStubExpression(mySetter);
}
@NotNull
@Override
public Maybe<Callable> getDeleter() {
public Maybe<PyCallable> getDeleter() {
return filterNonStubExpression(myDeleter);
}
@@ -819,7 +819,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
@NotNull
@Override
public Maybe<Callable> getByDirection(@NotNull AccessDirection direction) {
public Maybe<PyCallable> getByDirection(@NotNull AccessDirection direction) {
switch (direction) {
case READ:
return getGetter();
@@ -840,7 +840,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> 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<PyClassStub> implements PyCla
@NotNull
@Override
protected Maybe<Callable> translate(@Nullable PyExpression expr) {
protected Maybe<PyCallable> 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>((Callable)expr);
if (expr instanceof PyCallable) {
return new Maybe<PyCallable>((PyCallable)expr);
}
final PsiReference ref = expr.getReference();
if (ref != null) {
PsiElement something = ref.resolve();
if (something instanceof Callable) {
return new Maybe<Callable>((Callable)something);
if (something instanceof PyCallable) {
return new Maybe<PyCallable>((PyCallable)something);
}
}
return NONE;
}
@NotNull
private static Maybe<Callable> filterNonStubExpression(@NotNull Maybe<Callable> maybeCallable) {
final Callable callable = maybeCallable.valueOrNull();
private static Maybe<PyCallable> filterNonStubExpression(@NotNull Maybe<PyCallable> maybeCallable) {
final PyCallable callable = maybeCallable.valueOrNull();
if (callable != null) {
if (!(callable instanceof StubBasedPsiElement)) {
return UNKNOWN_CALL;
@@ -158,7 +158,7 @@ public class PyDecoratorImpl extends StubBasedPsiElementBase<PyDecoratorStub> im
}
@Override
public Callable resolveCalleeFunction(PyResolveContext resolveContext) {
public PyCallable resolveCalleeFunction(PyResolveContext resolveContext) {
return PyCallExpressionHelper.resolveCalleeFunction(this, resolveContext);
}
@@ -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;
}
@@ -73,8 +73,8 @@ public class PySubscriptionExpressionImpl extends PyElementImpl implements PySub
final List<PyType> members = new ArrayList<PyType>();
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();
@@ -40,7 +40,7 @@ public class PyOverridingMethodsSearchExecutor implements QueryExecutor<PyFuncti
final Property overridingProperty = overridingMethod.getProperty();
if (baseProperty != null && overridingProperty != null) {
final AccessDirection direction = PyUtil.getPropertyAccessDirection(baseMethod);
final Callable callable = overridingProperty.getByDirection(direction).valueOrNull();
final PyCallable callable = overridingProperty.getByDirection(direction).valueOrNull();
overridingMethod = (callable instanceof PyFunction) ? (PyFunction)callable : null;
}
}
@@ -52,7 +52,7 @@ public class PySuperMethodsSearchExecutor implements QueryExecutor<PsiElement, P
final Property superProperty = superMethod.getProperty();
if (property != null && superProperty != null) {
final AccessDirection direction = PyUtil.getPropertyAccessDirection(func);
final Callable callable = superProperty.getByDirection(direction).valueOrNull();
final PyCallable callable = superProperty.getByDirection(direction).valueOrNull();
superMethod = (callable instanceof PyFunction) ? (PyFunction)callable : null;
}
}
@@ -252,9 +252,9 @@ public class PyClassTypeImpl extends UserDataHolderBase implements PyClassType {
Ref<ResolveResultList> resultRef = null;
Property property = myClass.findProperty(name, inherited);
if (property != null) {
Maybe<Callable> accessor = property.getByDirection(direction);
Maybe<PyCallable> 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();
@@ -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;
}
@@ -459,7 +459,7 @@ public class PyTypeChecker {
final Map<PyExpression, PyNamedParameter> 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<PyExpression, PyNamedParameter> myArguments;
public AnalyzeCallResults(@NotNull Callable callable, @Nullable PyExpression receiver,
public AnalyzeCallResults(@NotNull PyCallable callable, @Nullable PyExpression receiver,
@NotNull Map<PyExpression, PyNamedParameter> arguments) {
myCallable = callable;
myReceiver = receiver;
@@ -626,7 +626,7 @@ public class PyTypeChecker {
}
@NotNull
public Callable getCallable() {
public PyCallable getCallable() {
return myCallable;
}
@@ -52,9 +52,9 @@ class PropertiesManager extends MembersManager<PyElement> {
@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<PyElement> {
@NotNull
private static Collection<PyFunction> getAllFunctions(@NotNull final Property property) {
final Collection<PyFunction> result = new ArrayList<PyFunction>(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);
@@ -128,8 +128,8 @@ public class RenamePyFunctionProcessor extends RenamePyElementProcessor {
}
}
private static void addRename(Map<PsiElement, String> renames, String newName, Maybe<Callable> accessor) {
final Callable callable = accessor.valueOrNull();
private static void addRename(Map<PsiElement, String> renames, String newName, Maybe<PyCallable> accessor) {
final PyCallable callable = accessor.valueOrNull();
if (callable instanceof PyFunction) {
renames.put(callable, newName);
}
@@ -167,7 +167,7 @@ public class PythonSkeletonsTest extends PyEnvTestCase {
});
}
private void assertIsNotNull(Maybe<Callable> accessor) {
private void assertIsNotNull(Maybe<PyCallable> accessor) {
if (accessor.isDefined()) {
assertNotNull(accessor.valueOrNull());
}
@@ -37,7 +37,7 @@ public class PyClassicPropertyTest extends PyTestCase {
public void testV1() throws Exception {
Property p;
Maybe<Callable> accessor;
Maybe<PyCallable> 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<Callable> accessor;
Maybe<PyCallable> 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<Callable> accessor;
Maybe<PyCallable> 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<Callable> accessor;
Maybe<PyCallable> accessor;
p = myClass.findProperty("v4");
assertNotNull(p);
assertEquals("otherworldly", p.getDoc());
@@ -33,7 +33,7 @@ public class PyDecoratedPropertyTest extends PyTestCase {
public void testW1() throws Exception {
Property p;
Maybe<Callable> accessor;
Maybe<PyCallable> 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<Callable> accessor;
Maybe<PyCallable> 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);
@@ -120,12 +120,12 @@ public class PyStubsTest extends PyTestCase {
assertEquals("BarClass", pyClass.getName());
Property prop = pyClass.findProperty("value", true);
Maybe<Callable> maybe_function = prop.getGetter();
Maybe<PyCallable> maybe_function = prop.getGetter();
assertTrue(maybe_function.isDefined());
assertEquals(pyClass.getMethods(false)[0], maybe_function.value());
Property setvalueProp = pyClass.findProperty("setvalue", true);
Maybe<Callable> setter = setvalueProp.getSetter();
Maybe<PyCallable> setter = setvalueProp.getSetter();
assertTrue(setter.isDefined());
assertEquals("__set", setter.value().getName());