@NotNull
  @Override
  public PsiPolyVariantReference getReference(PyResolveContext context) {
    final PsiFile file = getContainingFile();
    final PyExpression qualifier = getQualifier();

    // Handle import reference
    final PsiElement importParent =
        PsiTreeUtil.getParentOfType(this, PyImportElement.class, PyFromImportStatement.class);
    if (importParent != null) {
      return PyImportReference.forElement(this, importParent, context);
    }

    // Return special reference
    final ConsoleCommunication communication =
        file.getCopyableUserData(PydevConsoleRunner.CONSOLE_KEY);
    if (communication != null) {
      if (qualifier != null) {
        return new PydevConsoleReference(this, communication, qualifier.getText() + ".");
      }
      return new PydevConsoleReference(this, communication, "");
    }

    if (qualifier != null) {
      return new PyQualifiedReference(this, context);
    }

    return new PyReferenceImpl(this, context);
  }
 @NotNull
 public PsiPolyVariantReference getReference(PyResolveContext context) {
   final PyExpression qualifier = getQualifier();
   if (qualifier != null) {
     return new PyQualifiedReference(this, context);
   }
   final PsiElement importParent =
       PsiTreeUtil.getParentOfType(this, PyImportElement.class, PyFromImportStatement.class);
   if (importParent != null) {
     return PyImportReference.forElement(this, importParent, context);
   }
   return new PyDocReference(this, context);
 }