boolean (final @NotNull PsiElement queryParameters, final @NotNull Processor<? super PsiElement> consumer) { if (queryParameters instanceof XmlTag xml) { if (ReadAction.compute(() -> isTypeElement(xml))) { final Collection<SchemaTypeInfo> infos = ReadAction.compute(() -> gatherInheritors(xml)); if (infos != null && ! infos.isEmpty()) { final XmlFile file = XmlUtil.getContainingFile(xml); final Project project = file.getProject(); final Module module = ModuleUtilCore.findModuleForPsiElement(queryParameters); //if (module == null) return false; final VirtualFile vf = file.getVirtualFile(); String thisNs = ReadAction.compute(() -> XmlNamespaceIndex.getNamespace(vf, project)); thisNs = thisNs == null ? getDefaultNs(file) : thisNs; // so thisNs can be null if (thisNs == null) return false; final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<>(infos); Collections.sort(infosLst); final Map<String, Set<XmlFile>> nsMap = new HashMap<>(); for (final SchemaTypeInfo info : infosLst) { Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri()); if (targetFiles == null) { targetFiles = new HashSet<>(); if (Objects.equals(info.getNamespaceUri(), thisNs)) { targetFiles.add(file); } final Collection<XmlFile> files = ReadAction.compute(() -> XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module)); if (files != null) { targetFiles.addAll(files); } nsMap.put(info.getNamespaceUri(), targetFiles); } if (! targetFiles.isEmpty()) { for (final XmlFile targetFile : targetFiles) { ApplicationManager.getApplication().runReadAction(() -> { final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri()); if (prefixByURI == null) return; final PsiElementProcessor processor = new PsiElementProcessor() { @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlTag) { if (isCertainTypeElement((XmlTag)element, info.getTagName(), prefixByURI) || isElementWithEmbeddedType((XmlTag)element, info.getTagName(), prefixByURI)) { consumer.process(element); return false; } } return true; } }; XmlUtil.processXmlElements(targetFile, processor, true); }); } } } } } } return true; }