Search in sources :

Example 11 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class ContentBuilder method visitCMGroup.

public void visitCMGroup(CMGroup e) {
    int forcedMin = (buildPolicy == BUILD_ALL_CONTENT || alwaysVisit) ? 1 : 0;
    int min = Math.max(e.getMinOccur(), forcedMin);
    alwaysVisit = false;
    for (int i = 1; i <= min; i++) {
        if (e.getOperator() == CMGroup.CHOICE) {
            // add only 1 element from the group
            // todo... perhaps add something other than the first one
            CMNodeList nodeList = e.getChildNodes();
            if (nodeList.getLength() > 0) {
                visitCMNode(nodeList.item(0));
            }
        } else // SEQUENCE, ALL
        {
            // visit all of the content
            super.visitCMGroup(e);
        }
    }
}
Also used : CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 12 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class CMPrinter method visitCMGroup.

public void visitCMGroup(CMGroup group) {
    // $NON-NLS-1$
    fStringBuffer.append(indent + "<CMGroup");
    printAttributes(fStringBuffer, group);
    // $NON-NLS-1$
    fStringBuffer.append(">\n");
    incrementIndent();
    CMNodeList nodeList = group.getChildNodes();
    int size = nodeList.getLength();
    for (int i = 0; i < size; i++) {
        visitCMNode(nodeList.item(i));
    }
    decrementIndent();
    // $NON-NLS-1$
    fStringBuffer.append(indent + "</CMGroup>\n");
}
Also used : CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 13 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList 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 14 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList 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 15 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList 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)

Aggregations

CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)23 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)9 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)8 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)5 CMGroup (org.eclipse.wst.xml.core.internal.contentmodel.CMGroup)5 DocumentationImpl (org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl)5 CMContent (org.eclipse.wst.xml.core.internal.contentmodel.CMContent)4 Node (org.w3c.dom.Node)3 URL (java.net.URL)2 List (java.util.List)2 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)2 Element (org.w3c.dom.Element)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1 ContextInformation (org.eclipse.jface.text.contentassist.ContextInformation)1 IContextInformation (org.eclipse.jface.text.contentassist.IContextInformation)1 CMDataType (org.eclipse.wst.xml.core.internal.contentmodel.CMDataType)1 CMDocumentation (org.eclipse.wst.xml.core.internal.contentmodel.CMDocumentation)1 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)1