Search in sources :

Example 11 with IDOMAttr

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

the class CommonSelectContentAssistRequest method getCompletionProposals.

@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    proposals.clear();
    adjustXPathStart(SELECT_ATTRIBUTE);
    int offset = getReplacementBeginPosition();
    IDOMAttr attrNode = getAttribute(SELECT_ATTRIBUTE);
    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 12 with IDOMAttr

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

the class AttributeContentAssist method getAttributeAtOffset.

private IDOMAttr getAttributeAtOffset(int offset) {
    Node node = getNode();
    if (node == null) {
        return null;
    }
    NamedNodeMap nodeMap = node.getAttributes();
    IDOMAttr attrNode = null;
    for (int i = 0; i < nodeMap.getLength(); i++) {
        IDOMAttr tmpAttr = (IDOMAttr) nodeMap.item(i);
        int start = tmpAttr.getStartOffset();
        int end = tmpAttr.getEndOffset();
        if (start <= offset || end > offset) {
            attrNode = tmpAttr;
            break;
        }
    }
    return attrNode;
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node)

Example 13 with IDOMAttr

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

the class AttributeContentAssist method getCompletionProposals.

/**
 * (non-Javadoc)
 * @see org.eclipse.wst.xsl.ui.internal.contentassist.SelectAttributeContentAssist#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    int offset = getReplacementBeginPosition();
    IDOMAttr attrNode = getAttributeAtOffset(offset);
    if (attrNode == null || !matchString.contains("{")) {
        // $NON-NLS-1$
        return getAllCompletionProposals();
    }
    adjustXPathStart(attrNode.getLocalName());
    offset = getReplacementBeginPosition();
    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 14 with IDOMAttr

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

the class XSLHyperlinkDetector 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) IRegion(org.eclipse.jface.text.IRegion)

Example 15 with IDOMAttr

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

the class TestAttributeContentAssist method getCompletionProposals.

/**
 * (non-Javadoc)
 * @see org.eclipse.wst.xsl.ui.internal.contentassist.SelectAttributeContentAssist#getCompletionProposals()
 */
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
    adjustXPathStart(ATTR_TEST);
    int offset = getReplacementBeginPosition();
    IDOMAttr attrNode = (IDOMAttr) ((IDOMElement) getNode()).getAttributeNode(ATTR_TEST);
    matchString = extractXPathMatchString(attrNode, getRegion(), getReplacementBeginPosition());
    addSelectProposals((Element) getNode().getParentNode(), offset);
    return getAllCompletionProposals();
}
Also used : IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)

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