Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367866 - [quick assist][clean up] Save action "Use blocks in if/while..." deletes comments before "else if"
Summary: [quick assist][clean up] Save action "Use blocks in if/while..." deletes comm...
Status: CLOSED DUPLICATE of bug 378139
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-04 11:19 EST by Werner Piel CLA
Modified: 2012-05-03 04:40 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Werner Piel CLA 2012-01-04 11:19:06 EST
Build Identifier: Version: Indigo Service Release 1 Build id: 20110916-0149

When using the option "Always" in "Use blocks in if/while/for/do statements" as an additional Save Action, comments (and empty lines) get deleted when if-statement has a single expression without a block followed by an if-else-statement.
Example:
Before save:
	public void test() {
        if ("x".equals("x")) 
        	new Integer("1");

        // 1
        /* 
         * 2 
         * 3
         * 4
         */
        else if ("y".equals("y"))
        	new Integer("1");
    }
After save:
	public void test() {
        if ("x".equals("x")) 
        {
        	new Integer("1");
        }
        else if ("y".equals("y"))
        {
        	new Integer("1");
        }
    }


Reproducible: Always

Steps to Reproduce:
1. Display properties dialog for project
2. Check "Additional actions" checkbox in "Java Editor/Save Actions" dialog
3. Press "Configure..." button (shows the "Additional Save Actions" dialog
4. Check "Use blocks in if/while/for/do statements" checkbox and select the first radiobutton "Always".
5. Close the property dialogs
6. Save the java-sourcefile with the example as described in "Details"
Comment 1 Deepak Azad CLA 2012-01-12 07:40:03 EST
Fix to go in ControlStatementsFix.AddBlockOperation.rewriteAST(...)

Also a problem with the corresponding quick assists - 'Change if statement to block', 'Change if-else statements to blocks' etc. Fix for quick assists to go in QuickAssistProcessor.getAddBlockProposals(...).
Comment 2 Deepak Azad CLA 2012-05-03 04:40:57 EDT

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