void (CompletionParameters parameters, CompletionResultSet result) { if (!parameters.isAutoPopup()) { return; } PsiFile file = parameters.getPosition().getContainingFile(); int offset = parameters.getOffset(); Editor editor = parameters.getEditor(); final CollectCustomTemplateCallback callback = new CollectCustomTemplateCallback(editor, file); ZenCodingGenerator generator = findApplicableDefaultGenerator(callback, false); if (generator != null && generator.addToCompletion()) { final String templatePrefix = computeTemplateKeyWithoutContextChecking(callback); if (templatePrefix != null) { List<TemplateImpl> regularTemplates = TemplateManagerImpl.listApplicableTemplates( TemplateActionContext.expanding(file, offset)); boolean regularTemplateWithSamePrefixExists = !ContainerUtil.filter(regularTemplates, template -> templatePrefix.equals(template.getKey())).isEmpty(); result = result.withPrefixMatcher(result.getPrefixMatcher().cloneWithPrefix(templatePrefix)); result.restartCompletionOnPrefixChange(StandardPatterns.string().startsWith(templatePrefix)); if (!regularTemplateWithSamePrefixExists) { // exclude perfect matches with existing templates because LiveTemplateCompletionContributor handles it final Collection<SingleLineEmmetFilter> extraFilters = ContainerUtil.newLinkedList(new SingleLineEmmetFilter()); try { expand(templatePrefix, callback, generator, extraFilters, false, 0); } catch (EmmetException ignore) { } final TemplateImpl template = callback.getGeneratedTemplate(); if (template != null) { template.setKey(templatePrefix); template.setDescription(template.getTemplateText()); final CustomLiveTemplateLookupElement lookupElement = new CustomLiveTemplateLookupElement(this, template.getKey(), template.getKey(), template.getDescription(), !LiveTemplateCompletionContributor.shouldShowAllTemplates(), true) { @Override public void renderElement(@NotNull LookupElementPresentation presentation) { super.renderElement(presentation); presentation.setTailText("\t Emmet abbreviation", true); } }; result.addElement(lookupElement); } } } else if (result.getPrefixMatcher().getPrefix().isEmpty()) { result.restartCompletionOnPrefixChange(StandardPatterns.string().longerThan(0)); } } }