Bug 10749 - Bug is code formatter
Summary: Bug is code formatter
Status: RESOLVED DUPLICATE of bug 9969
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-05 06:51 EST by Ray Elenteny CLA
Modified: 2002-03-05 09:42 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 Ray Elenteny CLA 2002-03-05 06:51:20 EST
Build: 20020214

I have found what appears to be a problem in the code formatter.  The problem 
appears in formatting "else if" statements.  It seems to occur when an 
expression is used in the statements.  In cases where there is not expression 
in the "if," the formatting works fine.  For example, the following two pieces 
of code are in the same class file:

=========================================================
Case 1
=========================================================
            if (obj == null)
            {
                return null;
            }
            else if (obj instanceof String)
            {
                return (String) obj;
            }

=========================================================
Case 2
=========================================================
            if (value == null || value.equals("null"))
            {
                return null;
            }
            else if (type.equals(String.class.getName()))
            
                {
                return new String(value);
            }
=========================================================

As you can see there is a problem with the opening brace after the "else if."  
The following are the options I have set in the formater dialog tabs:

New Lines:
    Checked
       Insert new line before an opening brace
       Insert new lines in control statements
    Unchecked
       Clear all blank lines
       Insert new line between 'else if'
       Insert a new line inside an empty block

Line splitting:
    Maximum line length: 100

Style
    Unchecked
       Compact assignment
       Indentation is represented by a tab

    Number of spaces representing a tab: 4

Thanks.  Eclipse is a great tool!
Comment 1 Olivier Thomann CLA 2002-03-05 09:37:56 EST
This is fixed with my latest changes. The guilty piece of code is the class literal (.class). In 
fact this is a duplicate of 9969.

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