}
Template template = getCodeTemplate(templateName, sp);
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(
template.getContextTypeId(), sp, lineDelimiter);
// context.setCompilationUnitVariables(sp);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD,
methodName);
if (retTypeSig != null) {
context.setVariable(CodeTemplateContextType.RETURN_TYPE, retTypeSig);
}
if (target != null) {
String targetTypeName = target.getDeclaringType()
.getTypeQualifiedName(
PHPModelUtils.ENCLOSING_TYPE_SEPARATOR);
if (targetTypeName.indexOf(PHPModelUtils.ENCLOSING_TYPE_SEPARATOR) > 0) {
targetTypeName = PHPModelUtils.ENCLOSING_TYPE_SEPARATOR
+ targetTypeName;
}
String[] targetParamTypeNames = getParameterTypeNamesForSeeTag(target);
if (delegate)
context.setVariable(
CodeTemplateContextType.SEE_TO_TARGET_TAG,
getSeeTag(targetTypeName, methodName,
targetParamTypeNames));
else
context.setVariable(
CodeTemplateContextType.SEE_TO_OVERRIDDEN_TAG,
getSeeTag(targetTypeName, methodName,
targetParamTypeNames));
}
TemplateBuffer buffer;
try {
buffer = context.evaluate(template);
} catch (BadLocationException e) {
throw new CoreException(Status.CANCEL_STATUS);
} catch (TemplateException e) {
throw new CoreException(Status.CANCEL_STATUS);
}