use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class HtmlNSDescriptorImpl method getCommonAttributeDescriptors.
public static XmlAttributeDescriptor[] getCommonAttributeDescriptors(XmlTag context) {
final XmlNSDescriptor nsDescriptor = context != null ? context.getNSDescriptor(context.getNamespace(), false) : null;
if (nsDescriptor instanceof HtmlNSDescriptorImpl) {
XmlElementDescriptor descriptor = ((HtmlNSDescriptorImpl) nsDescriptor).getElementDescriptorByName("div");
descriptor = descriptor == null ? ((HtmlNSDescriptorImpl) nsDescriptor).getElementDescriptorByName("span") : descriptor;
if (descriptor != null) {
return descriptor.getAttributesDescriptors(context);
}
}
return XmlAttributeDescriptor.EMPTY;
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testAttributeDescriptor2.
public void testAttributeDescriptor2() throws Exception {
XmlFile file = createFile("<root><a c='' a=''></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("c", attributes[0].getName());
assertTrue(attributes[0].isRequired());
assertEquals("a", attributes[1].getName());
assertTrue(attributes[1].isRequired());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testAttributeDescriptor1.
public void testAttributeDescriptor1() throws Exception {
XmlFile file = createFile("<root><a attr1=''></a><a attr2='' 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("attr1", attributes[0].getName());
assertTrue(attributes[0].isRequired());
assertEquals("attr2", attributes[1].getName());
assertTrue(!attributes[1].isRequired());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testElementDescriptor2.
public void testElementDescriptor2() throws Exception {
XmlFile file = createFile("<root><a><b/></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());
assertEquals("c", elements[1].getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor10.
public void testElementDescriptor10() 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:attributeGroup ref=\"ddd:bookAttributes\"/>" + "</xsd:complexType>" + "<xsd:attributeGroup name=\"bookAttributes\">" + " <xsd:attribute name=\"isbn\" type=\"xs:string\" use=\"required\"/>" + " <xsd:attribute name=\"available\" type=\"xs:string\"/>" + "</xsd:attributeGroup>" + "</xsd:schema>");
final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(2, attributes.length);
assertEquals("isbn", attributes[0].getName());
assertEquals("available", attributes[1].getName());
assertEquals("isbn", elementDescriptor.getAttributeDescriptor("isbn", tag).getName());
assertNull(elementDescriptor.getAttributeDescriptor("xxx", tag));
}
Aggregations