use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project webtools.sourceediting by eclipse.
the class CompoundQuickAssistProcessor method computeQuickAssistProposals.
public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
List proposalsList = new ArrayList();
// first get list of fixes
IQuickAssistProcessor processor = getQuickFixProcessor();
ICompletionProposal[] proposals = processor.computeQuickAssistProposals(invocationContext);
if (proposals != null && proposals.length > 0) {
proposalsList.addAll(Arrays.asList(proposals));
}
// no fixes, so try adding assists
if (proposalsList.isEmpty()) {
Set processors = getQuickAssistProcessors(invocationContext);
if (processors != null) {
// canAssist
for (Iterator it = processors.iterator(); it.hasNext(); ) {
IQuickAssistProcessor assistProcessor = (IQuickAssistProcessor) it.next();
ICompletionProposal[] assistProposals = assistProcessor.computeQuickAssistProposals(invocationContext);
if (assistProposals != null && assistProposals.length > 0) {
proposalsList.addAll(Arrays.asList(assistProposals));
}
}
}
}
/*
* Java editor currently returns a no modification completion proposal
* but it seems better to just return null so user does not get
* annoying proposal popup
*/
if (proposalsList.isEmpty()) {
// proposalsList.add(new NoModificationCompletionProposal());
return null;
}
return (ICompletionProposal[]) proposalsList.toArray(new ICompletionProposal[proposalsList.size()]);
}
use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project eclipse.platform.text by eclipse.
the class CompositeQuickAssistProcessor method getErrorMessage.
@Override
public String getErrorMessage() {
StringBuilder res = new StringBuilder();
for (IQuickAssistProcessor processor : this.fProcessors) {
String errorMessage = processor.getErrorMessage();
if (errorMessage != null) {
res.append(errorMessage);
res.append('\n');
}
}
if (res.length() == 0) {
return null;
}
return res.toString();
}
use of org.eclipse.jface.text.quickassist.IQuickAssistProcessor in project webtools.sourceediting by eclipse.
the class CompoundQuickAssistProcessor method getQuickAssistProcessors.
private Set getQuickAssistProcessors(String partitionType) {
if (fInstalledExtendedContentTypes == null || !fInstalledExtendedContentTypes.contains(partitionType)) {
// get extended quick assist processors that have not already
// been set
List processors = ExtendedConfigurationBuilder.getInstance().getConfigurations(QUICK_ASSIST_PROCESSOR_EXTENDED_ID, partitionType);
if (processors != null && !processors.isEmpty()) {
Iterator iter = processors.iterator();
while (iter.hasNext()) {
IQuickAssistProcessor processor = (IQuickAssistProcessor) iter.next();
setQuickAssistProcessor(partitionType, processor);
}
}
// up every time)
if (fInstalledExtendedContentTypes == null)
fInstalledExtendedContentTypes = new ArrayList();
fInstalledExtendedContentTypes.add(partitionType);
}
Set processors = null;
if (fProcessors != null)
processors = (Set) fProcessors.get(partitionType);
return processors;
}
Aggregations