apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.69k stars 853 forks source link

Fixing imports deletes a comment line #7964

Open JoachimRohde opened 2 weeks ago

JoachimRohde commented 2 weeks ago

Apache NetBeans version

Apache NetBeans 24 release candidate

What happened

In the following code the first comment line gets deleted when CTRL+SHIFT+I is pressed to fix imports:

package com.mycompany.fiximportdeletescommentdemo;

import java.util.List;

// https://github.com/toby1984/swing-autocomplete
// xxx
// https://github.com/toby1984/swing-autocomplete/blob/master/src/test/java/de/codesourcery/swing/autocomplete/Demo.java
public class FixImportDeletesCommentDemo {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

I could reproduce this behaviour with NetBeans 22 and NetBeans 24-rc3. It only occurs if all imports are about to be removed and the code does not contain any unresolved imports. If those criterias are met the issue is always reproduceable.

A trivial Maven project to demonstrate this issue: FixImportDeletesCommentDemo.zip

Language / Project Type / NetBeans Component

Java editor

How to reproduce

See text above and attached project.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Linux Mint 21.3 Cinnamon

JDK

17.0.12; OpenJDK 64-Bit Server VM 17.0.12+7-Ubuntu-1ubuntu222.04

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

matthiasblaesing commented 2 weeks ago

Reproducible.