| Summary: | [reorg] Refactoring: Textual move members does not allow compilation unit as target | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | alexandra <astehman> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | markus.kell.r, Olivier_Thomann |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
alexandra
Could you please provide an example? (Thanks to Walter Harley for detailing!) 1. create a new Java project; 2. add a new package p and new classes p.A and p.B; 3. add a public String x1 to p.A; 4. highlight x1 and select Refactor -> Move. When I click B.java, I see an error message saying "The selected element cannot be the destination for this operation." However, if I expand the B.java item, under it I see sub-items for the package p and for the class B. If I select the *class* B, I am able to refactor successfully. Note that B.java can contain multiple top-level declarations, including multiple class declarations (though only one of them can be "class B"). So in a sense, what it's saying is true; you can't move a field into the top level of a .java file, that is, outside the scope of a class. But in the 95% likely case, where the .java file contains only a single top-level class, the intent is very clear and I think this is a usability bug. I didn't see anything about it in Bugzilla, so you might want to enter a Bugzilla feature request. Moving to JDT/UI As the dialog title says, this is just a textual move, so no references are being updated in this case -- it just does a copy/paste of the source text. There is no real refactoring for moving instance fields, and it would be very hard to write one that is behavior-preserving. We could allow a compilation unit as target, though. >We could allow a compilation unit as target, though.
That would be useful, thank you.
The fix for bug 297752 also fixes this. *** This bug has been marked as a duplicate of bug 297752 *** |