Bug 4139 EC DCR: Code templates feature (1GIVMDV)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/template/TemplateProposal.java
int start= fCursorSelectionEvaluator.getStart();
		if (start == -1) {
			fSelectionStart= pattern.length();
			fSelectionEnd= fSelectionStart;
		} else {		
			fSelectionStart= start;
			fSelectionEnd= fCursorSelectionEvaluator.getEnd();			
		}
		boolean format= TemplatePreferencePage.useCodeFormatter();
		if (format) {
			CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions());
			formatter.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd});
			formatter.setInitialIndentationLevel(indentationLevel);
			pattern= formatter.formatSourceString(pattern);
			
			int[] positions= formatter.getMappedPositions();
			fSelectionStart= positions[0];
			fSelectionEnd= positions[1];
		} else {
			CodeIndentator indentator= new CodeIndentator();
			indentator.setPositionsToMap(new int[] {fSelectionStart, fSelectionEnd});
			indentator.setIndentationLevel(indentationLevel);
			
			pattern= indentator.indentate(pattern);
			int[] positions= indentator.getMappedPositions();
			fSelectionStart= positions[0];
			fSelectionEnd= positions[1];	
		}
		
		String finalString= trimBegin(pattern);