Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 154621

Summary: [typing] Ctrl-I (Correct indentation) re-indentation of string argument to method call is incorrect.
Product: [Eclipse Project] JDT Reporter: Gary <gebarnes>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:

Description Gary CLA 2006-08-21 18:11:47 EDT
Type in two lines of code that look like this into a Java unit:

    xxx(
        yyy, "zzz");

Position your text cursor so that it is immediately in front of the first " of the string.  Press the Enter/Return key.  You will now have this:

    xxx(
        yyy,
        "zzz");

which is fine.  Now type Ctrl-I (or the "Correct indentation" item on the Source menu).  You will now have this:

    xxx(
        yyy,
    "zzz");

Interestingly enough if you add an unnecessary '+ ""' to the string expression, the indentation does not change.

This:
    xxx(
        yyy, "zzz" + "");
changes to:
    xxx(
        yyy,
        "zzz" + "");
and stays that way even after the Ctrl-I is typed.

Under the Java preferences for Java > Code Style > Formatter I am using these "Settings for arguments": "Line wrapping poliy" is "Wrap only when necessary" and "Indentation policy" is "Indent by one"
Comment 1 Dani Megert CLA 2006-08-22 03:19:00 EDT

*** This bug has been marked as a duplicate of 75573 ***