if (unit == null)
return new ICompletionProposal[0];
ICompletionProposal[] results;
CompletionProposalCollector collector;
// BEGIN HACK
if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)) {
collector= new WojExperimentalResultCollector(unit);
} else {
collector= new WojCompletionProposalCollector(unit);
}
// END HACK
try {
Point selection= viewer.getSelectedRange();
if (selection.y > 0)
collector.setReplacementLength(selection.y);
unit.codeComplete(offset, collector);
} catch (JavaModelException x) {
Shell shell= viewer.getTextWidget().getShell();
if (x.isDoesNotExist() && !unit.getJavaProject().isOnClasspath(unit))
MessageDialog.openInformation(shell, WojJavaTextMessages.CompletionProcessor_error_notOnBuildPath_title, WojJavaTextMessages.CompletionProcessor_error_notOnBuildPath_message);
else
ErrorDialog.openError(shell, WojJavaTextMessages.CompletionProcessor_error_accessing_title, WojJavaTextMessages.CompletionProcessor_error_accessing_message, x.getStatus());
}
results= collector.getJavaCompletionProposals();
int contextInformationOffset= guessContextInformationPosition(viewer, offset);
if (contextInformationOffset != offset) {
for (int i= 0; i < results.length; i++) {
if (results[i] instanceof JavaMethodCompletionProposal) {
JavaMethodCompletionProposal jmcp= (JavaMethodCompletionProposal) results[i];
jmcp.setContextInformationPosition(contextInformationOffset);
}
}
}
fErrorMsg= collector.getErrorMessage();
if (fTemplateEngine != null) {
fTemplateEngine.reset();
fTemplateEngine.complete(viewer, offset, unit);
TemplateProposal[] templateResults= fTemplateEngine.getResults();
// update relevance of template proposals that match with a keyword
// give those templates slightly more relevance than the keyword to
// sort them first
IJavaCompletionProposal[] keyWordResults= collector.getKeywordCompletionProposals();
for (int i= 0; i < keyWordResults.length; i++) {
String keyword= keyWordResults[i].getDisplayString();
for (int k= 0; k < templateResults.length; k++) {
TemplateProposal curr= templateResults[k];
if (curr.getTemplate().getName().startsWith(keyword)) {