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();
}
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;
}
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();
}
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;
}
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();
}
Aggregations