Search in sources :

Example 1 with PyClassFindUsagesHandler

use of com.jetbrains.python.findUsages.PyClassFindUsagesHandler in project intellij-community by JetBrains.

the class PyStaticCallHierarchyUtil method createFindUsageHandler.

/**
   * @see {@link com.jetbrains.python.findUsages.PyFindUsagesHandlerFactory#createFindUsagesHandler(com.intellij.psi.PsiElement, boolean) createFindUsagesHandler}
   */
@Nullable
private static FindUsagesHandler createFindUsageHandler(@NotNull final PsiElement element) {
    if (element instanceof PyFunction) {
        final TypeEvalContext context = TypeEvalContext.userInitiated(element.getProject(), null);
        final Collection<PsiElement> superMethods = PySuperMethodsSearch.search((PyFunction) element, true, context).findAll();
        if (superMethods.size() > 0) {
            final PsiElement next = superMethods.iterator().next();
            if (next instanceof PyFunction && !isInObject((PyFunction) next)) {
                List<PsiElement> allMethods = Lists.newArrayList();
                allMethods.add(element);
                allMethods.addAll(superMethods);
                return new PyFunctionFindUsagesHandler(element, allMethods);
            }
        }
        return new PyFunctionFindUsagesHandler(element);
    }
    if (element instanceof PyClass) {
        return new PyClassFindUsagesHandler((PyClass) element);
    }
    return null;
}
Also used : PyFunctionFindUsagesHandler(com.jetbrains.python.findUsages.PyFunctionFindUsagesHandler) PyClassFindUsagesHandler(com.jetbrains.python.findUsages.PyClassFindUsagesHandler) TypeEvalContext(com.jetbrains.python.psi.types.TypeEvalContext) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PyClassFindUsagesHandler (com.jetbrains.python.findUsages.PyClassFindUsagesHandler)1 PyFunctionFindUsagesHandler (com.jetbrains.python.findUsages.PyFunctionFindUsagesHandler)1 TypeEvalContext (com.jetbrains.python.psi.types.TypeEvalContext)1 Nullable (org.jetbrains.annotations.Nullable)1