use of org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext in project che by eclipse.
the class StubUtility method getCatchBodyContent.
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, String enclosingType, String enclosingMethod, String lineDelimiter) throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
return evaluateTemplate(context, template);
}
use of org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext in project che by eclipse.
the class StubUtility method getGetterComment.
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.jdt.ui.CodeGeneration#getGetterComment(ICompilationUnit, String, String, String, String, String, String)
*/
public static String getGetterComment(ICompilationUnit cu, String typeName, String methodName, String fieldName, String fieldType, String bareFieldName, String lineDelimiter) throws CoreException {
String templateName = CodeTemplateContextType.GETTERCOMMENT_ID;
Template template = getCodeTemplate(templateName, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
context.setVariable(CodeTemplateContextType.FIELD, fieldName);
context.setVariable(CodeTemplateContextType.FIELD_TYPE, fieldType);
context.setVariable(CodeTemplateContextType.BARE_FIELD_NAME, bareFieldName);
return evaluateTemplate(context, template);
}
use of org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext in project che by eclipse.
the class StubUtility method getFileComment.
/*
* Don't use this method directly, use CodeGeneration.
* @see org.eclipse.jdt.ui.CodeGeneration#getFileComment(ICompilationUnit, String)
*/
public static String getFileComment(ICompilationUnit cu, String lineDelimiter) throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, cu.getJavaProject());
if (template == null) {
return null;
}
IJavaProject project = cu.getJavaProject();
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
context.setCompilationUnitVariables(cu);
context.setVariable(CodeTemplateContextType.TYPENAME, JavaCore.removeJavaLikeExtension(cu.getElementName()));
return evaluateTemplate(context, template);
}
use of org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext in project che by eclipse.
the class UnimplementedCodeCleanUp method getMethodBody.
private String getMethodBody() {
String templateName = CodeTemplateContextType.METHODSTUB_ID;
Template template = getCodeTemplate(templateName);
if (template == null)
//$NON-NLS-1$
return "";
//$NON-NLS-1$
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), null, "\n");
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, "method");
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, "Face");
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.BODY_STATEMENT, "");
return evaluateTemplate(template, context);
}
use of org.eclipse.jdt.internal.corext.template.java.CodeTemplateContext in project flux by eclipse.
the class StubUtility method getCatchBodyContent.
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, String enclosingType, String enclosingMethod, String lineDelimiter) throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.CATCHBLOCK_ID, cu.getJavaProject());
if (template == null) {
return null;
}
CodeTemplateContext context = new CodeTemplateContext(template.getContextTypeId(), cu.getJavaProject(), lineDelimiter);
context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, enclosingType);
context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, enclosingMethod);
context.setVariable(CodeTemplateContextType.EXCEPTION_TYPE, exceptionType);
context.setVariable(CodeTemplateContextType.EXCEPTION_VAR, variableName);
return evaluateTemplate(context, template);
}
Aggregations