LookupElement (final LookupElement @NotNull [] lookupItems, @NotNull final String lookupString) { for (LookupElement element : lookupItems) { final LookupElementPresentation p = new LookupElementPresentation(); element.renderElement(p); final String elementText = p.getItemText() + p.getTailText(); if (elementText.contains(lookupString)) { return element; } } final String allLookupElements = Arrays.stream(lookupItems) .map(LookupElement::getLookupString) .collect(Collectors.joining(", ")); throw new NoSuchElementException("Unable to find a lookup element by '" + lookupString + "' among [" + allLookupElements + "]"); }