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);
}
}
}
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");
}
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());
}
}
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());
}
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());
}
Aggregations