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-6278] Refactoring that outputs a "best-effort" member-wise init for a class or struct #48828

Open
swift-ci opened this issue Nov 2, 2017 · 1 comment
Labels
new feature refactoring Area → source tooling: refactoring

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 2, 2017

Previous ID SR-6278
Radar None
Original Reporter rayfix (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels New Feature, Refactoring
Assignee rayfix (JIRA)
Priority Medium

md5: b62dcc1461f29e6a0e7ddf70d290afa4

Issue Description:

Refactoring that outputs a "best-effort" member-wise init for a class or struct.

Local refactoring, cursor based

Availability: Cursor on class or struct name

Process: For every stored property create a argument with the same name.

class Derived: Base {{{ }}

{{ let property1: Type1}}{{ }}

{{ let property2: Type2?}}

{{}}}

This would generate:

init(property1: Type1, property2: Type2?) {{{ }}

{{ self.property1 = property1}}

{{ self.property2 = property2}}

{{ super.init()}}

{{}}}

Note: This code is "best-effort" as it may or may not compile depending on the requirements of Base initialization.

public struct Struct {{{ }}

{{ let property1: Type1}}{{ }}

{{ let property2: Type2}}

{{}}}

Would create:

public init(property1: Type1, property2: Type2) {{{ }}

{{ self.property1 = property1}}

{{ self.property2 = property2}}

{{}}}

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 2, 2017

Comment by Ray Fix (JIRA)

My thought was to dip my toe into refactoring by working on this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature refactoring Area → source tooling: refactoring
Projects
None yet
Development

No branches or pull requests

1 participant