Skip to content
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

Add a Refactoring Action for Converting Implicitly Unwrapped Optionals to Proper Optionals #1320

Open
CodaFi opened this issue May 18, 2024 · 1 comment · May be fixed by #1539
Open

Add a Refactoring Action for Converting Implicitly Unwrapped Optionals to Proper Optionals #1320

CodaFi opened this issue May 18, 2024 · 1 comment · May be fixed by #1539
Labels
code action Code action provided by LSP enhancement New feature or request good first issue Good for newcomers

Comments

@CodaFi
Copy link
Contributor

CodaFi commented May 18, 2024

Description

Add a refactoring action that converts T! to T? for all types T. At first blush, this appears to be possible by converting ImplicitlyUnwrappedOptionalTypeSyntax nodes to OptionalTypeSyntax nodes without changing the underlying type syntax for T.

As an aside, I think we may not necessarily want to go the other way (T? to T!) since it's generally not great Swift style.

@CodaFi CodaFi added enhancement New feature or request good first issue Good for newcomers code action Code action provided by LSP labels May 18, 2024
@ahoppen
Copy link
Member

ahoppen commented May 18, 2024

Synced to Apple’s issue tracker as rdar://128310729

@ahoppen ahoppen changed the title Add a Refactoring Action for Converting IUOs to Proper Optionals Add a Refactoring Action for Converting implicitly unwrapped optionals to proper optionals Jun 8, 2024
@ahoppen ahoppen changed the title Add a Refactoring Action for Converting implicitly unwrapped optionals to proper optionals Add a Refactoring Action for Converting Implicitly Unwrapped Optionals to Proper Optionals Jun 8, 2024
AppAppWorks added a commit to AppAppWorks/sourcekit-lsp that referenced this issue Jun 29, 2024
…1320

- created ConvertIUOToProperOptional that will suggest a conversion when the token in concern is
    - an IUO;
    - a direct child of an IUO; or
    - a direct child of the wrappedType of an IUO.
- registered in SyntaxCodeActions.allSyntaxCodeActions
- added a test in CodeActionTests
- added ConvertIUOToProperOptional.swift to CMakeLists of SourceKitLSP
AppAppWorks added a commit to AppAppWorks/sourcekit-lsp that referenced this issue Jul 1, 2024
…1320

- created ConvertImplicitlyUnwrappedOptionalToOptional that will suggest a conversion when the token in concern is
    - an IUO;
    - a direct child of an IUO; or
    - a direct child of the wrappedType of an IUO.
- registered in SyntaxCodeActions.allSyntaxCodeActions
- added a test in CodeActionTests
- added ConvertImplicitlyUnwrappedOptionalToOptional.swift to CMakeLists of SourceKitLSP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code action Code action provided by LSP enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants