use of org.eclipse.jface.text.contentassist.ICompletionProposal in project bndtools by bndtools.
the class ProjectBuildPage method generateFixes.
// look for available quick-fixes from the bnd build error details
private void generateFixes(String message, final IMarker marker) {
boolean fixable = marker.getAttribute(BuildErrorDetailsHandler.PROP_HAS_RESOLUTIONS, false);
if (!fixable)
return;
ITextEditor sourcePage = editor.getSourcePage();
if (sourcePage == null)
return;
String type = marker.getAttribute("$bndType", (String) null);
if (type == null)
return;
BuildErrorDetailsHandler handler = BuildErrorDetailsHandlers.INSTANCE.findHandler(type);
if (handler == null)
return;
List<IAction> fixes = new LinkedList<>();
List<ICompletionProposal> proposals = handler.getProposals(marker);
if (proposals != null) {
for (ICompletionProposal proposal : proposals) {
fixes.add(new ApplyCompletionProposalAction(proposal, editor.getSourcePage(), editor, BndEditor.SOURCE_PAGE));
}
}
// If no source completion fixes were found, add the marker resolution actions.
if (fixes.isEmpty()) {
List<IMarkerResolution> resolutions = handler.getResolutions(marker);
for (final IMarkerResolution resolution : resolutions) {
Action action = new Action(resolution.getLabel()) {
@Override
public void run() {
resolution.run(marker);
}
};
fixes.add(action);
}
}
messageFixesMap.put(message, fixes.toArray(new IAction[0]));
}
use of org.eclipse.jface.text.contentassist.ICompletionProposal in project bndtools by bndtools.
the class BundleClassCompletionProposalComputer method computeCompletionProposals.
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
List<ICompletionProposal> result = new LinkedList<ICompletionProposal>();
if (!(context instanceof JavaContentAssistInvocationContext)) {
return Collections.emptyList();
}
try {
int offset = context.getInvocationOffset();
CharSequence prefix = context.computeIdentifierPrefix();
result.add(new CompletionProposal("foobar", offset - prefix.length(), prefix.length(), offset - prefix.length() + 6));
result.add(new CompletionProposal("fizzbuzz", offset - prefix.length(), prefix.length(), offset - prefix.length() + 8));
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
Aggregations