-
Notifications
You must be signed in to change notification settings - Fork 439
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
Conversation
FixIt.Change
and FixIt.Changes
FixIt.Change
and FixIt.Changes
@swift-ci Please test |
@swift-ci Please test |
@swift-ci Please test |
@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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much copy-paste
@swift-ci Please test |
@swift-ci Please test Windows |
@swift-ci Please test Windows |
@swift-ci Please test |
@swift-ci Please test macOS |
@swift-ci Please test Windows |
@swift-ci Please test Linux |
@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.
@swift-ci Please test |
@swift-ci Please test macOS |
@swift-ci Please test Windows |
The existing API with
FixIt.Change
andFixIt.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 thatFixIt.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:FixIt.Changes
toSwiftParserDiagnostics
, make it internal and rename it toMultiNodeChange
. 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 isFixIt.Change
, which we want to continue to support. We will probably add more cases to it in the future.FixIt.Changes
no longer conform toExpressibleByArrayLiteral
. That just makes everything a lot more explicit and easier to follow.FixIt.Changes
whereFixIt.Change
was sufficient.presence
onTokenSyntax
settable so you can dotoken.with(\.presence, .missing)