use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class XsltRunConfiguration method initFromFile.
public XsltRunConfiguration initFromFile(@NotNull XmlFile file) {
assert XsltSupport.isXsltFile(file) : "Not an XSLT file: " + file.getName();
mySuggestedName = file.getName();
final VirtualFile virtualFile = file.getVirtualFile();
assert virtualFile != null : "No VirtualFile for " + file.getName();
setXsltFile(virtualFile);
final PsiFile[] associations = FileAssociationsManager.getInstance(file.getProject()).getAssociationsFor(file);
if (associations.length > 0) {
final VirtualFile assoc = associations[0].getVirtualFile();
assert assoc != null;
setXmlInputFile(assoc);
}
final XmlDocument document = file.getDocument();
assert document != null : "XSLT file without document?";
final XmlTag rootTag = document.getRootTag();
assert rootTag != null : "XSLT file without root element?";
final XmlTag[] params = rootTag.findSubTags("param", XsltSupport.XSLT_NS);
for (XmlTag param : params) {
final String name = param.getAttributeValue("name");
if (name != null) {
final Pair<String, String> pair = Pair.create(name, null);
myParameters.add(pair);
}
}
final XmlTag[] outputs = rootTag.findSubTags("output", XsltSupport.XSLT_NS);
for (XmlTag output : outputs) {
final String method = output.getAttributeValue("method");
if ("xml".equals(method)) {
setFileType(StdFileTypes.XML);
} else if ("html".equals(method)) {
setFileType(StdFileTypes.HTML);
} else if ("text".equals(method)) {
setFileType(FileTypes.PLAIN_TEXT);
}
}
return this;
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class NamespaceCollector method findAllNamespaces.
public static Set<Namespace> findAllNamespaces(final XmlFile psiFile) {
final NamespaceCollector namespaceCollector = new NamespaceCollector();
final XmlDocument document = psiFile.getDocument();
if (document != null) {
document.accept(namespaceCollector);
}
return namespaceCollector.namespaces;
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class NamespaceCollector method findNamespaces.
public static Map<String, String> findNamespaces(final XmlFile psiFile) {
final NamespaceCollector namespaceCollector = new NamespaceCollector();
final XmlDocument document = psiFile.getDocument();
if (document != null) {
document.accept(namespaceCollector);
}
final Set<Namespace> namespaces = namespaceCollector.namespaces;
return convert(namespaces);
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class ResolvingVisitor method processInclude.
private void processInclude(XmlFile xmlFile, XmlAttribute attribute) {
final Set<XmlFile> set = myProcessingContext.get(VISITED_KEY);
if (set.contains(xmlFile)) {
return;
}
set.add(xmlFile);
final XmlDocument document = xmlFile.getDocument();
if (document == null)
return;
final XmlTag rootTag = document.getRootTag();
if (rootTag == null)
return;
rootTag.processElements(this, attribute);
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class Html5SectionsNodeProvider method provideNodes.
@NotNull
@Override
public Collection<Html5SectionTreeElement> provideNodes(@NotNull final TreeElement node) {
if (!(node instanceof HtmlFileTreeElement))
return Collections.emptyList();
final XmlFile xmlFile = ((HtmlFileTreeElement) node).getElement();
final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
if (document == null)
return Collections.emptyList();
final List<XmlTag> rootTags = new ArrayList<>();
document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);
final Collection<Html5SectionTreeElement> result = new ArrayList<>();
for (XmlTag tag : rootTags) {
result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag));
}
return result;
}
Aggregations