static Collection<LookupElement> createFromPsiItems(Collection<? extends PsiNamedElement> elements, @Nullable Icon icon, @Nullable Integer groupId) { return elements.stream().map(psi -> { LookupElementBuilder element = LookupElementBuilder.create(psi).withCaseSensitivity(true); if (icon != null) { element = element.withIcon(icon); } if (groupId != null) { return PrioritizedLookupElement.withGrouping(element, groupId); } return element; }).collect(Collectors.toList()); }
static Collection<LookupElement> createPathItems(List<String> osPathes) { return osPathes.stream() .map(path -> //fix the windows file and directory pathes to be cygwin compatible SystemInfoRt.isWindows ? OSUtil.toBashCompatible(path) : path ) .map(path -> { int groupId = path.startsWith("/") ? CompletionGrouping.AbsoluteFilePath.ordinal() : CompletionGrouping.RelativeFilePath.ordinal(); return PrioritizedLookupElement.withGrouping(createPathLookupElement(path, !path.endsWith("/")), groupId); }).collect(Collectors.toList()); }
static Collection<LookupElement> createItems(Collection<String> lookupStrings, final Icon icon, boolean trimLookupString, Integer groupId) { return lookupStrings .stream() .map(item -> { LookupElementBuilder elementBuilder = LookupElementBuilder.create(item).withCaseSensitivity(true); if (icon != null) { elementBuilder = elementBuilder.withIcon(icon); } if (trimLookupString) { elementBuilder = elementBuilder.withLookupString(item.replace("_", "")); } if (groupId != null) { return PrioritizedLookupElement.withGrouping(elementBuilder, groupId); } return elementBuilder; }) .collect(Collectors.toList()); }