use of com.jetbrains.python.console.completion.PydevConsoleReference in project intellij-community by JetBrains.
the class PyReferenceExpressionImpl method getReference.
@NotNull
@Override
public PsiPolyVariantReference getReference(@NotNull PyResolveContext context) {
// Handle import reference
final PsiElement importParent = PsiTreeUtil.getParentOfType(this, PyImportElement.class, PyFromImportStatement.class);
if (importParent != null) {
return PyImportReference.forElement(this, importParent, context);
}
final PyExpression qualifier = getQualifier();
// Return special reference
final ConsoleCommunication communication = getContainingFile().getCopyableUserData(PydevConsoleRunner.CONSOLE_KEY);
if (communication != null) {
final String prefix = qualifier == null ? "" : qualifier.getText() + ".";
return new PydevConsoleReference(this, communication, prefix, context.allowRemote());
}
if (qualifier != null) {
return new PyQualifiedReference(this, context);
}
return new PyReferenceImpl(this, context);
}
use of com.jetbrains.python.console.completion.PydevConsoleReference 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();
}
Aggregations