private static boolean isInBuiltins(PyExpression callee) { if (callee instanceof PyQualifiedExpression && (((PyQualifiedExpression) callee).getQualifier() != null)) { return false; } PsiReference reference = callee.getReference(); if (reference != null) { PsiElement resolved = reference.resolve(); if (resolved != null && PyBuiltinCache.getInstance(callee).hasInBuiltins(resolved)) { return true; } } return false; }
@Override public void visitPyCallExpression(final PyCallExpression node) { // TODO: refactor, messy code final PyExpression callee = node.getCallee(); if (callee != null) { final PsiReference calleeRef = callee.getReference(); if (calleeRef != null) { final PsiElement calleeDeclaration = calleeRef.resolve(); if (calleeDeclaration instanceof PyFunction) { final PyFunction calleeFunction = (PyFunction) calleeDeclaration; final PyClass clazz = calleeFunction.getContainingClass(); if (clazz != null) { if (PyUtil.isInit(calleeFunction)) { return; // Init call should not be marked as dependency } myResult.putValue(clazz, calleeFunction); } } } } }
/** @param self should be this */ @NotNull private static List<PyAssignmentStatement> findAttributesStatic(@NotNull final PsiElement self) { final List<PyAssignmentStatement> result = new ArrayList<>(); for (final PyAssignmentStatement statement : new PsiQuery(self).siblings(PyAssignmentStatement.class).getElements()) { for (final PyQualifiedExpression targetExpression : new PsiQuery(statement.getTargets()).filter(PyQualifiedExpression.class).getElements()) { final PyExpression qualifier = targetExpression.getQualifier(); if (qualifier == null) { continue; } final PsiReference qualifierReference = qualifier.getReference(); if (qualifierReference == null) { continue; } if (qualifierReference.isReferenceTo(self)) { result.add(statement); } } } return result; }