Skip to content

Change casting function to SyntaxEnum to as(SyntaxEnum.self) #168

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
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Note: This is in reverse chronological order, so newer entries are added to the
```swift
let node: Syntax

switch node.asSyntaxEnum {
switch node.as(SyntaxEnum.self) {
case .identifierExpr(let identifierExprSyntax):
/* ... */
}
Expand Down Expand Up @@ -126,4 +126,4 @@ For increased performance, the modelling of the syntax node hierarchy has been s
/* ... */
return ExprSyntax(identiferExprSyntax)
}
```
```
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/Misc.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public extension Syntax {
/// Retrieve the concretely typed node that this Syntax node wraps.
/// This property is exposed for testing purposes only.
var _asConcreteType: Any {
switch self.asSyntaxEnum {
switch self.as(SyntaxEnum.self) {
case .token(let node):
return node
case .unknown(let node):
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/SyntaxEnum.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum SyntaxEnum {

public extension Syntax {
/// Get an enum that can be used to exhaustively switch over all syntax nodes.
var asSyntaxEnum: SyntaxEnum {
func `as`(_: SyntaxEnum.Type) -> SyntaxEnum {
switch raw.kind {
case .token:
return .token(TokenSyntax(self)!)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/gyb_generated/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ public extension Syntax {
/// Retrieve the concretely typed node that this Syntax node wraps.
/// This property is exposed for testing purposes only.
var _asConcreteType: Any {
switch self.asSyntaxEnum {
switch self.as(SyntaxEnum.self) {
case .token(let node):
return node
case .unknown(let node):
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public enum SyntaxEnum {

public extension Syntax {
/// Get an enum that can be used to exhaustively switch over all syntax nodes.
var asSyntaxEnum: SyntaxEnum {
func `as`(_: SyntaxEnum.Type) -> SyntaxEnum {
switch raw.kind {
case .token:
return .token(TokenSyntax(self)!)
Expand Down