Skip to content

Get rid of XXXSyntax.Cursor type #630

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
Aug 23, 2022
Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 23, 2022

They are internal types which served as layout 'subscript' keys e.g. layout[Cursor.propertyName]. That looks nice, but in reality, the name is usually written very close, like:

  var propertyName: PropertyType {
    get { layout[Cursor.propertyName] }
  }

So it didn't give us much benefit. In the contrary, it hid the actual "index" information which might be useful when investigating issues. So just get rid of them for now.

Since they are just internal types, there's no external API changes.

They are internal types which served as layout 'subscript' keys e.g.
`layout[Cursor.propertyName]`. That looks nice, but in reality, the
name is usually written very close:

  var propertyName: PropertyType {
    get { layout[Cursor.propertyName] }
  }

So it didn't give us much benefit. In the contrary, it hid the "index"
information which might be useful when investigating issues. So just get
rid of them for now.

Since they are just internal types. So no external API changes.
@rintaro rintaro requested a review from ahoppen as a code owner August 23, 2022 21:08
@rintaro
Copy link
Member Author

rintaro commented Aug 23, 2022

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Aug 23, 2022

Maybe it's convenient for getting a property name from an index? Like String(describing: FunctionDeclSyntax.Cursor(rawValue: 1)!).
I guess we'd just do

extension FunctionDeclSyntax {
  static func propertyName(at i: Int) -> String {
    switch i {
    case 0: return "unexpectedBeforeAttributes"
    case 1: return "attributes"
    ...
    }
  }
}

or similar when we want.

@rintaro rintaro merged commit 276d2e0 into swiftlang:main Aug 23, 2022
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.

2 participants