Bug 4086 Format problem in single element mode (1GKPJI8)
EG (27.09.2001 12:32:36) from WSAD newsgoup If you select Format (from the popup menu when you right click on .java file) while in "View selected element only" mode (ie - looking at only one method) the auot format adds a large amount of whitespace to the begining of each line. Repeated "Formats" just add more space. You then have to go to the "whole document" view and reformat the entire document to fix this (well, I guess I could manual remove the whitespace, but then what's the point of autoformat?). NOTES: EG (10.10.2001 22:38:03) pls investigate whether this is the formatting strategy or the Java editor
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaFormattingStrategy.java
fViewer = viewer;
	}
	
	/**
	 * @see IFormattingStrategy#formatterStarts(String)
	 */
	public void formatterStarts(String initialIndentation) {
		fInitialIndentation= initialIndentation;
	}
	
	/**
	 * @see IFormattingStrategy#formatterStops()
	 */
	public void formatterStops() {
	}
	
	/**
	 * @see IFormattingStrategy#format(String, boolean, String, int[])
	 */
	public String format(String content, boolean isLineStart, String indentation, int[] positions) {
		CodeFormatter formatter= new CodeFormatter(JavaCore.getOptions());
		
		IDocument doc= fViewer.getDocument();
		String lineDelimiter= StubUtility.getLineDelimiterFor(doc);
		formatter.options.setLineSeparator(lineDelimiter);
		formatter.setPositionsToMap(positions);
		formatter.setInitialIndentationLevel(fInitialIndentation == null ? 0 : fInitialIndentation.length());
		return formatter.formatSourceString(content);
	}	
}