String string= ""; if (compilationUnit != null && compilationUnit.exists()) { string= compilationUnit.getSource(); }
IDocument document= new Document(); if (compilationUnit != null && compilationUnit.exists()) document.set(compilationUnit.getSource());
	public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException {		ContextType contextType= ContextTypeRegistry.getInstance().getContextType("java"); //$NON-NLS-1$		if (contextType == null)			throw new CoreException(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IStatus.ERROR, JavaTemplateMessages.getString("JavaContext.error.message"), null)); //$NON-NLS-1$		String string= ""; //$NON-NLS-1$		if (compilationUnit != null && compilationUnit.exists()) {			string= compilationUnit.getSource();		}		JavaContext context= new JavaContext(contextType, string, position, compilationUnit);		context.setForceEvaluation(true);		TemplateBuffer buffer= context.evaluate(template);		return buffer.getString();	}