void (AtomicBoolean templatesShown, Map<TemplateImpl, String> templates, List<? extends TemplateImpl> availableTemplates, CompletionResultSet result, boolean isAutopopup) { if (!templatesShown.getAndSet(true)) { var templateKeys = ContainerUtil.map(availableTemplates, template -> template.getKey()); result.restartCompletionOnPrefixChange(StandardPatterns.string().with(new PatternCondition<>("type after non-identifier") { @Override public boolean accepts(@NotNull String s, ProcessingContext context) { return s.length() > 1 && !Character.isJavaIdentifierPart(s.charAt(s.length() - 2)) && ContainerUtil.exists(templateKeys, template -> s.endsWith(template)); } })); for (final Map.Entry<TemplateImpl, String> entry : templates.entrySet()) { ProgressManager.checkCanceled(); if (isAutopopup && entry.getKey().getShortcutChar() == TemplateSettings.NONE_CHAR) continue; result.withPrefixMatcher(result.getPrefixMatcher().cloneWithPrefix(StringUtil.notNullize(entry.getValue()))) .addElement(new LiveTemplateLookupElementImpl(entry.getKey(), false)); } } }