Bug 219221 - By renaming the package the packages in the Source Packages nad Test Packages should be suggested to be renamed together
By renaming the package the packages in the Source Packages nad Test Packages...
Status: NEW
Product: editor
Classification: Unclassified
Component: Refactoring
7.2
PC Windows 7
: P3 (vote)
: TBD
Assigned To: Ralph Ruijs
issues@editor
: USABILITY
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-29 15:39 UTC by rudyment
Modified: 2015-10-30 16:07 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Tiny test project with package-access src/main class and a corresponding src/test class. (9.83 KB, application/x-download)
2015-10-30 16:07 UTC, nimarukan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rudyment 2012-09-29 15:39:16 UTC
Product Version = NetBeans IDE 7.2 (Build 201207171143)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_07
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.3-b01
Comment 1 nimarukan 2015-10-30 16:07:54 UTC
Created attachment 157068 [details]
Tiny test project with package-access src/main class and a corresponding src/test class.

possible duplicates: bug 243784, bug 240025
(bug 240025 mentions that NetBeans offers to rename a test Class when renaming a main class, but not a test package.)

present in NetBeans 8.1RC

The current workaround is to, for example, 
- rename the src/main com.sample package to org.example
  (which warns you about use by the src/test com.sample package), 
- then rename the src/test com.sample package to org.example also.  

Renaming the src/main com.sample package introduces import statements into the src/test package files for the src/main classes that were in the same package but are now in the new package. (com.sample.PackageUtilTest now imports org.example.PackageUtil).

If some of these newly imported src/main classes have package-level access, then the system can't compile the src/test classes.  (org.example.PackageUtil is package-private, so com.sample.PackageUtilTest cannot import it.)  So the src/test package must be renamed to match the src/main package again.  (Rename src/test package com.sample to org.example).

After renaming the src/test package, the revised added import statements remain.  (org.example.PackageUtilTest has import org.example.PackageUtil). NetBeans marks each one in yellow, warning that it is an import from the same package.  To clean up the changeset, these imports can be removed by manually editing each src/test file.

NetBeans would be nicer (and better match its competition) if it offered an option to rename the src/main and src/test packages together, and avoided these issues.  (I also tried selecting them both and right-clicking, but that currently disables the refactor menu item.)


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo