Search in sources :

Example 16 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class ExcludeResultPrefixesContentAssist method getCompletionProposals.

/**
 * (non-Javadoc)
 * @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    IDOMAttr attrNode = (IDOMAttr) ((IDOMElement) getNode()).getAttributeNode(EXCLUDE_RESULT_PREFIXES);
    String excludeResultPrefixes = attrNode.getValue();
    int offset = getCursorPosition();
    if (excludeResultPrefixes == null || excludeResultPrefixes.equals(DEFAULT)) {
        return getAllCompletionProposals();
    }
    // $NON-NLS-1$
    tokens = excludeResultPrefixes.split("\\s");
    if (tokens[0].equals("")) {
        // $NON-NLS-1$
        CustomCompletionProposal proposal = new CustomCompletionProposal(DEFAULT, offset, 0, DEFAULT.length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_PREFIX), DEFAULT, null, null, 0);
        addProposal(proposal);
    }
    Collection<NamespaceInfo> namespaces = this.getNamespaces((IDOMElement) node);
    for (NamespaceInfo namespace : namespaces) {
        if (includePrefix(namespace)) {
            CustomCompletionProposal proposal = new CustomCompletionProposal(namespace.prefix, offset, 0, namespace.prefix.length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_PREFIX), namespace.prefix, null, namespace.uri, 0);
            addProposal(proposal);
        }
    }
    return getAllCompletionProposals();
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal) NamespaceInfo(org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo)

Example 17 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class XSLModelObjectFactory method configure.

private void configure(IDOMNode node, XSLElement element) {
    setPositionInfo(node, element);
    IDOMElement domElem = (IDOMElement) node;
    element.setName(domElem.getLocalName());
    NamedNodeMap map = node.getAttributes();
    for (int i = 0; i < map.getLength(); i++) {
        IDOMAttr attr = (IDOMAttr) map.item(i);
        XSLAttribute xslatt = new XSLAttribute(element, attr.getName(), attr.getValue());
        setPositionInfo(attr, xslatt);
        element.setAttribute(xslatt);
    }
    setParentElement(node, element);
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) NamedNodeMap(org.w3c.dom.NamedNodeMap) XSLAttribute(org.eclipse.wst.xsl.core.model.XSLAttribute) IDOMElement(org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)

Example 18 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class CommonTestContentAssistRequest method getCompletionProposals.

@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    adjustXPathStart(ATTR_TEST);
    int offset = getReplacementBeginPosition();
    IDOMAttr attrNode = getAttribute(ATTR_TEST);
    this.matchString = extractXPathMatchString(attrNode, getRegion(), getReplacementBeginPosition());
    addSelectProposals((Element) getNode().getParentNode(), offset);
    return getAllCompletionProposals();
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)

Example 19 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class PatternMatcher method createSearchMatch.

protected SearchMatch createSearchMatch(IFile file, Attr attributeNode) {
    int start = 0;
    int length = 0;
    if (attributeNode instanceof IDOMAttr) {
        IDOMAttr domAttr = (IDOMAttr) attributeNode;
        start = domAttr.getValueRegionStartOffset();
        length = domAttr.getValueRegionText().length();
    }
    SearchMatch match = new SearchMatch(attributeNode, start, length, file);
    return match;
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) SearchMatch(org.eclipse.wst.common.core.search.SearchMatch)

Example 20 with IDOMAttr

use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr in project webtools.sourceediting by eclipse.

the class XMLHyperlinkDetector method getHyperlinkRegion.

private IRegion getHyperlinkRegion(Node node) {
    IRegion hyperRegion = null;
    if (node != null) {
        short nodeType = node.getNodeType();
        if (nodeType == Node.DOCUMENT_TYPE_NODE) {
            // handle doc type node
            IDOMNode docNode = (IDOMNode) node;
            hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
        } else if (nodeType == Node.ATTRIBUTE_NODE) {
            // handle attribute nodes
            IDOMAttr att = (IDOMAttr) node;
            // do not include quotes in attribute value region
            int regOffset = att.getValueRegionStartOffset();
            ITextRegion valueRegion = att.getValueRegion();
            if (valueRegion != null) {
                int regLength = valueRegion.getTextLength();
                String attValue = att.getValueRegionText();
                if (StringUtils.isQuoted(attValue)) {
                    ++regOffset;
                    regLength = regLength - 2;
                }
                hyperRegion = new Region(regOffset, regLength);
            }
        }
    }
    return hyperRegion;
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) Region(org.eclipse.jface.text.Region) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) IRegion(org.eclipse.jface.text.IRegion) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)29 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)10 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)10 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)9 NamedNodeMap (org.w3c.dom.NamedNodeMap)9 IRegion (org.eclipse.jface.text.IRegion)7 Region (org.eclipse.jface.text.Region)7 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)6 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)5 Node (org.w3c.dom.Node)5 Attr (org.w3c.dom.Attr)3 Element (org.w3c.dom.Element)3 SearchMatch (org.eclipse.wst.common.core.search.SearchMatch)2 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)2 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)2 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)2 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)2 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 IDOMText (org.eclipse.wst.xml.core.internal.provisional.document.IDOMText)2