Search in sources :

Example 56 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testElementDescriptor1.

public void testElementDescriptor1() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:element name=\"comment\" type=\"xsd:string\"/>" + "</xsd:schema>");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(XmlTestUtil.tag("purchaseOrder", getProject()));
    assertEquals("purchaseOrder", elementDescriptor.getName());
    elementDescriptor = NSDescriptor.getElementDescriptor(XmlTestUtil.tag("comment", getProject()));
    assertEquals("comment", elementDescriptor.getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor)

Example 57 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testAny4.

public void testAny4() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://foo\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" + "  <xsd:element name=\"root\">" + "    <xsd:complexType>" + "        <xsd:anyAttribute namespace=\"##other\" processContents=\"skip\"/>" + "    </xsd:complexType>" + "  </xsd:element>" + "</xsd:schema>");
    XmlFile xmlFile = (XmlFile) createFile("file.xml", "<root xmlns=\"http://foo\" a=\"1\">" + "</root>");
    final XmlTag rootTag = xmlFile.getDocument().getRootTag();
    XmlElementDescriptor rootDescriptor = NSDescriptor.getElementDescriptor(rootTag);
    assertNotNull(rootDescriptor);
    XmlAttribute attribute = rootTag.getAttribute("a", XmlUtil.EMPTY_URI);
    assertNotNull(attribute);
    XmlAttributeDescriptor aDescriptor = rootDescriptor.getAttributeDescriptor("a", rootTag);
    assertNull(aDescriptor);
    attribute = rootTag.getAttribute("a", "http://foo");
    assertNull(attribute);
    attribute = rootTag.getAttribute("a", XmlUtil.ANT_URI);
    assertNull(attribute);
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlFile(com.intellij.psi.xml.XmlFile) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 58 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlInsightTest method testElementDescriptor4.

public void testElementDescriptor4() throws Exception {
    XmlFile file = createFile("<root><a attr2=''></a><a attr1=''></a></root>");
    XmlNSDescriptor descriptor = createDescriptor(file);
    XmlTag rootTag = file.getDocument().getRootTag();
    XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
    element = element.getElementsDescriptors(rootTag)[0];
    XmlAttributeDescriptor[] attributes = element.getAttributesDescriptors(rootTag);
    assertEquals(2, attributes.length);
    assertEquals("attr1", attributes[0].getName());
    assertEquals("attr2", attributes[1].getName());
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 59 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlInsightTest method testElementDescriptor1.

public void testElementDescriptor1() throws Exception {
    XmlFile file = createFile("<root><a></a><b></b><a></a></root>");
    XmlNSDescriptor descriptor = createDescriptor(file);
    XmlTag rootTag = file.getDocument().getRootTag();
    XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
    XmlElementDescriptor[] elements = element.getElementsDescriptors(rootTag);
    assertEquals(2, elements.length);
    assertEquals("a", elements[0].getName());
    assertEquals("b", elements[1].getName());
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 60 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlInsightTest method testElementDescriptor3.

public void testElementDescriptor3() throws Exception {
    XmlFile file = createFile("<root><a><b/><c></c></a><a><c/></a></root>");
    XmlNSDescriptor descriptor = createDescriptor(file);
    XmlTag rootTag = file.getDocument().getRootTag();
    XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
    element = element.getElementsDescriptors(rootTag)[0];
    XmlElementDescriptor[] elements = element.getElementsDescriptors(rootTag.getSubTags()[0]);
    assertEquals(2, elements.length);
    assertEquals("b", elements[0].getName());
    //assertTrue(elements[0].getContentType() == XmlElementDescriptor.CONTENT_TYPE_EMPTY);
    assertEquals("c", elements[1].getName());
//assertTrue(elements[1].getContentType() == XmlElementDescriptor.CONTENT_TYPE_CHILDREN);
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)87 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)60 XmlTag (com.intellij.psi.xml.XmlTag)52 XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)32 XmlFile (com.intellij.psi.xml.XmlFile)21 Nullable (org.jetbrains.annotations.Nullable)11 XmlDocument (com.intellij.psi.xml.XmlDocument)10 PsiElement (com.intellij.psi.PsiElement)5 XmlAttribute (com.intellij.psi.xml.XmlAttribute)5 AnyXmlElementDescriptor (com.intellij.xml.impl.schema.AnyXmlElementDescriptor)5 XmlNSDescriptorImpl (com.intellij.xml.impl.schema.XmlNSDescriptorImpl)5 CachedValue (com.intellij.psi.util.CachedValue)3 NotNull (org.jetbrains.annotations.NotNull)3 FlexMxmlNSDescriptor (com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 HtmlTag (com.intellij.psi.html.HtmlTag)2 PsiMetaData (com.intellij.psi.meta.PsiMetaData)2 PsiElementProcessor (com.intellij.psi.search.PsiElementProcessor)2 XmlElementDescriptorImpl (com.intellij.xml.impl.schema.XmlElementDescriptorImpl)2