use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testNamespace2.
public void testNamespace2() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element ref=\"xsd:items\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "<xsd:element name=\"items\" type=\"xsd:string\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", "http://www.w3.org/2001/XMLSchema", getProject());
XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl) NSDescriptor.getElementDescriptor(tag);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("items", elements[0].getName());
assertEquals("items", elementDescriptor.getElementDescriptor("items").getName());
assertNull(elementDescriptor.getElementDescriptor("xxx"));
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor14.
public void testElementDescriptor14() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://www.deansoft.com/AddressBook\" xmlns:ab=\"http://www.deansoft.com/AddressBook\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\">" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element ref=\"shipTo\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "</xsd:element>" + "<xsd:element name=\"shipTo\" abstract=\"true\">" + " <xsd:complexType name=\"USAddress\">" + " <xsd:attribute name=\"orderDate\" type=\"xsd:date\"/>" + " <xsd:element name=\"items\" type=\"Items\"/>" + " </xsd:complexType>" + "</xsd:element>" + "<xsd:element name=\"name\" substitutionGroup=\"ab:shipTo\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", "http://www.deansoft.com/AddressBook", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
final XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("name", elements[0].getName());
XmlAttributeDescriptor[] attrs = elements[0].getAttributesDescriptors(tag);
assertEquals(1, attrs.length);
assertEquals("orderDate", attrs[0].getName());
XmlElementDescriptor[] element0Descriptors = elements[0].getElementsDescriptors(tag.findFirstSubTag(elements[0].getName()));
assertEquals(1, element0Descriptors.length);
assertEquals("items", element0Descriptors[0].getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor8.
public void testElementDescriptor8() 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 ref=\"items\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "<xsd:element name=\"items\" type=\"xsd:string\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("items", elements[0].getName());
assertEquals("items", elementDescriptor.getElementDescriptor(XmlTestUtil.tag("items", getProject()), null).getName());
assertNull(elementDescriptor.getElementDescriptor(UNKNOWN_TAG, null));
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testDocumentDescriptor1.
public void testDocumentDescriptor1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:element name=\"comment\" type=\"xsd:string\"/>" + "</xsd:schema>");
assertNotNull(NSDescriptor);
assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("purchaseOrder", getProject())));
assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("comment", getProject())));
assertNull(NSDescriptor.getElementDescriptor(UNKNOWN_TAG));
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-plugins by JetBrains.
the class FlexHighlightingTest method testDumbMode.
@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithGumboSdk })
@SuppressWarnings({ "ConstantConditions" })
public void testDumbMode() throws Exception {
DumbServiceImpl.getInstance(getProject()).setDumb(true);
((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject())).mustWaitForSmartMode(false, getTestRootDisposable());
XmlNSDescriptor nsDescriptor;
try {
assertTrue(DumbService.isDumb(getProject()));
configureByFile(getBasePath() + "/dumbMode.mxml");
nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
doDoTest(true, true);
} finally {
DumbServiceImpl.getInstance(getProject()).setDumb(false);
}
nsDescriptor = ((XmlFile) getFile()).getDocument().getRootTagNSDescriptor();
assertTrue(nsDescriptor.toString(), nsDescriptor instanceof FlexMxmlNSDescriptor);
doDoTest(true, true);
}
Aggregations