Bug 478392

Summary: When creating fields with a quick-fix, use 'final' if in constructor
Product: [Eclipse Project] JDT Reporter: Alex Blewitt <alex.blewitt>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 4.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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.