Template[] templates= getTemplates(context.getContextType().getId());
List matches= new ArrayList();
String prefixLowerCase = prefix.toLowerCase();
for (int i= 0; i < templates.length; i++) {
Template template= templates[i];
if (!context.canEvaluate(template, prefix)) {
continue;
}
try {
context.getContextType().validate(template.getPattern());
} catch (TemplateException e) {
continue;
}
if (prefixLowerCase.length() == 0) {
// original code: doesn't use prefix
if (template.matches(prefixLowerCase, context.getContextType().getId())) {
matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
}
} else {
// as per http://dev.eclipse.org/newslists/news.eclipse.platform/msg26165.html
if (template.matches(prefix, context.getContextType().getId()) &&
template.getName().toLowerCase().startsWith(prefixLowerCase)) {
matches.add(createProposal(template, context, (IRegion)region,getRelevance(template, prefixLowerCase)));
}
}
}