-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code action to convert between computed property and stored property #1245
Comments
Synced to Apple’s issue tracker as rdar://128016684 |
@ahoppen I'm working on this enhancement, I have a few questions for the requirement,
|
Thanks for looking into this @AppAppWorks!
It would be great to preserve all comments. I don’t care about whitespace that much.
What do you think about running a
Ideally we shouldn’t offer the code action if the surrounding type cannot have a stored property. |
Thanks for your clarifications and suggestions! I didn't know it's possible to determine variable types with SwiftLanguageService.variableTypeInfos. |
@AppAppWorks have you stared work on this already? @antigluten opened swiftlang/swift-syntax#2712 to implement the syntactic transformation in swift-syntax. Would you like to collaborate on this issue. For example @antigluten finishes his PR in swift-syntax to cover the syntactic cases and @AppAppWorks would you be interested in adding the cases you mentioned in this issue on top, like adding explicit type annotations to the computed property if it was previously inferred and restricting it to the contexts that can validly have a stored property? Or would you be interested on tackling those extended goals as well, @antigluten? |
I've started work on this for a while but I'm currently stuck with finding a way to inject a language service instance into the code action.
I'd definitely love to collaborate with @antigluten! |
If you’re stuck and you need help with something, feel free to put up a PR and highlight where you’ve got questions and I can help you. |
I've figured out the entry point of code actions in
The problem is |
The proper solution here would be that the |
I'm also asking on behalf of #1539,
|
Yes
My understanding of the codeAction/resolve request is that it will be sent automatically from the client if textDocument.codeAction.resolveSupport = { properties: ['edit'] };
SourceKit-LSP has support for find references that we should be able to re-use: sourcekit-lsp/Sources/SourceKitLSP/SourceKitLSPServer.swift Lines 1910 to 1934 in 607292a
I don’t think LSP supports any kind of confirmation dialog like that, so no. |
Description
A stored property with an initializer, e.g.,
might be better off as a computed property:
or vice versa. Let's create a pair of code actions to go from the first to second or vice-versa.
The text was updated successfully, but these errors were encountered: