Search in sources :

Example 16 with XmlNSDescriptor

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

the class XmlSchemaTest method testAttributeDescriptorProhibited2.

public void testAttributeDescriptorProhibited2() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + "    <xsd:complexContent>" + "     <xsd:restriction base=\"PurchaseOrderType2\">" + "       <xsd:attribute name=\"orderDate\" type=\"xsd:date\" use=\"prohibited\"/>" + "     </xsd:restriction>" + "    </xsd:complexContent>" + "</xsd:complexType>" + "<xsd:complexType name=\"PurchaseOrderType2\">" + "   <xsd:sequence>" + "     <xsd:attribute name=\"orderDate\" type=\"xsd:date\"/>" + "     <xsd:attribute name=\"name\" type=\"xsd:string\"/>" + "   </xsd:sequence>" + "</xsd:complexType>" + "</xsd:schema>");
    final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
    assertEquals(1, attributes.length);
    assertEquals("name", attributes[0].getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 17 with XmlNSDescriptor

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

the class XmlSchemaTest method testElementDescriptor5.

public void testElementDescriptor5() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + "   <xsd:sequence>" + "     <xsd:element name=\"shipTo\" type=\"USAddress\"/>" + "     <xsd:element name=\"billTo\" type=\"USAddress\"/>" + "     <xsd:element name=\"items\" type=\"Items\"/>" + "   </xsd:sequence>" + "</xsd:complexType>" + "<xsd:complexType name=\"USAddress\">" + "  <xsd:sequence>" + "    <xsd:element name=\"name\" type=\"xsd:string\"/>" + "    <xsd:element name=\"street\" type=\"xsd:string\"/>" + "    <xsd:element name=\"city\" type=\"xsd:string\"/>" + "    <xsd:element name=\"state\" type=\"xsd:string\"/>" + "    <xsd:element name=\"zip\" type=\"xsd:decimal\"/>" + "  </xsd:sequence>" + "  <xsd:attribute name=\"country\" type=\"xsd:NMTOKEN\" fixed=\"US\"/>" + "</xsd:complexType>" + "</xsd:schema>");
    XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag).getElementDescriptor(SHIP_TO, null);
    XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
    assertEquals(5, elements.length);
    assertEquals("name", elements[0].getName());
    assertEquals("street", elements[1].getName());
    assertEquals("city", elements[2].getName());
    assertEquals("state", elements[3].getName());
    assertEquals("zip", elements[4].getName());
    final XmlTag context = tag.findFirstSubTag(elements[2].getName());
    assertEquals(0, elements[2].getElementsDescriptors(context).length);
    XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(context);
    assertEquals(1, attributes.length);
    assertEquals("country", attributes[0].getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 18 with XmlNSDescriptor

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

the class XmlSchemaTest method testElementDescriptor15.

public void testElementDescriptor15() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + "    <xsd:complexContent>" + "     <xsd:extension base=\"PurchaseOrderType2\">" + "       <xsd:element name=\"shipTo2\" type=\"USAddress\"/>" + "     </xsd:extension>" + "    </xsd:complexContent>" + "</xsd:complexType>" + "<xsd:complexType name=\"PurchaseOrderType2\">" + "   <xsd:sequence>" + "     <xsd:element name=\"shipTo\" type=\"USAddress\"/>" + "     <xsd:element name=\"billTo\" type=\"USAddress\"/>" + "     <xsd:element name=\"items\" type=\"Items\"/>" + "   </xsd:sequence>" + "</xsd:complexType>" + "</xsd:schema>");
    XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
    assertEquals(4, elements.length);
    assertEquals("shipTo", elements[0].getName());
    assertEquals("billTo", elements[1].getName());
    assertEquals("items", elements[2].getName());
    assertEquals("shipTo2", elements[3].getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 19 with XmlNSDescriptor

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

the class XmlDtdTest method testEntityDeclElement1.

public void testEntityDeclElement1() throws Exception {
    final XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % types \"fileset | patternset \"> <!ELEMENT project (target | taskdef | %types; | property )*> " + "<!ELEMENT target><!ELEMENT taskdef><!ELEMENT fileset><!ELEMENT patternset><!ELEMENT property>");
    XmlTag projectTag = tag("project");
    final XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(projectTag);
    final XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(projectTag);
    assertEquals(5, elements.length);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 20 with XmlNSDescriptor

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

the class XmlDtdTest method testEntityDecl2.

public void testEntityDecl2() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % coreattrs \"id D #IMPLIED\"> <!ELEMENT a ANY> <!ATTLIST a %coreattrs; version CDATA #FIXED \"1.0\"");
    final XmlTag tag = tag("a");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    final XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
    assertEquals(2, attributes.length);
    assertEquals("id", attributes[0].getName());
    assertEquals("version", attributes[1].getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) 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