Skip to content

Slightly clean up FixIt.Change and FixIt.Changes #1460

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

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 28, 2023

The existing API with FixIt.Change and FixIt.Changes and the fact that we passed [FixIt.Changes] around what fairly weird.

Ideally, we would only have FixIt.Change and make it powerful enough to represent all the trivia transfer that FixIt.Changes is doing. But given that that will be a larger effort, let’s make some smaller changes now that reduce the badness of the public API impact:

  • Move FixIt.Changes to SwiftParserDiagnostics, make it internal and rename it to MultiNodeChange. That way this type is no longer exposed in the public API, so we can iterate on it or remove it without breaking clients. The only thing that remains exposed is FixIt.Change, which we want to continue to support. We will probably add more cases to it in the future.
  • Make FixIt.Changes no longer conform to ExpressibleByArrayLiteral. That just makes everything a lot more explicit and easier to follow.
  • Remove some unecessary initializations of FixIt.Changes where FixIt.Change was sufficient.
  • Make presence on TokenSyntax settable so you can do token.with(\.presence, .missing)
  • Slightly unrelated: Rename SyntaxOtherNodes.swift to TokenSyntax.swift because that’s the only node it contains.

@ahoppen ahoppen requested a review from bnbarham March 28, 2023 22:02
@ahoppen ahoppen changed the title Sligthly clean up FixIt.Change and FixIt.Changes Slightly clean up FixIt.Change and FixIt.Changes Mar 28, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Mar 28, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 28, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@swift-ci Please test Windows

public func withPresence(_ newValue: SourcePresence, arena: SyntaxArena) -> RawSyntax {
switch raw.rawData.payload {
case .parsedToken(_):
// The wholeText can't be continuous anymore. Make a materialized token.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't it be continuous any more? We're only changing presence here. It's true that we might then merge the trivia later (?) but that doesn't matter for here, am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Too much copy-paste

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

@swift-ci Please test Windows

@shahmishal
Copy link
Member

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Mar 29, 2023

swiftlang/swift#64747

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 30, 2023

swiftlang/swift#64747

@swift-ci Please test macOS

@ahoppen
Copy link
Member Author

ahoppen commented Mar 30, 2023

swiftlang/swift#64747

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Mar 30, 2023

swiftlang/swift#64747

@swift-ci Please test Linux

@ahoppen
Copy link
Member Author

ahoppen commented Mar 31, 2023

swiftlang/swift#64747

@swift-ci Please test Windows

The existing API with `FixIt.Change` and `FixIt.Changes` and the fact that we passed `[FixIt.Changes]` around what fairly weird.

Ideally, we would only have `FixIt.Change` and make it powerful enough to represent all the trivia transfer that `FixIt.Changes` is doing. But given that that will be a larger effort, let’s make some smaller changes now that reduce the badness of the public API impact:

- Move `FixIt.Changes` to `SwiftParserDiagnostics`, make it internal and rename it to `MultiNodeChange`. That way this type is no longer exposed in the public API, so we can iterate on it or remove it without breaking clients. The only thing that remains exposed is `FixIt.Change`, which we want to continue to support. We will probably add more cases to it in the future.
- Make `FixIt.Changes` no longer conform to `ExpressibleByArrayLiteral`. That just makes everything a lot more explicit and easier to follow.
- Remove some unecessary initializations of `FixIt.Changes` where `FixIt.Change` was sufficient.
- Make `presence` on `TokenSyntax` settable so you can do `token.with(\.presence, .missing)`
- Slightly unrelated: Rename SyntaxOtherNodes.swift to TokenSyntax.swift because that’s the only node it contains.
@ahoppen
Copy link
Member Author

ahoppen commented Apr 4, 2023

swiftlang/swift#64747

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

swiftlang/swift#64747

@swift-ci Please test macOS

@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

swiftlang/swift#64747

@swift-ci Please test Windows

@ahoppen ahoppen merged commit d8dee5c into swiftlang:main Apr 5, 2023
@ahoppen ahoppen deleted the ahoppen/fixit branch April 5, 2023 22:57
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.

4 participants