Search in sources :

Example 21 with CMNamedNodeMapImpl

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

the class XMLTagInfoHoverProcessor method getCMAttributeDeclaration.

/**
 * Retreives CMAttributeDeclaration indicated by attribute name within
 * elementDecl
 */
protected CMAttributeDeclaration getCMAttributeDeclaration(IDOMNode node, CMElementDeclaration elementDecl, String attName) {
    CMAttributeDeclaration attrDecl = null;
    if (elementDecl != null) {
        CMNamedNodeMap attributes = elementDecl.getAttributes();
        CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
        List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
        for (int k = 0; k < nodes.size(); k++) {
            CMNode cmnode = (CMNode) nodes.get(k);
            if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
                allAttributes.put(cmnode);
            }
        }
        attributes = allAttributes;
        String noprefixName = DOMNamespaceHelper.getUnprefixedName(attName);
        if (attributes != null) {
            attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
            if (attrDecl == null) {
                attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attName);
            }
        }
    }
    return attrDecl;
}
Also used : CMNamedNodeMapImpl(org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl) CMAttributeDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) List(java.util.List) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)

Aggregations

CMNamedNodeMapImpl (org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl)21 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)16 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)15 List (java.util.List)14 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)14 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)13 ArrayList (java.util.ArrayList)11 NamedNodeMap (org.w3c.dom.NamedNodeMap)11 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)7 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)6 Attr (org.w3c.dom.Attr)6 Iterator (java.util.Iterator)5 Image (org.eclipse.swt.graphics.Image)4 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)4 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)4 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)4 CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)4 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)4 Element (org.w3c.dom.Element)4 NodeList (org.w3c.dom.NodeList)4