This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 248241 - Netbeans eats my Java comments when I inline
Summary: Netbeans eats my Java comments when I inline
Status: RESOLVED INCOMPLETE
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-29 11:52 UTC by jfcorbett
Modified: 2014-11-06 11:03 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Diff screenshot (10.65 KB, image/png)
2014-10-29 11:52 UTC, jfcorbett
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jfcorbett 2014-10-29 11:52:46 UTC
Created attachment 150150 [details]
Diff screenshot

When I do Refactor > Inline..., Netbeans eats my Java comments. 

Example:

    double a = 1;
    //Important comment! DO NOT DELETE! <~~~~ gets deleted when inlining inlineMe
    double inlineMe = 2 * a;
    double b = 4 * inlineMe;

Example diff: see attached screenshot. 

Is it possible to prevent this behaviour? I browsed through Tools > Options and couldn't find anything that would do this. Therefore I thought this could be a bug. 

See also: http://stackoverflow.com/q/26283733/119775
Comment 1 Ralph Ruijs 2014-10-29 14:35:21 UTC
The comment preceding the variable declaration is attached to this variable declaration. When performing inline on a variable, this variable gets deleted together with it's associated comments.

The sample you attached is a bit too artificial, do you have a good example of a comment that should remain? or a comment that should be copied to the statements using the variable?

The following are examples of comments I think should be removed when performing inline on a variable.

/**
 * The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.
 */
private double PI = Math.PI;

// Temporary value, should probably be inlined
double temp = 7 * value;

double a = 1.2; // initialize variable