Skip to content

Clean up formatting of Observable macro #69644

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 2 commits into from
Nov 3, 2023

Conversation

stephencelis
Copy link
Contributor

Currently the macro preserves some trivia it shouldn't, and has inconsistent indentation. This PR trims this trivia and leaves things unindented so that SwiftSyntax's formatter can take care of it.

Currently the macro preserves some trivia it shouldn't, and has inconsistent indentation.
@stephencelis
Copy link
Contributor Author

Before/after:

 class State {
   var count = 0 {
-    @storageRestrictions(initializes: _count )
+    @storageRestrictions(initializes: _count)
       init(initialValue) {
-        _count  = initialValue
+        _count = initialValue
       }
       get {
-        access(keyPath: \.count )
-        return _count 
+        access(keyPath: \.count)
+        return _count
       }
       set {
-        withMutation(keyPath: \.count ) {
-          _count  = newValue
+        withMutation(keyPath: \.count) {
+          _count = newValue
         }
       }
     }
   }
   …
   internal nonisolated func access<Member>(
-      keyPath: KeyPath<State , Member>
+    keyPath: KeyPath<State, Member>
   ) {
     _$observationRegistrar.access(self, keyPath: keyPath)
   }
   …
 }

@phausler phausler self-requested a review November 3, 2023 18:28
Copy link
Contributor

@phausler phausler left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning this up! the output looks great.

From what I can tell this is a non-functional change so I don't see any issues with it.

@phausler
Copy link
Contributor

phausler commented Nov 3, 2023

@swift-ci please smoke test

@DougGregor
Copy link
Member

Thank you!

@DougGregor DougGregor merged commit 24dc372 into swiftlang:main Nov 3, 2023
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.

3 participants