Search in sources :

Example 1 with DocumentationImpl

use of org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl in project webtools.sourceediting by eclipse.

the class BugFixesTest method testGlobalElementDocumentation.

public void testGlobalElementDocumentation() {
    // See bug 157254
    Bundle bundle = Platform.getBundle("org.eclipse.wst.xsd.core.tests");
    URL url = bundle.getEntry("/testresources/samples/documentation/globalreftest.xsd");
    CMDocument document = XSDImpl.buildCMDocument(url.toExternalForm());
    assertNotNull("Content model loaded Null", document);
    CMNamedNodeMap elements = document.getElements();
    CMElementDeclaration node = (CMElementDeclaration) elements.getNamedItem("rootTest");
    assertNotNull("Missing rootElement", node);
    CMElementDeclaration testElement = (CMElementDeclaration) node.getLocalElements().getNamedItem("test");
    assertNotNull("Missing test element", testElement);
    CMNodeList documentation = (CMNodeList) testElement.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("test global element missing documentation.");
    }
    for (int cnt = 0; cnt < documentation.getLength(); cnt++) {
        DocumentationImpl doc = (DocumentationImpl) documentation.item(cnt);
        assertEquals("Test global element missing documentation.", "This some global documentation", doc.getValue());
    }
    testElement = (CMElementDeclaration) node.getLocalElements().getNamedItem("testElement");
    documentation = (CMNodeList) testElement.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("testElement local element missing documentation.");
    }
    for (int cnt = 0; cnt < documentation.getLength(); cnt++) {
        DocumentationImpl doc = (DocumentationImpl) documentation.item(cnt);
        assertEquals("testElement documentation wrong.", "This is an override", doc.getValue());
    }
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Bundle(org.osgi.framework.Bundle) DocumentationImpl(org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap) URL(java.net.URL) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 2 with DocumentationImpl

use of org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl in project webtools.sourceediting by eclipse.

the class BugFixesTest method testGlobalAttr1Documentation.

private void testGlobalAttr1Documentation(CMNamedNodeMap attributes) {
    CMAttributeDeclaration attribute = (CMAttributeDeclaration) attributes.getNamedItem("globalAttr1");
    assertNotNull("Missing globalAttr1 attribute.");
    CMNodeList documentation = (CMNodeList) attribute.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("Unable to find documentation for globalAttr1");
    }
    assertEquals("Wrong number of documentation annotations.", 2, documentation.getLength());
    assertEquals("Incorrect first annotation for globalAttr1:", "PASS! Documentation for attribute ref overrides the resolved attribute ref documentation", ((DocumentationImpl) documentation.item(0)).getValue().trim());
    assertEquals("Incorrect second annotation for globalAttr1:", "PASS! Multiple documentation elements.", ((DocumentationImpl) documentation.item(1)).getValue().trim());
}
Also used : CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) DocumentationImpl(org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 3 with DocumentationImpl

use of org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl in project webtools.sourceediting by eclipse.

the class BugFixesTest method testGlobalAttr2Documentation.

private void testGlobalAttr2Documentation(CMNamedNodeMap attributes) {
    CMAttributeDeclaration attribute = (CMAttributeDeclaration) attributes.getNamedItem("globalAttr2");
    assertNotNull("Missing globalAttr1 attribute.");
    CMNodeList documentation = (CMNodeList) attribute.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("Unable to find documentation for globalAttr2");
    }
    assertEquals("Wrong number of documentation annotations.", 1, documentation.getLength());
    assertEquals("Incorrect annotation for globalAttr2:", "PASS! Documentation for resolved attribute ref when the attribute ref does not have documentation", ((DocumentationImpl) documentation.item(0)).getValue().trim());
}
Also used : CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) DocumentationImpl(org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 4 with DocumentationImpl

use of org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl in project webtools.sourceediting by eclipse.

the class BugFixesTest method testLocalAttrDocumentation.

private void testLocalAttrDocumentation(CMNamedNodeMap attributes) {
    CMAttributeDeclaration attribute = (CMAttributeDeclaration) attributes.getNamedItem("localAttr");
    assertNotNull("Missing localAttr attribute.");
    CMNodeList documentation = (CMNodeList) attribute.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("Unable to find documentation for localAttr");
    }
    assertEquals("Wrong number of documentation annotations.", 2, documentation.getLength());
    assertEquals("Incorrect annotation for localAttr:", "PASS! Multiple documentation elements for local attribute part 1", ((DocumentationImpl) documentation.item(0)).getValue().trim());
    assertEquals("Incorrect annotation for localAttr:", "PASS! Multiple documentation elements for local attribute part 2", ((DocumentationImpl) documentation.item(1)).getValue().trim());
}
Also used : CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) DocumentationImpl(org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 5 with DocumentationImpl

use of org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl in project webtools.sourceediting by eclipse.

the class BugFixesTest method testGlobalAttr3Documentation.

private void testGlobalAttr3Documentation(CMNamedNodeMap attributes) {
    CMAttributeDeclaration attribute = (CMAttributeDeclaration) attributes.getNamedItem("globalAttr3");
    assertNotNull("Missing globalAttr1 attribute.");
    CMNodeList documentation = (CMNodeList) attribute.getProperty("documentation");
    if (documentation.getLength() == 0) {
        fail("Unable to find documentation for globalAttr3");
    }
    assertEquals("Wrong number of documentation annotations.", 1, documentation.getLength());
    assertEquals("Incorrect annotation for globalAttr3:", "PASS! Documentation for resolved attribute ref when the attribute ref has an annotation but does not have documentation", ((DocumentationImpl) documentation.item(0)).getValue().trim());
}
Also used : CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) DocumentationImpl(org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Aggregations

CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)5 DocumentationImpl (org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl)5 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)4 URL (java.net.URL)1 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)1 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)1 Bundle (org.osgi.framework.Bundle)1