use of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration in project webtools.sourceediting by eclipse.
the class MarkupTagInfoProvider method printDefaultInfo.
/**
* Adds the default info (element name, content model, data type) of
* CMNode to the string buffer, sb
*/
protected void printDefaultInfo(CMNode node, StringBuffer sb) {
{
if (node.getNodeType() == CMNode.ELEMENT_DECLARATION) {
CMElementDeclaration ed = (CMElementDeclaration) node;
sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Element____1 + SPACE + BOLD_END);
sb.append(node.getNodeName());
sb.append(PARAGRAPH_END);
printDocumentation(sb, node);
if (ed.getContentType() == CMElementDeclaration.PCDATA) {
CMDataType dataType = ed.getDataType();
if (dataType != null) {
printDataTypeInfo(sb, dataType);
}
} else {
CMDescriptionBuilder builder = new CMDescriptionBuilder();
String description = builder.buildDescription(node);
if ((description != null) && (description.length() > 0)) {
sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Content_Model____2 + SPACE + BOLD_END);
sb.append(description + PARAGRAPH_END);
}
}
} else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
CMAttributeDeclaration ad = (CMAttributeDeclaration) node;
sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Attribute____3 + SPACE + BOLD_END);
sb.append(node.getNodeName());
sb.append(PARAGRAPH_END);
printDocumentation(sb, node);
CMDataType dataType = ad.getAttrType();
if (dataType != null) {
printDataTypeInfo(sb, dataType);
}
} else if (node.getNodeType() == CMNode.DATA_TYPE) {
sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
sb.append(node.getNodeName());
sb.append(PARAGRAPH_END);
printDocumentation(sb, node);
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration in project webtools.sourceediting by eclipse.
the class XMLTagInfoHoverProcessor method computeTagAttNameHelp.
/**
* Computes the hover help for the attribute name
*/
protected String computeTagAttNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
String attName = flatNode.getText(region);
CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
return getAdditionalInfo(elementDecl, attDecl);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration in project webtools.sourceediting by eclipse.
the class XMLTagInfoHoverProcessor method computeTagNameHelp.
/**
* Computes the hover help for the tag name
*/
protected String computeTagNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
CMElementDeclaration pelementDecl = getCMElementDeclaration(parentNode);
return getAdditionalInfo(pelementDecl, elementDecl);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration in project webtools.sourceediting by eclipse.
the class XMLTagInfoHoverProcessor method computeTagAttValueHelp.
/**
* Computes the hover help for the attribute value (this is the same as
* the attribute name's help)
*/
protected String computeTagAttValueHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
ITextRegion attrNameRegion = getAttrNameRegion(xmlnode, region);
String attName = flatNode.getText(attrNameRegion);
CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
return getAdditionalInfo(elementDecl, attDecl);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration in project webtools.sourceediting by eclipse.
the class DocumentImpl method getCMAttributes.
/**
* Provides an element's attribute declarations
* @param element the element to retrieve the attribute map of
* @return a <code>CMNamedNodeMap</code> of attributes if the declaration exists; null otherwise.
*/
CMNamedNodeMap getCMAttributes(Element element) {
CMNamedNodeMap map = (CMNamedNodeMap) fCMCache.get(element);
if (map == null) {
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(this);
CMElementDeclaration decl = modelQuery != null ? modelQuery.getCMElementDeclaration(element) : null;
if (decl != null) {
map = decl.getAttributes();
fCMCache.put(element, map);
}
}
return map;
}
Aggregations