use of com.jetbrains.python.toolbox.ChainIterable in project intellij-community by JetBrains.
the class PyStarImportElementImpl method iterateNames.
@NotNull
public Iterable<PyElement> iterateNames() {
if (getParent() instanceof PyFromImportStatement) {
PyFromImportStatement fromImportStatement = (PyFromImportStatement) getParent();
final List<PsiElement> importedFiles = fromImportStatement.resolveImportSourceCandidates();
ChainIterable<PyElement> chain = new ChainIterable<>();
for (PsiElement importedFile : new HashSet<>(importedFiles)) {
// resolver gives lots of duplicates
final PsiElement source = PyUtil.turnDirIntoInit(importedFile);
if (source instanceof PyFile) {
final PyFile sourceFile = (PyFile) source;
chain.add(filterStarImportableNames(sourceFile.iterateNames(), sourceFile));
}
}
return chain;
}
return Collections.emptyList();
}
use of com.jetbrains.python.toolbox.ChainIterable in project intellij-community by JetBrains.
the class PythonDocumentationProvider method describeFunction.
/**
* Creates a HTML description of function definition.
*
* @param fun the function
* @param funcNameWrapper puts a tag around the function name
* @param escaper sanitizes values that come directly from doc string or code
* @return chain of strings for further chaining
*/
@NotNull
static ChainIterable<String> describeFunction(@NotNull PyFunction fun, FP.Lambda1<Iterable<String>, Iterable<String>> funcNameWrapper, @NotNull FP.Lambda1<String, String> escaper) {
final ChainIterable<String> cat = new ChainIterable<>();
final String name = fun.getName();
cat.addItem("def ").addWith(funcNameWrapper, $(name));
final TypeEvalContext context = TypeEvalContext.userInitiated(fun.getProject(), fun.getContainingFile());
final List<PyParameter> parameters = PyUtil.getParameters(fun, context);
final String paramStr = "(" + StringUtil.join(parameters, parameter -> PyUtil.getReadableRepr(parameter, false), ", ") + ")";
cat.addItem(escaper.apply(paramStr));
if (!PyNames.INIT.equals(name)) {
cat.addItem(escaper.apply("\nInferred type: "));
describeTypeWithLinks(fun, cat);
cat.addItem(BR);
}
return cat;
}
Aggregations