Skip to content

Add refactoring action to convert stored to computed properties - #2622

Merged
ahoppen merged 2 commits into
swiftlang:mainfrom
ahoppen:stored-to-computed
Jul 24, 2026
Merged

Add refactoring action to convert stored to computed properties#2622
ahoppen merged 2 commits into
swiftlang:mainfrom
ahoppen:stored-to-computed

Conversation

@ahoppen

@ahoppen ahoppen commented Apr 27, 2026

Copy link
Copy Markdown
Member

This is the first syntactic refactoring action that needs to perform a cursor info request on codeAction/resolve, so the majority of this PR is to add infrastructure for that.

Based on #2496.

WorkspaceEdit(
changes: [
uri: [
TextEdit(range: positions["1️⃣"]..<positions["3️⃣"], newText: "\n var x :Int{ 25 }")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Padmashree06: It looks like the refactoring action in swift-syntax doesn’t produce correct whitespaces here (it should be x: Int, not x :Int). Would you be able to work on a fix for that in swift-syntax?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes sure! I will fix it!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ahoppen I have fixed the whitespace error in swift-syntax.

@ahoppen

ahoppen commented Apr 27, 2026

Copy link
Copy Markdown
Member Author

@swift-ci Please test

Comment thread Sources/SwiftLanguageService/CodeActions/ConvertStoredPropertyToComputed.swift Outdated
Comment thread Sources/SwiftLanguageService/SwiftLanguageService.swift
@ahoppen

ahoppen commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Finally got back to this and updated it to have two distinct code action + resolve phases. Ready for another review.

@ahoppen

ahoppen commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

swiftlang/swift-tools-protocols#72

@swift-ci Please test

Comment thread Sources/SwiftLanguageService/SwiftLanguageService.swift Outdated
@ahoppen
ahoppen force-pushed the stored-to-computed branch from 81df70d to 46ca133 Compare July 9, 2026 07:46
Comment thread Sources/SwiftSyntaxCodeActions/SyntaxCodeActionProvider.swift Outdated
Comment thread Sources/SwiftLanguageService/SwiftLanguageService.swift Outdated
This is the first syntactic refactoring action that needs to perform a cursor info request on `codeAction/resolve`, so the majority of this PR is to add infrastructure for that.

Based on swiftlang#2496.

Co-Authored-By: Padmashree S S <padmashreess2006@gmail.com>
@ahoppen
ahoppen force-pushed the stored-to-computed branch from 46ca133 to a3f9b80 Compare July 10, 2026 12:12
@ahoppen

ahoppen commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

@swift-ci Please test

@ahoppen
ahoppen force-pushed the stored-to-computed branch from 659c4b3 to 30bea88 Compare July 13, 2026 08:56
@ahoppen

ahoppen commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

swiftlang/swift-tools-protocols#72

@swift-ci Please test

@rintaro

rintaro commented Jul 21, 2026

Copy link
Copy Markdown
Member

swiftlang/swift-tools-protocols#72
@swift-ci Please test

@ahoppen

ahoppen commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

swiftlang/swift-tools-protocols#72
@swift-ci Please test Windows

ahoppen added a commit to swiftlang/swift-tools-protocols that referenced this pull request Jul 24, 2026
@ahoppen
ahoppen merged commit 91faff6 into swiftlang:main Jul 24, 2026
3 checks passed
@ahoppen
ahoppen deleted the stored-to-computed branch July 24, 2026 13:39
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