void (final @NotNull CompletionResultSet result, PsiElement position) { final PsiElementProcessor processor = new PsiElementProcessor() { @Override public boolean execute(final @NotNull PsiElement element) { if (element instanceof XmlEntityDecl xmlEntityDecl) { String name = xmlEntityDecl.getName(); if (name != null && xmlEntityDecl.isInternalReference()) { result.addElement(LookupElementBuilder.create(name).withInsertHandler(XmlCompletionContributor.ENTITY_INSERT_HANDLER)); } } return true; } }; XmlUtil.processXmlElements((XmlFile)position.getContainingFile().getOriginalFile(), processor, true); }