| Summary: | [Quick Assist] "Assign parameter to field" does not work for existing field | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Thomas Singer <eclipse> |
| Component: | UI | Assignee: | Martin Aeschlimann <martinae> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | daniel_megert, david, dcorbin, hudsonr, preuss |
| Version: | 3.1 | ||
| Target Milestone: | 3.1 RC1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Regarding the last comment: maybe another quick fix "assign to..." would be nice since the current really says "new" and hence it's not OK the reuse an existing one. Why not remove the "new" from the quick-fix' name and ask the user in the situation, when the variable already exists, whether it wan't to reuse it or assign it a new one? (although adding a new quick-fix "Assign parameter to existing field" also sounds useful, but might be more difficult, because you would need to allow selection of existing member variables) quick fix doesn't show dialogs to ask users. But what we can do is to offer more than one proposal. 'Assign to field 'xxx'' if the type matches. > quick fix doesn't show dialogs to ask users. OK, although I think, this is a too hard restriction. > But what we can do is to offer more than one > proposal. 'Assign to field 'xxx'' if the type matches. Sounds good-enough for me. Tom fixed > 20050519 *** Bug 81645 has been marked as a duplicate of this bug. *** *** Bug 96142 has been marked as a duplicate of this bug. *** Verifying... Original bug not fixed in I20050527-1300. There's still no quick-fix on the parameter to "Assign parameter to new field". in fact you are right. From comment 2 I aassumed that 'assign to existing' was really wanted here. Thomas please protest if I was wrong. I don't know, how exactly you fixed it, but from what I read I think there are two possible solutions: 1) Rename "Assign parameter to new field" to "Rename parameter to field" and allow to enter a field name (in a separate dialog, which also allows to mark the field final when invoked in a constructor), which might be an already existing one. By default, the suggested name is like the parameter. This is the way IDEA does; since a couple of EAP builds not only from the constructor, but from every method. 2) Add another quick-fix "Assign parameter to field 'xyz'". 2a) There is one quick-fix entry for each matching (existing) field 2b) The user can select in a dialog the field to assign to. I would prefer variant 1) because I already are accustomed to IDEA's behaviour. *** Bug 71863 has been marked as a duplicate of this bug. *** Verified in I20050624-0010 that quick assists "Assign parameter to new field" and "Assign parameter to field 'bar'" work, unless the field bar is declared final. Filed bug 101624 for the remaining problem. |
In this small example, there does not occur the quick-fix to "Assign parameter to new field": public class Foo { private final Bar bar; public Foo(Bar bar) { } } Even worse: when I remove the final from the variable declaration, invoking the quick-fix creates a new variable bar2 instead of reusing the existing one.