void (List<LookupElement> elements, @NotNull XmlTag tag, String prefix) { final List<String> namespaces; if (prefix.isEmpty()) { namespaces = new ArrayList<>(Arrays.asList(tag.knownNamespaces())); namespaces.add(XmlUtil.EMPTY_URI); // empty namespace } else { namespaces = new ArrayList<>(Collections.singletonList(tag.getNamespace())); } PsiFile psiFile = tag.getContainingFile(); XmlExtension xmlExtension = XmlExtension.getExtension(psiFile); List<XmlElementDescriptor> variants = TagNameVariantCollector.getTagDescriptors(tag, namespaces, null); if (psiFile instanceof XmlFile && ((XmlFile)psiFile).getRootTag() == tag) { addXmlProcessingInstructions(elements, tag); if (variants.isEmpty()) { getRootTagsVariants(tag, elements); return; } } final Set<String> visited = new HashSet<>(); for (XmlElementDescriptor descriptor : variants) { String qname = descriptor.getName(tag); if (!visited.add(qname)) continue; if (!prefix.isEmpty() && qname.startsWith(prefix + ":")) { qname = qname.substring(prefix.length() + 1); } PsiElement declaration = descriptor.getDeclaration(); if (declaration != null && !declaration.isValid()) { LOG.error(descriptor + " contains invalid declaration: " + declaration); } LookupElementBuilder lookupElement = declaration == null ? LookupElementBuilder.create(qname) : LookupElementBuilder.create(declaration, qname); final int separator = qname.indexOf(':'); if (separator > 0) { lookupElement = lookupElement.withLookupString(qname.substring(separator + 1)); } Icon icon = AllIcons.Nodes.Tag; if (descriptor instanceof PsiPresentableMetaData) { icon = ((PsiPresentableMetaData)descriptor).getIcon(); } lookupElement = lookupElement.withIcon(icon); if (xmlExtension.useXmlTagInsertHandler()) { lookupElement = lookupElement.withInsertHandler(XmlTagInsertHandler.INSTANCE); } boolean deprecated = descriptor instanceof XmlDeprecationOwnerDescriptor && ((XmlDeprecationOwnerDescriptor)descriptor).isDeprecated(); if (deprecated) { lookupElement = lookupElement.withStrikeoutness(true); } lookupElement = lookupElement.withCaseSensitivity(!(descriptor instanceof HtmlElementDescriptorImpl)); elements.add(PrioritizedLookupElement.withPriority(lookupElement, deprecated ? -1 : separator > 0 ? 0 : 1)); } }