UsageSearcher () { return new UsageSearcher() { final Set<UsageInfo> usages = new HashSet<>(); @Override public void generate(@NotNull final Processor<? super Usage> processor) { ApplicationManager.getApplication().runReadAction(() -> { collectUsages(myModel); for (MavenDomProjectModel model : MavenDomProjectProcessorUtils.getChildrenProjects(myModel)) { collectUsages(model); } for (UsageInfo usage : usages) { processor.process(UsageInfo2UsageAdapter.CONVERTER.fun(usage)); } }); } private void collectUsages(@NotNull MavenDomProjectModel model) { if (model.isValid()) { final XmlElement root = model.getXmlElement(); if (root != null) { root.acceptChildren(new XmlElementVisitor() { @Override public void visitXmlText(@NotNull XmlText text) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { usages.addAll(getUsages(text)); } } @Override public void visitXmlAttributeValue(@NotNull XmlAttributeValue value) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); if (xmlTag != null && !xmlTag.equals(root)) { usages.addAll(getUsages(value)); } } @Override public void visitXmlElement(@NotNull XmlElement element) { element.acceptChildren(this); } }); } } } @NotNull private Set<UsageInfo> getUsages(@NotNull XmlElement xmlElement) { String s = xmlElement.getText(); if (StringUtil.isEmptyOrSpaces(s)) return Collections.emptySet(); int start = s.indexOf(mySelectedString); if (start == -1) return Collections.emptySet(); Set<UsageInfo> usages = new HashSet<>(); List<TextRange> ranges = getPropertiesTextRanges(s); TextRange elementTextRange = xmlElement.getTextRange(); PsiFile containingFile = xmlElement.getContainingFile(); do { int end = start + mySelectedString.length(); boolean isInsideProperty = isIntersectWithRanges(ranges, start, end); if (!isInsideProperty) { usages .add(new UsageInfo(containingFile, elementTextRange.getStartOffset() + start, elementTextRange.getStartOffset() + end)); } start = s.indexOf(mySelectedString, end); } while (start != -1); return usages; } }; }