Skip to content

Conversation

@Padmashree06
Copy link

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

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. 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
Author

Thank you for reviewing. I will add the tests.

@Padmashree06
Copy link
Author

I have added tests. Please review.

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.

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
Copy link
Member

ahoppen commented Jan 31, 2026

@swift-ci Please test

@ahoppen
Copy link
Member

ahoppen commented Jan 31, 2026

Can you please ensure that your tests pass?

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

2 participants