use of org.eclipse.jface.text.contentassist.IContextInformation in project bndtools by bndtools.
the class BundleClassCompletionProposalComputer method computeContextInformation.
public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
List<IContextInformation> result = new LinkedList<IContextInformation>();
result.add(new ContextInformation("contextDisplayString", "informationDisplayString"));
return result;
}
use of org.eclipse.jface.text.contentassist.IContextInformation in project eclipse.platform.text by eclipse.
the class BarContentAssistProcessor method getContextInformationValidator.
@Override
public IContextInformationValidator getContextInformationValidator() {
return new IContextInformationValidator() {
ITextViewer viewer;
int offset;
@Override
public void install(IContextInformation info, ITextViewer viewer, int offset) {
this.viewer = viewer;
this.offset = offset;
}
@Override
public boolean isContextInformationValid(int offset) {
try {
IDocument document = viewer.getDocument();
IRegion line = document.getLineInformationOfOffset(this.offset);
int end = line.getOffset() + line.getLength();
return (offset >= this.offset && offset < end);
} catch (BadLocationException e) {
return false;
}
}
};
}
use of org.eclipse.jface.text.contentassist.IContextInformation in project eclipse.platform.text by eclipse.
the class BarContentAssistProcessor method computeContextInformation.
/**
* Creates context info "idx= <word index in #PROPOSAL>" at the end of a word.
*/
@Override
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
try {
IDocument document = viewer.getDocument();
int begin = offset;
while (begin > 0 && Character.isLetterOrDigit(document.getChar(begin - 1))) {
begin--;
}
if (begin < offset) {
String word = document.get(begin, offset - begin);
int idx = Arrays.asList(completeString.split("\\W")).indexOf(word);
if (idx >= 0) {
return new IContextInformation[] { new ContextInformation(word, "idx= " + idx) };
}
}
} catch (BadLocationException e) {
e.printStackTrace();
}
return null;
}
use of org.eclipse.jface.text.contentassist.IContextInformation in project eclipse.platform.text by eclipse.
the class ContextInformationPopup2 method setContexts.
/**
* Sets the contexts in the context selector to the given set.
*
* @param contexts the possible contexts
*/
private void setContexts(IContextInformation[] contexts) {
if (Helper2.okToUse(fContextSelectorTable)) {
fContextSelectorInput = contexts;
fContextSelectorTable.setRedraw(false);
fContextSelectorTable.removeAll();
TableItem item;
IContextInformation t;
for (IContextInformation context : contexts) {
t = context;
item = new TableItem(fContextSelectorTable, SWT.NULL);
if (t.getImage() != null)
item.setImage(t.getImage());
item.setText(t.getContextDisplayString());
}
fContextSelectorTable.select(0);
fContextSelectorTable.setRedraw(true);
}
}
use of org.eclipse.jface.text.contentassist.IContextInformation in project eclipse.platform.text by eclipse.
the class JavaCompletionProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
ICompletionProposal[] result = new ICompletionProposal[fgProposals.length];
for (int i = 0; i < fgProposals.length; i++) {
// $NON-NLS-1$
IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] }));
// $NON-NLS-1$
result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(JavaEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] }));
}
return result;
}
Aggregations