Search in sources :

Example 1 with ConsoleCommunication

use of com.jetbrains.python.console.pydev.ConsoleCommunication 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);
}
Also used : PydevConsoleReference(com.jetbrains.python.console.completion.PydevConsoleReference) PyQualifiedReference(com.jetbrains.python.psi.impl.references.PyQualifiedReference) ConsoleCommunication(com.jetbrains.python.console.pydev.ConsoleCommunication) PyReferenceImpl(com.jetbrains.python.psi.impl.references.PyReferenceImpl) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PydevConsoleReference (com.jetbrains.python.console.completion.PydevConsoleReference)1 ConsoleCommunication (com.jetbrains.python.console.pydev.ConsoleCommunication)1 PyQualifiedReference (com.jetbrains.python.psi.impl.references.PyQualifiedReference)1 PyReferenceImpl (com.jetbrains.python.psi.impl.references.PyReferenceImpl)1 NotNull (org.jetbrains.annotations.NotNull)1