use of com.intellij.psi.xml.XmlAttributeDecl in project intellij-community by JetBrains.
the class AdvancedDtdOptions method prepareNamespaceMap.
public static Map<String, ?> prepareNamespaceMap(Project project, VirtualFile firstFile) {
final PsiFile file = PsiManager.getInstance(project).findFile(firstFile);
if (file == null) {
return Collections.emptyMap();
}
final HashMap<String, Object> map = new LinkedHashMap<>();
file.accept(new PsiRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof XmlElementDecl) {
final String s = ((XmlElementDecl) element).getName();
if (s != null) {
final String[] parts = s.split(":");
if (parts.length > 1) {
map.put(XMLNS + ":" + parts[0], null);
}
}
} else if (element instanceof XmlAttributeDecl) {
final String s = ((XmlAttributeDecl) element).getName();
if (s != null) {
final String[] parts = s.split(":");
if (parts.length > 1) {
map.put(XMLNS + ":" + parts[0], null);
}
}
}
super.visitElement(element);
}
});
return map;
}
Aggregations