use of com.intellij.psi.XmlRecursiveElementWalkingVisitor in project intellij-community by JetBrains.
the class HtmlUtil method getIncludedPathsElements.
public static List<XmlAttributeValue> getIncludedPathsElements(@NotNull final XmlFile file) {
final List<XmlAttributeValue> result = new ArrayList<>();
file.acceptChildren(new XmlRecursiveElementWalkingVisitor() {
@Override
public void visitXmlTag(XmlTag tag) {
XmlAttribute attribute = null;
if ("link".equalsIgnoreCase(tag.getName())) {
attribute = tag.getAttribute("href");
} else if ("script".equalsIgnoreCase(tag.getName()) || "img".equalsIgnoreCase(tag.getName())) {
attribute = tag.getAttribute("src");
}
if (attribute != null)
result.add(attribute.getValueElement());
super.visitXmlTag(tag);
}
@Override
public void visitElement(PsiElement element) {
if (element.getLanguage() instanceof XMLLanguage) {
super.visitElement(element);
}
}
});
return result.isEmpty() ? Collections.emptyList() : result;
}
use of com.intellij.psi.XmlRecursiveElementWalkingVisitor in project intellij-plugins by JetBrains.
the class AngularAttributeIndexer method map.
@NotNull
@Override
public Map<String, AngularNamedItemDefinition> map(@NotNull FileContent inputData) {
final Map<String, AngularNamedItemDefinition> map = new HashMap<>();
final PsiFile file = inputData.getPsiFile();
if (file instanceof XmlFile) {
file.accept(new XmlRecursiveElementWalkingVisitor() {
@Override
public void visitXmlAttribute(XmlAttribute attribute) {
if (myAttributeName.equals(DirectiveUtil.normalizeAttributeName(attribute.getName()))) {
final XmlAttributeValue element = attribute.getValueElement();
if (element == null) {
map.put("", new AngularNamedItemDefinition("", attribute.getTextRange().getStartOffset()));
} else {
final String name = StringUtil.unquoteString(element.getText());
map.put(name, new AngularNamedItemDefinition(name, element.getTextRange().getStartOffset()));
}
}
}
});
}
return map;
}
Aggregations