void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, final @NotNull CompletionResultSet result) { final PsiElement position = parameters.getPosition(); if (!position.getLanguage().isKindOf(XMLLanguage.INSTANCE)) { return; } final XmlAttributeValue attributeValue = PsiTreeUtil.getParentOfType(position, XmlAttributeValue.class, false); if (attributeValue == null) { // we are injected, only getContext() returns attribute value return; } final Set<String> usedWords = new HashSet<>(); final Ref<Boolean> addWordVariants = Ref.create(true); result.runRemainingContributors(parameters, r -> { if (r.getLookupElement().getUserData(WORD_COMPLETION_COMPATIBLE) == null) { addWordVariants.set(false); } usedWords.add(r.getLookupElement().getLookupString()); result.passResult(r.withLookupElement(LookupElementDecorator.withInsertHandler(r.getLookupElement(), QUOTE_EATER))); }); if (addWordVariants.get().booleanValue()) { addWordVariants.set(attributeValue.getReferences().length == 0); } if (addWordVariants.get().booleanValue() && parameters.getInvocationCount() > 0) { WordCompletionContributor.addWordCompletionVariants(result, parameters, usedWords); } }