netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

ComputeImports: fix package computation.

Open mbien opened this issue 1 year ago • 1 comments

attempt to fix #7073, #5537 and #6902

  • getPackageElement() requires the full package String or it returns null (e.g javax is not sufficient)
  • this caused a bug where the fix-imports-action imported members which matched root packages of random fully qualified declarations (e.g imports)
 // hit ctrl+shift+i, it shouldn't import anything
import java.util.List;
public class FixImports {
    public static class SomeClass2 {
        public static String java(String value) {
            return value;
        }
    }
}

mbien avatar May 07 '24 03:05 mbien

Minimal nitpick: The test sources seem to be missing package declarations.

@matthiasblaesing good that you mentioned this since I misunderstood how the test works. It uses now one test file since all it has to do is to check that the computed candidates are empty.

mbien avatar May 10 '24 21:05 mbien