Search in sources :

Example 61 with XmlNSDescriptor

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

the class XmlInsightTest method testDocumentDescriptor1.

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

Example 62 with XmlNSDescriptor

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

the class XmlDtdTest method testEntityDecl1.

public void testEntityDecl1() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % boolean \"(true|false|on|off|yes|no)\"> <!ELEMENT toc ANY> <!ATTLIST toc remote %boolean; \"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(6, values.length);
    assertEquals("true", values[0]);
    assertEquals("false", values[1]);
    assertEquals("on", values[2]);
    assertEquals("off", values[3]);
    assertEquals("yes", values[4]);
    assertEquals("no", values[5]);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 63 with XmlNSDescriptor

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

the class XmlDtdTest method testEntityDecl4.

public void testEntityDecl4() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % boolean \'(true|false|on|off|yes|no)\'> <!ENTITY % bool \"%boolean;\">  <!ELEMENT toc ANY> <!ATTLIST toc remote %bool; \"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(6, values.length);
    assertEquals("true", values[0]);
    assertEquals("false", values[1]);
    assertEquals("on", values[2]);
    assertEquals("off", values[3]);
    assertEquals("yes", values[4]);
    assertEquals("no", values[5]);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 64 with XmlNSDescriptor

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

the class XmlDtdTest method testEntityDecl3.

public void testEntityDecl3() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % att1 \"id1 D #IMPLIED\"> <!ENTITY % att2 \"id2 D #IMPLIED\"> <!ELEMENT a ANY> <!ATTLIST a %att1; %att2; ");
    final XmlTag tag = tag("a");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    final XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
    assertEquals(2, attributes.length);
    assertEquals("id1", attributes[0].getName());
    assertEquals("id2", 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)

Example 65 with XmlNSDescriptor

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

the class XmlDtdTest method testElementDescriptor1.

public void testElementDescriptor1() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals (#PCDATA)><!ELEMENT data-sources (#PCDATA)>");
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag("principals"));
    assertEquals("principals", elementDescriptor.getName());
    elementDescriptor = NSDescriptor.getElementDescriptor(tag("data-sources"));
    assertEquals("data-sources", elementDescriptor.getName());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor)

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