/** * Returns <code>true</code> if a context type id specifies a valid context type * or if no context type registry is present. * * @param contextTypeId the context type id to look for * @return <code>true</code> if the context type specified by the id * is present in the context type registry, or if no registry is * specified */ private boolean contextExists(String contextTypeId) { return contextTypeId != null && (fRegistry == null || fRegistry.getContextType(contextTypeId) != null); }
@Override public TemplateContextType getContextType(String id) { return super.getContextType(id); }
public CodeTemplateContext(String contextTypeName, IJavaProject project, String lineDelim) { super(JavaManipulation.getCodeTemplateContextRegistry().getContextType(contextTypeName)); fLineDelimiter= lineDelim; fProject= project; }
/** * Validates a template against the context type registered in the context * type registry. Returns always <code>true</code> if no registry is * present. * * @param template the template to validate * @return <code>true</code> if validation is successful or no context * type registry is specified, <code>false</code> if validation * fails */ private boolean validateTemplate(Template template) { String contextTypeId= template.getContextTypeId(); if (contextExists(contextTypeId)) { if (fRegistry != null) try { fRegistry.getContextType(contextTypeId).validate(template.getPattern()); } catch (TemplateException e) { return false; } return true; } return false; }