Skip to content

Allow passing type information to ConvertStoredPropertyToComputed#3249

Merged
ahoppen merged 4 commits into
swiftlang:mainfrom
Padmashree06:convertStoredPropertyToComputed-add-type
Feb 9, 2026
Merged

Allow passing type information to ConvertStoredPropertyToComputed#3249
ahoppen merged 4 commits into
swiftlang:mainfrom
Padmashree06:convertStoredPropertyToComputed-add-type

Conversation

@Padmashree06

Copy link
Copy Markdown
Contributor

Update ConvertStoredPropertyToComputed to accept a TypeSyntax via a new Context struct. This allows refactoring to include type annotations when converting stored properties to computed properties.

Resolves: swiftlang/sourcekit-lsp#2459

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. This looks good. Could you add two test cases? One where a type annotation is missing and one is provided and one where it is not?

@Padmashree06

Copy link
Copy Markdown
Contributor Author

Thank you for reviewing. I will add the tests.

@Padmashree06

Copy link
Copy Markdown
Contributor Author

I have added tests. Please review.

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. I just realized that we don’t have this refactoring included in SyntaxCodeAction.swift in SourceKit-LSP. Would you like to add it to that list as well? You should be able to use the cursorInfo request to determine the type of a variable there.

@ahoppen

ahoppen commented Jan 31, 2026

Copy link
Copy Markdown
Member

@swift-ci Please test

@ahoppen

ahoppen commented Jan 31, 2026

Copy link
Copy Markdown
Member

Can you please ensure that your tests pass?

@Padmashree06

Copy link
Copy Markdown
Contributor Author

Looks good. I just realized that we don’t have this refactoring included in SyntaxCodeAction.swift in SourceKit-LSP. Would you like to add it to that list as well? You should be able to use the cursorInfo request to determine the type of a variable there.

Yes sure I'll add it. Thank you for the feedback

@Padmashree06

Copy link
Copy Markdown
Contributor Author

Can you please ensure that your tests pass?

Yes, I've resolved the spacing and trivia issues in the test suite. I’ve verified locally that all tests pass successfully.
Thank you

@PhantomInTheWire

Copy link
Copy Markdown
Member

@swift-ci please test

@PhantomInTheWire

Copy link
Copy Markdown
Member

@swift-ci please test windows

@ahoppen ahoppen merged commit c1d117c into swiftlang:main Feb 9, 2026
33 checks passed
@Padmashree06

Copy link
Copy Markdown
Contributor Author

Thank you for merging !

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.

Convert to computed property may generate code without a type annotation

3 participants