Bug 6466 - Code Formatter
Summary: Code Formatter
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.0 M2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-11-30 09:40 EST by Sebastian Davids CLA
Modified: 2002-03-05 06:48 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2001-11-30 09:40:49 EST
@@@ Code Formatter @@@

I'd like to the "Code Formatter" to have the following features
(individually turned on/off):

1. Pre-/suffixes instance variables with a user defined pre-/suffix; in case
of a prefix the following rules apply: "ab" and "Ab" (a: first letter of the
name; following letters) are exchanged with "pA" (p: the prefix). turned
on/off on two levels: instance & class (!! all references in other sources
should be adjusted !!)
2. Convert constants, i.e. "final"s, into "All Caps"; the following pattern:
"aBa" (a, b: abitrary letters) should be exchanged with "A_BA"; the
conversion should be turned on/off on two levels: instance & class (!! all
references in other sources should be adjusted !!)
3. Capitalize class names; !! all references in other sources should be
adjusted !!
4. Decapitalize first letter on variable and method names; turned on/off
individually

Report all conflicts to the user and let him decide ...

//Before
public class test {
    private char character;
    private int number;
    protected int Number;
    public int PublicNumber;
    private final constant;
    public static final classConstant;

    public test() {}

    public void TestFunction() {
        int Number;
    }

    public int getNumber() {
        return number;
    }
}

//After
//(1) both turned on; instance - user defined prefix "f"; class - user
defined suffix "_"
//(2) both turned on
//(4) both turned on
public class Test {// (3) to uppercase !! necessary to change all references
!!
    private char fCharacter; // (1) instance - added prefix
    private int number; // (1) instance - report to user, two variable's
names differing only in capitalization should be not allowed anyway
    protected int Number; // (4) variable and (1) instance - report to user,
two variable's names differing only in capitalization should be not allowed
anyway
    public int publicNumber_; // (4) variable and (1) class - added prefix
!! necessary to change all references !!
    private final CONSTANT;// (2) to uppercase
    public static final CLASS_CONSTANT; // (2) to uppercase and
"aBa"-pattern changed to "A_BA" !! necessary to change all references !!

    public Test() {} // (3) to uppercase

    public void testFunction() { // (4) method - changed first letter
        int number; // (4) variable - changed first letter
    }

    public int getNumber() {
        return fNumber; // (1) added prefix
    }
}

@@@@@@

Sebastian Davids
Comment 1 Philipe Mulet CLA 2001-12-03 08:53:10 EST
I do not think this is the formatter job to ensure coding conventions. The 
formatter is simply pretty printing the source code, not altering it (changing 
names or so).
Comment 2 Sidney Monteiro CLA 2001-12-06 18:10:30 EST
I agree with Philippe Mulet 2001-12-03 08:53 ------- this is NOT the 
responsibility of the Code Formatter.

Comment 3 Sebastian Davids CLA 2001-12-10 13:12:42 EST
What (existing?) plugin would the belong to then?

I agree with the point "Code Formatter == Code Layouter" (i.e. only change of 
whitespaces) ...
Comment 4 Philipe Mulet CLA 2002-01-16 09:51:12 EST
Closing. No change planned.
Comment 5 Sebastian Davids CLA 2002-03-05 06:48:00 EST
.