Search in sources :

Example 41 with CMAttributeDeclaration

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

Example 42 with CMAttributeDeclaration

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

Example 43 with CMAttributeDeclaration

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

Example 44 with CMAttributeDeclaration

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

Example 45 with CMAttributeDeclaration

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

Aggregations

CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)57 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)30 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)29 List (java.util.List)24 ArrayList (java.util.ArrayList)18 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)17 NamedNodeMap (org.w3c.dom.NamedNodeMap)17 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)14 CMNamedNodeMapImpl (org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl)13 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)12 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)12 CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)11 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)11 Attr (org.w3c.dom.Attr)11 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)10 Element (org.w3c.dom.Element)10 Iterator (java.util.Iterator)9 NodeList (org.w3c.dom.NodeList)8 CMDataType (org.eclipse.wst.xml.core.internal.contentmodel.CMDataType)7 HashMap (java.util.HashMap)4