Search in sources :

Example 41 with CMElementDeclaration

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);
        }
    }
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) CMDataType(org.eclipse.wst.xml.core.internal.contentmodel.CMDataType) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) CMDescriptionBuilder(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)

Example 42 with CMElementDeclaration

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);
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)

Example 43 with CMElementDeclaration

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);
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)

Example 44 with CMElementDeclaration

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);
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)

Example 45 with CMElementDeclaration

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;
}
Also used : CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) ModelQuery(org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)

Aggregations

CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)147 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)53 List (java.util.List)46 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)43 Element (org.w3c.dom.Element)41 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)38 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)37 ArrayList (java.util.ArrayList)35 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)33 Node (org.w3c.dom.Node)32 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)30 NodeList (org.w3c.dom.NodeList)28 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)24 Iterator (java.util.Iterator)19 CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)19 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)17 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)17 NamedNodeMap (org.w3c.dom.NamedNodeMap)17 Image (org.eclipse.swt.graphics.Image)15 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)15