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