Search in sources :

Example 31 with XmlNSDescriptor

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"));
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptorImpl(com.intellij.xml.impl.schema.XmlElementDescriptorImpl) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 32 with XmlNSDescriptor

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());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 33 with XmlNSDescriptor

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));
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 34 with XmlNSDescriptor

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));
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor)

Example 35 with XmlNSDescriptor

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);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlFile(com.intellij.psi.xml.XmlFile) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) FlexMxmlNSDescriptor(com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)

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