use of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration in project webtools.sourceediting by eclipse.
the class BugFixesTest method testGlobalAttr4Documentation.
private void testGlobalAttr4Documentation(CMNamedNodeMap attributes) {
CMAttributeDeclaration attribute = (CMAttributeDeclaration) attributes.getNamedItem("globalAttr4");
assertNotNull("Missing globalAttr1 attribute.");
CMNodeList documentation = (CMNodeList) attribute.getProperty("documentation");
if (documentation.getLength() == 0) {
fail("Documentation element not returned for globalAttr4");
}
assertNull("globalAttr4 returned data when non expected.", ((DocumentationImpl) documentation.item(0)).getValue());
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration 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());
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration 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());
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration in project webtools.sourceediting by eclipse.
the class CMDocumentFactoryTLD method createElementDeclaration.
protected CMElementDeclaration createElementDeclaration(CMDocument document, Node tagNode) {
CMElementDeclarationImpl ed = new CMElementDeclarationImpl(document);
Node child = tagNode.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
// tag information
String nodeName = child.getNodeName();
if (nodeName.equals(JSP11TLDNames.NAME) && child.hasChildNodes()) {
ed.setNodeName(getContainedText(child));
} else if ((nodeName.equals(JSP11TLDNames.TAGCLASS) || nodeName.equals(JSP12TLDNames.TAG_CLASS)) && child.hasChildNodes()) {
ed.setTagclass(getContainedText(child));
} else if ((nodeName.equals(JSP11TLDNames.TEICLASS) || nodeName.equals(JSP12TLDNames.TEI_CLASS)) && child.hasChildNodes()) {
ed.setTeiclass(getContainedText(child));
} else if ((nodeName.equals(JSP11TLDNames.BODYCONTENT) || nodeName.equals(JSP12TLDNames.BODY_CONTENT)) && child.hasChildNodes()) {
String bodycontent = getContainedText(child);
// these values
if (bodycontent.equalsIgnoreCase(JSP11TLDNames.CONTENT_JSP))
ed.setBodycontent(JSP11TLDNames.CONTENT_JSP);
else if (bodycontent.equalsIgnoreCase(JSP11TLDNames.CONTENT_TAGDEPENDENT))
ed.setBodycontent(JSP11TLDNames.CONTENT_TAGDEPENDENT);
else if (bodycontent.equalsIgnoreCase(JSP11TLDNames.CONTENT_EMPTY))
ed.setBodycontent(JSP11TLDNames.CONTENT_EMPTY);
else if (bodycontent.equalsIgnoreCase(JSP20TLDNames.CONTENT_SCRIPTLESS))
ed.setBodycontent(JSP20TLDNames.CONTENT_SCRIPTLESS);
} else // info (1.1 only) or description (1.2 only)
if ((nodeName.equals(JSP11TLDNames.INFO) || nodeName.equals(JSP12TLDNames.DESCRIPTION)) && child.hasChildNodes()) {
ed.setDescription(getContainedText(child));
} else // attributes
if (nodeName.equals(JSP11TLDNames.ATTRIBUTE)) {
CMAttributeDeclaration attr = createAttributeDeclaration(document, child);
ed.fAttributes.setNamedItem(attr.getAttrName(), attr);
} else // variables
if (nodeName.equals(JSP12TLDNames.VARIABLE)) {
ed.getVariables().add(createVariable(child));
} else if (nodeName.equals(JSP12TLDNames.LARGE_ICON) && child.hasChildNodes()) {
ed.setLargeIcon(getContainedText(child));
} else if (nodeName.equals(JSP12TLDNames.SMALL_ICON) && child.hasChildNodes()) {
ed.setSmallIcon(getContainedText(child));
} else if (nodeName.equals(JSP20TLDNames.TAG_EXTENSION) && child.getNodeType() == Node.ELEMENT_NODE) {
ed.getExtensions().add(child);
} else if (nodeName.equals(JSP20TLDNames.DYNAMIC_ATTRIBUTES) && child.hasChildNodes()) {
ed.setDynamicAttributes(getContainedText(child));
}
}
child = child.getNextSibling();
}
return ed;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration in project webtools.sourceediting by eclipse.
the class HTMLTagsCompletionProposalComputer method validModelQueryNode.
/**
* <p>Filter out all {@link CMNode}s except those specific to HTML documents</p>
*
* @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLModelQueryCompletionProposalComputer#validModelQueryNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)
*/
protected boolean validModelQueryNode(CMNode node) {
boolean isValid = false;
// $NON-NLS-1$
Object cmdoc = node.getProperty("CMDocument");
if (cmdoc instanceof CMNode) {
String name = ((CMNode) cmdoc).getNodeName();
// $NON-NLS-1$ //$NON-NLS-2$
isValid = name != null && name.endsWith(".dtd") && name.indexOf("html") != -1;
} else if (node.supports(HTMLAttributeDeclaration.IS_HTML)) {
Boolean isHTML = (Boolean) node.getProperty(HTMLAttributeDeclaration.IS_HTML);
isValid = isHTML == null || isHTML.booleanValue();
} else if (node instanceof HTMLPropertyDeclaration) {
HTMLPropertyDeclaration propDec = (HTMLPropertyDeclaration) node;
isValid = !propDec.isJSP();
} else if (node instanceof CMAttributeDeclaration || node instanceof CMElementDeclarationImpl) {
isValid = true;
} else if (node instanceof CMElementDeclaration) {
Boolean isXHTML = ((Boolean) node.getProperty(HTMLCMProperties.IS_XHTML));
isValid = isXHTML != null && isXHTML.booleanValue();
}
// Do not propose obsolete tags, regardless
if (isValid && node.supports(HTMLCMProperties.IS_OBSOLETE)) {
Boolean isObsolete = ((Boolean) node.getProperty(HTMLCMProperties.IS_OBSOLETE));
isValid = !(isObsolete != null && isObsolete.booleanValue());
}
return isValid;
}
Aggregations