@NotNull public static List<PsiElement> resolveFromImportStatementSource( @NotNull PyFromImportStatement fromImportStatement, @Nullable QualifiedName qName) { final boolean absoluteImportEnabled = isAbsoluteImportEnabledFor(fromImportStatement); final PsiFile file = fromImportStatement.getContainingFile(); return resolveModule( qName, file, absoluteImportEnabled, fromImportStatement.getRelativeLevel()); }
@NotNull public String getPresentableText(@NotNull String myName) { final StringBuilder sb = new StringBuilder(getQualifiedName(myName, myPath, myImportElement)); PsiElement parent = null; if (myImportElement != null) { parent = myImportElement.getParent(); } if (myImportable instanceof PyFunction) { sb.append(((PyFunction) myImportable).getParameterList().getPresentableText(false)); } else if (myImportable instanceof PyClass) { final List<String> supers = ContainerUtil.mapNotNull( ((PyClass) myImportable).getSuperClasses(), new Function<PyClass, String>() { @Override public String fun(PyClass cls) { return PyUtil.isObjectClass(cls) ? null : cls.getName(); } }); if (!supers.isEmpty()) { sb.append("("); StringUtil.join(supers, ", ", sb); sb.append(")"); } } if (parent instanceof PyFromImportStatement) { sb.append(" from "); final PyFromImportStatement fromImportStatement = (PyFromImportStatement) parent; sb.append(StringUtil.repeat(".", fromImportStatement.getRelativeLevel())); final PyReferenceExpression source = fromImportStatement.getImportSource(); if (source != null) { sb.append(source.getReferencedName()); } } return sb.toString(); }