Bug 478392 - When creating fields with a quick-fix, use 'final' if in constructor
Summary: When creating fields with a quick-fix, use 'final' if in constructor
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-25 05:05 EDT by Alex Blewitt CLA
Modified: 2015-09-25 05:05 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Blewitt CLA 2015-09-25 05:05:59 EDT
When adding a field from a constructor, the quick-fix prompts to add a field:

public class Foo {
  public Foo() {
    this.field = "";
// Quick-Fix: Create field in Foo?
// private String foo;
  }
}

If this is being set in the constructor, there is a likelihood that this could be marked as final. (If it was being set from a method then of course this would not be true).

It would be nice if Eclipse added 'final' inside such constructors, because there will be a quick-fix to remove the final if an assignment is performed elsewhere in the class.