Search in sources :

Example 21 with XmlNSDescriptor

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

the class XmlDtdTest method testAttributeDescriptor4.

public void testAttributeDescriptor4() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT toc ANY> <!ATTLIST toc remote (true|false) \"false\">");
    final XmlTag tag = tag("toc");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
    assertTrue(!attributeDescriptor.isRequired());
    assertTrue(!attributeDescriptor.isFixed());
    assertTrue(attributeDescriptor.isEnumerated());
    assertEquals("false", attributeDescriptor.getDefaultValue());
    String[] values = attributeDescriptor.getEnumeratedValues();
    assertEquals(2, values.length);
    assertEquals("true", values[0]);
    assertEquals("false", values[1]);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 22 with XmlNSDescriptor

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

the class XmlDtdTest method testAttributeDescriptor1.

public void testAttributeDescriptor1() 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);
    assertEquals("path", attributeDescriptor.getName());
    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 23 with XmlNSDescriptor

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

the class XmlDtdTest method testElementDescriptor2.

public void testElementDescriptor2() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals (#PCDATA)><!ELEMENT data-sources ANY>" + "<!ELEMENT read-access (namespace-resource)><!ELEMENT group EMPTY>");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag("principals"));
    assertEquals(elementDescriptor.getContentType(), XmlElementDescriptor.CONTENT_TYPE_MIXED);
    elementDescriptor = NSDescriptor.getElementDescriptor(tag("data-sources"));
    assertEquals(elementDescriptor.getContentType(), XmlElementDescriptor.CONTENT_TYPE_ANY);
    elementDescriptor = NSDescriptor.getElementDescriptor(tag("read-access"));
    assertEquals(elementDescriptor.getContentType(), XmlElementDescriptor.CONTENT_TYPE_CHILDREN);
    elementDescriptor = NSDescriptor.getElementDescriptor(tag("group"));
    assertEquals(elementDescriptor.getContentType(), XmlElementDescriptor.CONTENT_TYPE_EMPTY);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor)

Example 24 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor 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 25 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor 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)

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