use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class DomGenPanel method createUIComponents.
private void createUIComponents() {
mySchemaLocation = new TextFieldWithBrowseButton();
final String title = "Choose XSD or DTD schema";
mySchemaLocation.addBrowseFolderListener(title, "Make sure there are only necessary schemes in directory where your XSD or DTD schema is located", myProject, new FileTypeDescriptor(title, "xsd", "dtd"));
mySchemaLocation.getTextField().setEditable(false);
mySchemaLocation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final File file = new File(mySchemaLocation.getText());
if (file.exists() && file.getName().toLowerCase().endsWith(".xsd")) {
final VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file);
if (vf != null) {
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(vf);
if (psiFile instanceof XmlFile) {
final XmlDocument xml = ((XmlFile) psiFile).getDocument();
if (xml != null) {
final XmlTag rootTag = xml.getRootTag();
if (rootTag != null) {
String target = null;
ArrayList<String> ns = new ArrayList<>();
for (XmlAttribute attr : rootTag.getAttributes()) {
if ("targetNamespace".equals(attr.getName())) {
target = attr.getValue();
} else if (attr.getName().startsWith("xmlns")) {
ns.add(attr.getValue());
}
}
ns.remove(target);
if (target != null) {
myNamespace.setText(target);
}
mySkipSchemas.setText(StringUtil.join(ArrayUtil.toStringArray(ns), "\n"));
}
}
}
}
}
}
});
myOutputDir = new TextFieldWithBrowseButton();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myOutputDir.addBrowseFolderListener("Select Output Directory For Generated Files", "", myProject, descriptor);
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class RegistrationCheckerUtil method processPluginXml.
private static void processPluginXml(XmlFile xmlFile, RegistrationTypeFinder finder, boolean includeActions) {
final XmlDocument document = xmlFile.getDocument();
if (document == null)
return;
final XmlTag rootTag = document.getRootTag();
if (rootTag == null)
return;
DescriptorUtil.processComponents(rootTag, finder);
if (includeActions) {
DescriptorUtil.processActions(rootTag, finder);
}
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class UpdateJspxFileCopyright method scanFile.
protected void scanFile() {
logger.debug("updating " + getFile().getVirtualFile());
XmlDocument doc = ((XmlFile) getFile()).getDocument();
XmlProlog xmlProlog = doc.getProlog();
if (xmlProlog == null) {
return;
}
PsiElement elem = xmlProlog.getFirstChild();
PsiElement docTypeStart = null;
while (elem != null) {
if (elem instanceof XmlDoctype) {
docTypeStart = elem;
break;
}
elem = getNextSibling(elem);
}
PsiElement first = xmlProlog.getFirstChild();
int location = getLanguageOptions().getFileLocation();
if (docTypeStart != null) {
final ArrayList<PsiComment> comments = new ArrayList<>();
collectComments(doc.getFirstChild(), xmlProlog, comments);
collectComments(first, docTypeStart, comments);
checkComments(first, location == XmlOptions.LOCATION_BEFORE_DOCTYPE, comments);
checkComments(docTypeStart, doc.getRootTag(), location == XmlOptions.LOCATION_BEFORE_ROOTTAG);
return;
} else if (location == XmlOptions.LOCATION_BEFORE_DOCTYPE) {
location = XmlOptions.LOCATION_BEFORE_ROOTTAG;
}
final ArrayList<PsiComment> comments = new ArrayList<>();
collectComments(doc.getFirstChild(), xmlProlog, comments);
collectComments(first, doc.getRootTag(), comments);
checkComments(doc.getRootTag(), location == XmlOptions.LOCATION_BEFORE_ROOTTAG, comments);
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class NamespaceCollector method collectInfo.
public static CollectedInfo collectInfo(final XmlFile psiFile) {
final NamespaceCollector namespaceCollector = new NamespaceCollector();
final XmlDocument document = psiFile.getDocument();
if (document != null) {
document.accept(namespaceCollector);
}
return new CollectedInfo(namespaceCollector.namespaces, namespaceCollector.elements, namespaceCollector.attributes);
}
use of com.intellij.psi.xml.XmlDocument in project intellij-community by JetBrains.
the class JavaFxNamespaceDescriptor method init.
@Override
public void init(PsiElement element) {
XmlDocument document = (XmlDocument) element;
myFile = ((XmlFile) document.getContainingFile());
}
Aggregations