Skip to content

Allow passing type information to ConvertStoredPropertyToComputed#3249

Open
Padmashree06 wants to merge 4 commits intoswiftlang:mainfrom
Padmashree06:convertStoredPropertyToComputed-add-type
Open

Allow passing type information to ConvertStoredPropertyToComputed#3249
Padmashree06 wants to merge 4 commits intoswiftlang:mainfrom
Padmashree06:convertStoredPropertyToComputed-add-type

Conversation

@Padmashree06
Copy link
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

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

Thank you for reviewing. I will add the tests.

@Padmashree06
Copy link
Contributor 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?

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

@swift-ci please test

@PhantomInTheWire
Copy link
Member

@swift-ci please test windows

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