Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7292] Swift local refactoring: adding field-wise initializers automatically #49840

Closed
nkcsgexi opened this issue Mar 27, 2018 · 4 comments
Closed

Comments

@nkcsgexi
Copy link
Member

nkcsgexi commented Mar 27, 2018

Previous ID SR-7292
Radar None
Original Reporter @nkcsgexi
Type New Feature
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels New Feature, Refactoring, StarterBug
Assignee mohit.athwani (JIRA)
Priority Medium

md5: 717c1a5493eaa3054e6b1fecb975394a

Issue Description:

Some initializers' implementation is quite expectable, e.g. a field-wise naive initializer. Thus, we can implement an automated refactoring to help developers adding such initializer, e.g.

// Right click on Animal and apply "add field-wise init" refactoring
class Animal {
  var age: Int
  var kind: AnimalKind
  var gender: Gender
}

An available refactoring "add field-wise init" shows up when the user right clicks the declared name `Animal`. After applying the local refactoring, the code snippet transforms to:

// code placeholder
class Animal {
  var age: Int
  var kind: AnimalKind
  var gender: Gender

  // Auto-generated initializer
  init(age: Int, kind: AnimalKind, gender: Gender) {
    self.age = age
    self.kind = kind
    self.gender = gender
  }
}
@swift-ci
Copy link
Collaborator

swift-ci commented Apr 30, 2018

Comment by Mohit Athwani (JIRA)

I'm trying to solve this as my starter bug... Could somebody please guide me on where to start with this?

@nkcsgexi
Copy link
Member Author

nkcsgexi commented Apr 30, 2018

mohit.athwani (JIRA User) similar with another task, we have the instruction here: https://swift.org/blog/swift-local-refactoring/

@swift-ci
Copy link
Collaborator

swift-ci commented May 31, 2018

Comment by Mohit Athwani (JIRA)

@nkcsgexi I will be starting work on this in the next day or two. I think this will be pretty quick as I can use everything I learn't from my recently closed PR... I will have to figure out how to get the correct location in the source code to write out the initializer...

@nkcsgexi
Copy link
Member Author

nkcsgexi commented May 31, 2018

Sounds great![]( mohit.athwani (JIRA User) I'm looking forward to your new PR)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants