Bug 97918 [formatter] tab policy and indentation policy: indent on column
I would like a smarter tab policy. In code formated like this: class Example { Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this(); } Example() { } } I would like to have a mix of tabs and spaces like this: class Example { <tb>Example(int arg1, int arg2, <tb> int arg3, int arg4, <tb> int arg5, int arg6) { <tb><tb>this(); <tb>} <tb>Example() { <tb>} } If the code it is formated like this then it looks good whether a editor is using 4 or 8 space tabs. I called this a smarter tab policy because it means the code that implements the tab policy needs to know more than just a column number. It needs an indentation level and column offset. This could be configured by setting the tab policy to "mixed" and then have a check box that says "use spaces for column alignment" Or it could be configured by a new tab policy called "portable mixed", and in that case only the tab size field is needed. On another note it is bad that the Constructor Declarations->parameters example in the code formatting dialog uses the word "Example" which happens to be 8 chars. So in "tab only" tab policy with tabs of 2,4, or 8, the example doesn't show what will happen when "indent on column" is set. The method declarations->parameters example makes this clear.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java
"  }" + 
	"}" + 
	"\n" + 
	"enum MyEnum {" + 
	"    UNDEFINED(0) {" + 
	"        void foo() {}" + 
	"    }" + 
	"}";
	
	private CompilationUnitPreview fPreview;
	private String fOldTabChar= null;
	
	public IndentationTabPage(ModifyDialog modifyDialog, Map workingValues) {
		super(modifyDialog, workingValues);
	}
	protected void doCreatePreferences(Composite composite, int numColumns) {
		final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_general_group_title); 
		
		final String[] tabPolicyValues= new String[] {JavaCore.SPACE, JavaCore.TAB, DefaultCodeFormatterConstants.MIXED};
		final String[] tabPolicyLabels= new String[] {
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE, 
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB, 
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED
		};
		final ComboPreference tabPolicy= createComboPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_policy, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels); 
		final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); 
		final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); 
		
		String tabchar= (String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
		updateTabPreferences(tabchar, tabSize, indentSize);