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 243035 - Accepting the hint "Use functional operation" deletes comment line
Summary: Accepting the hint "Use functional operation" deletes comment line
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on: 239487
Blocks:
  Show dependency tree
 
Reported: 2014-03-19 07:33 UTC by skomisa
Modified: 2014-07-10 14:28 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description skomisa 2014-03-19 07:33:21 UTC
Environment: Windows7 + NetBeans 201403180001

Summary: 
Accepting the hint "Use functional operation" to convert a for-each loop on a Collection works, but also causes the previous line with a comment to be deleted.

Steps to Reproduce:
[1] Create a trivial Java application exactly as follows:

package functiontest;
import java.util.Arrays;
import java.util.List;

public class FunctionTest {
    public static void main(String[] args) {
        List<String> strings = Arrays.asList("AAA", "BBB", "CCC");
        // for (String s : strings) { 
        for (String s : strings) { 
            System.out.println("Hello world " + s);
        }
    }
}

[2] There is a warning on the line with the for loop: "Can use functional operations".

[3] Press alt-enter on that line, then accept the hint to modify the code.

[4] An appropriate change is made, but the comment on the preceding line is also deleted.

Additional information: Bugs 241883 and 238887 look similar, but those problems relate to comment deletion for other hints.
Comment 1 Geoff_C 2014-04-04 05:02:45 UTC
I am also experiencing this, but it will delete entire blocks of comments following the point of refactoring.
Comment 2 Svata Dedic 2014-07-10 14:28:15 UTC
Fixed by general support implemented as part of issue #239487 and isssue #245348