use of org.eclipse.jface.text.contentassist.ContextInformation in project linuxtools by eclipse.
the class STPCompletionProcessor method getGlobalKeywordCompletion.
private ICompletionProposal[] getGlobalKeywordCompletion(String prefix, int offset) {
ArrayList<ICompletionProposal> completions = new ArrayList<>();
int prefixLength = prefix.length();
for (String[] keyword : GLOBAL_KEYWORDS) {
if (keyword[0].startsWith(prefix)) {
CompletionProposal proposal = new CompletionProposal(keyword[0].substring(prefixLength), offset, 0, keyword[0].length() - prefixLength, null, keyword[0], // $NON-NLS-1$ //$NON-NLS-2$
new ContextInformation("contextDisplayString", "informationDisplayString"), keyword[1]);
completions.add(proposal);
}
}
return completions.toArray(new ICompletionProposal[0]);
}
use of org.eclipse.jface.text.contentassist.ContextInformation in project webtools.sourceediting by eclipse.
the class AttributeContextInformationProvider method getInfoForText.
/**
* @param node
*/
IContextInformation[] getInfoForText(IDOMNode node) {
Node parent = node.getParentNode();
String contextString = node.getNodeName();
// $NON-NLS-1$
StringBuffer info = new StringBuffer(" ");
if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
CMContent content = decl.getContent();
if (content instanceof CMGroup) {
CMGroup cmGroup = (CMGroup) content;
CMNodeList children = cmGroup.getChildNodes();
CMNode cmNode = null;
for (int i = 0; i < children.getLength(); i++) {
cmNode = children.item(i);
contextString = cmNode.getNodeName();
if (contextString != null) {
// $NON-NLS-1$ //$NON-NLS-2$
info.append("<" + cmNode.getNodeName() + ">");
if (i < children.getLength() - 1) {
// $NON-NLS-1$
info.append(" ");
}
}
}
}
}
if (!info.toString().trim().equals("")) {
return new IContextInformation[] { new ContextInformation(contextString, info.toString()) };
} else {
return EMPTY_CONTEXT_INFO;
}
}
Aggregations