Search in sources :

Example 26 with XmlAttributeDescriptor

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

the class XmlDtdTest method testAttributeDescriptor3.

public void testAttributeDescriptor3() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT toc ANY> <!ATTLIST toc version CDATA #FIXED \"1.0\">");
    final XmlTag tag = tag("toc");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("version", tag);
    assertTrue(!attributeDescriptor.isRequired());
    assertTrue(attributeDescriptor.isFixed());
    assertTrue(!attributeDescriptor.isEnumerated());
    assertEquals("1.0", attributeDescriptor.getDefaultValue());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 27 with XmlAttributeDescriptor

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

the class XmlDtdTest method testAttributeDescriptor2.

public void testAttributeDescriptor2() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals ANY><!ATTLIST principals path CDATA #IMPLIED>");
    final XmlTag tag = tag("principals");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("path", tag);
    assertTrue(!attributeDescriptor.isRequired());
    assertTrue(!attributeDescriptor.isFixed());
    assertTrue(!attributeDescriptor.isEnumerated());
    assertNull(attributeDescriptor.getDefaultValue());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 28 with XmlAttributeDescriptor

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

the class XmlSchemaTest method testElementDescriptor6.

public void testElementDescriptor6() 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\">" + "       <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:element>" + "   </xsd:sequence>" + "</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 29 with XmlAttributeDescriptor

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

the class XmlSchemaTest method testElementDescriptor12.

public void testElementDescriptor12() 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=\"orderDate2\" type=\"xsd:date\"/>" + "       <xsd:attribute name=\"name\" type=\"xsd:date\"/>" + "     </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(3, attributes.length);
    assertEquals("orderDate", attributes[0].getName());
    assertEquals("orderDate2", attributes[1].getName());
    assertEquals("name", attributes[2].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 30 with XmlAttributeDescriptor

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

the class XmlSchemaTest method testAny3.

public void testAny3() 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\" y:a=\"1\">" + "</root>");
    final XmlTag rootTag = xmlFile.getDocument().getRootTag();
    XmlElementDescriptor rootDescriptor = NSDescriptor.getElementDescriptor(rootTag);
    assertNotNull(rootDescriptor);
    XmlAttribute attribute = rootTag.getAttribute("y:a", XmlUtil.EMPTY_URI);
    assertNotNull(attribute);
    XmlAttributeDescriptor aDescriptor = rootDescriptor.getAttributeDescriptor("y:a", rootTag);
    assertNotNull(aDescriptor);
}
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)

Aggregations

XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)89 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)54 XmlTag (com.intellij.psi.xml.XmlTag)46 XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)32 XmlAttribute (com.intellij.psi.xml.XmlAttribute)18 NotNull (org.jetbrains.annotations.NotNull)11 PsiElement (com.intellij.psi.PsiElement)10 ArrayList (java.util.ArrayList)8 XmlFile (com.intellij.psi.xml.XmlFile)7 AnnotationBackedDescriptor (com.intellij.lang.javascript.flex.AnnotationBackedDescriptor)6 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)6 Nullable (org.jetbrains.annotations.Nullable)6 Project (com.intellij.openapi.project.Project)5 HtmlTag (com.intellij.psi.html.HtmlTag)5 NamespaceAwareXmlAttributeDescriptor (com.intellij.xml.NamespaceAwareXmlAttributeDescriptor)5 AnyXmlAttributeDescriptor (com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor)5 JavaFxPropertyAttributeDescriptor (org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxPropertyAttributeDescriptor)5 LocalQuickFix (com.intellij.codeInspection.LocalQuickFix)3 PsiReference (com.intellij.psi.PsiReference)3 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)2