Bug 258377 - Inline local variable refactoring removes preceding comments
Summary: Inline local variable refactoring removes preceding comments
Status: RESOLVED DUPLICATE of bug 150558
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.1   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: 2008-12-10 18:25 EST by Mike M CLA
Modified: 2008-12-17 11:02 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike M CLA 2008-12-10 18:25:14 EST
Build ID: M20080911-1700

The "Inline local variable" refactoring removes comments that appear on the line(s) before the variable in question.

For example:

public void method()
{
    // Another
    // Comment
    int x = 4;
    int y = x;
}

This results in the following after inlining 'x':

public void method()
{
    int y = 4;
}

Sometimes comments before variables are attached to them, and it makes sense to delete them.  But more often, the comments are useful in their own right, and should not be deleted. The user can delete them if necessary later.

This problem is somewhat dangerous, because if you're not paying attention, comments get deleted but you don't notice until much later.
Comment 1 Dani Megert CLA 2008-12-11 03:52:03 EST

*** This bug has been marked as a duplicate of bug 150558 ***
Comment 2 Mike M CLA 2008-12-17 11:02:22 EST
I protest! 

Although the underlying cause of this problem may have to do with the AST rewriter, I see no reason why an option can not be created (either for just this refactoring, or globally for the AST RW) that allows the user to control whether or not surrounding comments are grouped with a given element.