Bug 97918 - [formatter] tab policy and indentation policy: indent on column
Summary: [formatter] tab policy and indentation policy: indent on column
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Benno Baumgartner CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 102007 (view as bug list)
Depends on: 49896
Blocks:
  Show dependency tree
 
Reported: 2005-06-01 13:12 EDT by Scott Cytacki CLA
Modified: 2005-11-01 05:09 EST (History)
3 users (show)

See Also:


Attachments
fix (5.87 KB, patch)
2005-10-07 05:49 EDT, Benno Baumgartner CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Cytacki CLA 2005-06-01 13:12:47 EDT
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.
Comment 1 Olivier Thomann CLA 2005-06-01 17:16:47 EDT
What you want is actually already done at the core level. See bug 49896.
Move to JDT/UI for adding this to the code formatter preference page.
Comment 2 Martin Aeschlimann CLA 2005-06-28 09:05:55 EDT
*** Bug 102007 has been marked as a duplicate of this bug. ***
Comment 3 Thomas Singer CLA 2005-06-28 11:36:54 EDT
I hope, you add the UI option very soon, otherwise we cannot use Eclipse for
real production code (would result in too much useless VCS differences each commit).
Comment 4 Benno Baumgartner CLA 2005-10-07 05:49:34 EDT
Created attachment 28021 [details]
fix

Adds checkbox
[x] Use tabs only for leading indentations
to
Indentation -> general settings
The checkbox is not enabled if Tab policy is 'spaces only'.
Comment 5 Martin Aeschlimann CLA 2005-10-11 04:14:08 EDT
patch released for I20051011
Comment 6 Benno Baumgartner CLA 2005-11-01 05:09:08 EST
Verified using I20051031-2000