use of org.eclipse.jface.text.templates.Template in project che by eclipse.
the class StubUtility method getCompilationUnitContent.
public static String getCompilationUnitContent(ICompilationUnit cu, String packDecl, String fileComment, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.NEWTYPE_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.PACKAGE_DECLARATION, packDecl);
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : "");
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : "");
context.setVariable(CodeTemplateContextType.TYPE_DECLARATION, typeContent);
context.setVariable(CodeTemplateContextType.TYPENAME, JavaCore.removeJavaLikeExtension(cu.getElementName()));
String[] fullLine = { CodeTemplateContextType.PACKAGE_DECLARATION, CodeTemplateContextType.FILE_COMMENT, CodeTemplateContextType.TYPE_COMMENT };
return evaluateTemplate(context, template, fullLine);
}
use of org.eclipse.jface.text.templates.Template in project flux by eclipse.
the class StubUtility method getCompilationUnitContent.
public static String getCompilationUnitContent(ICompilationUnit cu, String packDecl, String fileComment, String typeComment, String typeContent, String lineDelimiter) throws CoreException {
Template template = getCodeTemplate(CodeTemplateContextType.NEWTYPE_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.PACKAGE_DECLARATION, packDecl);
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : "");
//$NON-NLS-1$
context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : "");
context.setVariable(CodeTemplateContextType.TYPE_DECLARATION, typeContent);
context.setVariable(CodeTemplateContextType.TYPENAME, JavaCore.removeJavaLikeExtension(cu.getElementName()));
String[] fullLine = { CodeTemplateContextType.PACKAGE_DECLARATION, CodeTemplateContextType.FILE_COMMENT, CodeTemplateContextType.TYPE_COMMENT };
return evaluateTemplate(context, template, fullLine);
}
Aggregations