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
[SR-10174] Childen of a MemberDeclListSyntax are no longer typed #420
Comments
cc @nkcsgexi |
Please note that I found a way around this change, so it's not a pressing issue for me, but I would still expect something like the above being possible. Alternatively better documentation with more example uses would be great that covers stuff like this. Currently the project isn't particularly easy to use. But I'm sure you're aware of that. |
@Jeehut We have this change because the items in a MemberDeclList consist not decls but another layer of structure called MemberDeclListItem . We need to unwrap MemberDeclListItem to get all the enum cases back. More specifically, this is the code snippet you could use to replace the 4.2 version: cases.append(contentsOf: node.members.members.compactMap {
($0 as MemberDeclListItemSyntax).decl as? EnumCaseDeclSyntax
}) |
For other parts of migrations for the new swift 5 tag, please refer to the changes swift-format has made here: google/swift@62d5af4 |
Thank you for the answer. I still think better documentation would be great for SwiftFormat with examples that are updated on new versions (instead of just linking to some examples usages that become out of date the moment a new version is released, like now). |
Closing this issue because the issue appears to be fixed. If you don’t agree, please re-open the issue. |
Add a quick workaround for keypaths starting with `\.?.`.
Environment
Xcode 10.2, macOS 10.14.3.
Additional Detail from JIRA
md5: 308b17bfa083679803f5f2d92c489f53
Issue Description:
In the Swift 4.2 release, childen of a `MemberDeclListSyntax` type were typed, thus the following code was working:
But after updating to Xcode 10.2 today, which includes the Swift 5.0 release, all `children` members are of type `Syntax` and casting to `EnumCaseDeclSyntax` fails, although that's the type I'm expecting here. You can find an example Swift file being parsed here.
Why was this API changed to be less informative? And how am I supposed to cast it to the appropriate type going forward with the 5.0 release?
It would be great to get feedback soon, so I can make a Xcode 10.2 compatible release of my tool BartyCrouch. See also the appropriate line here.
Thank you for your help in advance!
The text was updated successfully, but these errors were encountered: