Bug 461417 - [quick fix] Generate constructor if no constructor exists and if there are final members
Summary: [quick fix] Generate constructor if no constructor exists and if there are fi...
Status: CLOSED DUPLICATE of bug 345896
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   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-03-04 11:35 EST by Lukas Eder CLA
Modified: 2015-04-01 08:10 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Eder CLA 2015-03-04 11:35:56 EST
I have this class

public class X {
    final int i;
    final int j;
    ...
}

This class doesn't compile. I have to tediously write the constructor and repeat all field types and names and then assignments. Scala has case classes, which work the same way, but don't have the boilerplate.

It would be great if I could just auto-generate the constructor using Eclipse:

public class X {
    final int i;
    final int j;
    ...

    public X(int i, int j, ...) {
        this.i = i;
        this.j = j;
        ...
    }
}
Comment 1 Lukas Eder CLA 2015-03-04 11:38:19 EST
I realise that these are similar issues:

- https://bugs.eclipse.org/bugs/show_bug.cgi?id=80197
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=77147

But I don't think they're the same...
Comment 2 Lukas Eder CLA 2015-03-04 12:39:49 EST
In fact, I just realised that this feature already exists, but not as a quick-fix option. "Create constructor from fields...". Would be great to offer that feature as a quick-fix option!
Comment 3 Noopur Gupta CLA 2015-04-01 08:10:48 EDT

*** This bug has been marked as a duplicate of bug 345896 ***