Search in sources :

Example 21 with PyElement

use of com.jetbrains.python.psi.PyElement in project intellij-community by JetBrains.

the class PydevDocumentationProvider method createDoc.

@Nullable
public static String createDoc(final PsiElement element, final PsiElement originalElement) {
    final PyReferenceExpression expression = PsiTreeUtil.getNonStrictParentOfType(originalElement, PyReferenceExpression.class);
    // Indicates that we are inside console, not a lookup element!
    if (expression == null) {
        return null;
    }
    PydevConsoleReference consoleRef = PyUtil.as(expression.getReference(), PydevConsoleReference.class);
    if (consoleRef == null) {
        //shouldn't really happen!
        return null;
    }
    PyElement documentationElement = consoleRef.getDocumentationElement();
    if (documentationElement == null) {
        return null;
    }
    return new PyDocumentationBuilder(documentationElement, null).build();
}
Also used : PydevConsoleReference(com.jetbrains.python.console.completion.PydevConsoleReference) PyDocumentationBuilder(com.jetbrains.python.documentation.PyDocumentationBuilder) PyReferenceExpression(com.jetbrains.python.psi.PyReferenceExpression) PyElement(com.jetbrains.python.psi.PyElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PyElement (com.jetbrains.python.psi.PyElement)21 PyClass (com.jetbrains.python.psi.PyClass)12 PyMemberInfo (com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo)8 ArrayList (java.util.ArrayList)7 NotNull (org.jetbrains.annotations.NotNull)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 PsiElement (com.intellij.psi.PsiElement)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 PsiManager (com.intellij.psi.PsiManager)2 MultiMap (com.intellij.util.containers.MultiMap)2 PyFunction (com.jetbrains.python.psi.PyFunction)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 LocalQuickFixOnPsiElement (com.intellij.codeInspection.LocalQuickFixOnPsiElement)1 HierarchyNodeDescriptor (com.intellij.ide.hierarchy.HierarchyNodeDescriptor)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 ItemPresentation (com.intellij.navigation.ItemPresentation)1 Project (com.intellij.openapi.project.Project)1 PsiComment (com.intellij.psi.PsiComment)1