swiftlang / swift-syntax

A set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.
Apache License 2.0
3.13k stars 393 forks source link

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

Closed antigluten closed 6 days ago

antigluten commented 2 weeks ago

A part of https://github.com/swiftlang/sourcekit-lsp/issues/1246

harlanhaskins commented 1 week ago

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 }
}
antigluten commented 1 week ago

@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

ahoppen commented 1 week ago

@swift-ci Please test

ahoppen commented 1 week ago

@swift-ci Please test Windows

ahoppen commented 1 week ago

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 commented 1 week ago

@ahoppen, thank you for your hint, done rebasing

antigluten commented 1 week ago

Accidentally removed the wrong branch

ahoppen commented 1 week ago

@swift-ci Please test

ahoppen commented 1 week ago

@swift-ci Please test Windows