context.setVariable("selection", selection.getText()); // name of the selection variables {line, word_selection //$NON-NLS-1$
Template[] templates = getTemplates(context.getContextType().getId());
List<ICompletionProposal> matches = new ArrayList<ICompletionProposal>();
for (int i= 0; i < templates.length; i++) {
Template template= templates[i];
try {
context.getContextType().validate(template.getPattern());
} catch (TemplateException e) {
continue;
}
if(!prefix.equals("") &&prefix.charAt(0)=='<')
prefix = prefix.substring(1);
if (!prefix.equals("")&&(template.getName().startsWith(prefix) &&
template.matches(prefix, context.getContextType().getId())))
matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
}
return matches.toArray(new ICompletionProposal[matches.size()]);
}