Iterable<LookupElement> (@NotNull String presentNamePart, boolean shouldSurroundWithQuotes) { Predicate<String> conditionFilter; Function<String, String> mapFunction; if (presentNamePart.startsWith("*")) { //TODO darcula etc. should be proposed after *? String tail = presentNamePart.substring(1); conditionFilter = key -> key.endsWith(tail); mapFunction = key -> key.substring(presentNamePart.length() - 1); // + 1 for dot, - 2 for '*.' } else if (presentNamePart.isEmpty()) { conditionFilter = key -> true; mapFunction = key -> key; } else { conditionFilter = key -> StringUtil.startsWithConcatenation(key, presentNamePart, "."); mapFunction = key -> key.substring(presentNamePart.length() + 1); // + 1 for dot } List<LookupElement> variants = new SmartList<>(); PairProcessor<UIThemeMetadata, UIThemeMetadata.UIKeyMetadata> processor = (themeMetadata, uiKeyMetadata) -> { String key = uiKeyMetadata.getKey(); if (!conditionFilter.test(key)) return true; final String completionKey = mapFunction.apply(key); final String description = uiKeyMetadata.getDescription(); final boolean deprecated = uiKeyMetadata.isDeprecated(); final String source = uiKeyMetadata.getSource(); final String since = uiKeyMetadata.getSince(); final LookupElementBuilder builder = LookupElementBuilder.create(completionKey) .withPresentableText(key) .withStrikeoutness(deprecated) .appendTailText(StringUtil.isEmpty(since) ? "" : " [" + since + "]", true) .appendTailText(StringUtil.isEmpty(description) ? "" : " (" + description + ")", true) .appendTailText(StringUtil.isEmpty(source) ? "" : " " + source, true) .withTypeText("[" + ObjectUtils.chooseNotNull(themeMetadata.getName(), themeMetadata.getPluginId()) + "]") .withInsertHandler(shouldSurroundWithQuotes ? MyInsertHandler.SURROUND_WITH_QUOTES : MyInsertHandler.INSTANCE); variants.add(deprecated ? PrioritizedLookupElement.withPriority(builder, -100) : builder); return true; }; UIThemeMetadataService.getInstance().processAllKeys(processor); return variants; }