Skip to content

Code actions to convert between computed properties and zero-parameter functions #2721

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

Merged

Conversation

antigluten
Copy link
Contributor

@harlanhaskins
Copy link
Contributor

This is awesome!

Can you also add some tests to make sure this doesn't suggest the refactor:

var x: Int {
    get { 5 }
    set { /*anything */ }
}

And that the refactor succeeds with:

var x: Int {
    get { 5 }
}

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. The test suggestion from @harlanhaskins would be good to address as well but I’m pretty sure those test will pass.

@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from fada317 to 7b61dfa Compare July 17, 2024 07:42
@antigluten
Copy link
Contributor Author

@harlanhaskins Thank you, for your test suggestion!
@ahoppen, Thanks for your review, refactoring is done, added checking for get accessor when we converting to the function

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for also adding support for a variable with an explicit get getter.

@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from 7b61dfa to dccabd4 Compare July 17, 2024 20:24
@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from dccabd4 to 095ab04 Compare July 17, 2024 21:00
@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from 095ab04 to 92e22a3 Compare July 18, 2024 03:43
@ahoppen
Copy link
Member

ahoppen commented Jul 18, 2024

@swift-ci Please test

@ahoppen
Copy link
Member

ahoppen commented Jul 18, 2024

@swift-ci Please test Windows

@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from 92e22a3 to 3a81bb8 Compare July 18, 2024 20:54
@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from 3a81bb8 to 92e22a3 Compare July 18, 2024 20:55
@ahoppen
Copy link
Member

ahoppen commented Jul 18, 2024

Instead of merging main into your branch, could you rebase your branch on top of the latest main? It makes for a nicer git history and it’s too easy to hide weird subtle changes in merge commits.

@antigluten antigluten force-pushed the code-action-zero-parameter-function branch from 59a93cc to 4d6a1fa Compare July 18, 2024 21:20
@antigluten
Copy link
Contributor Author

@ahoppen, thank you for your hint, done rebasing

@antigluten antigluten closed this Jul 18, 2024
@antigluten antigluten deleted the code-action-zero-parameter-function branch July 18, 2024 21:23
@antigluten antigluten restored the code-action-zero-parameter-function branch July 18, 2024 21:23
@antigluten antigluten reopened this Jul 18, 2024
@antigluten
Copy link
Contributor Author

Accidentally removed the wrong branch

@ahoppen
Copy link
Member

ahoppen commented Jul 18, 2024

@swift-ci Please test

@ahoppen
Copy link
Member

ahoppen commented Jul 18, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit eb3ff35 into swiftlang:main Jul 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants