Skip to content

Commit 7704521

Browse files
committed
Add TypeSyntax visitor.
1 parent 9cb7b9d commit 7704521

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

Sources/SwiftSyntax/SyntaxVisitor.swift.gyb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ extension SyntaxTransformVisitor {
232232
fatalError("Not expression?")
233233
}
234234
}
235+
236+
public func visit(_ data: TypeSyntax) -> [ResultType] {
237+
switch data.raw.kind {
238+
% for node in NON_BASE_SYNTAX_NODES:
239+
% if node.base_kind == "Type":
240+
case .${node.swift_syntax_kind}:
241+
let node = data.as(${node.name}.self)!
242+
return visit(node)
243+
% end
244+
% end
245+
default:
246+
fatalError("Not expression?")
247+
}
248+
}
235249

236250
public func visitChildren<SyntaxType: SyntaxProtocol>(_ node: SyntaxType) -> [ResultType] {
237251
let syntaxNode = Syntax(node)

Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10910,6 +10910,58 @@ extension SyntaxTransformVisitor {
1091010910
fatalError("Not expression?")
1091110911
}
1091210912
}
10913+
10914+
public func visit(_ data: TypeSyntax) -> [ResultType] {
10915+
switch data.raw.kind {
10916+
case .unknownType:
10917+
let node = data.as(UnknownTypeSyntax.self)!
10918+
return visit(node)
10919+
case .missingType:
10920+
let node = data.as(MissingTypeSyntax.self)!
10921+
return visit(node)
10922+
case .simpleTypeIdentifier:
10923+
let node = data.as(SimpleTypeIdentifierSyntax.self)!
10924+
return visit(node)
10925+
case .memberTypeIdentifier:
10926+
let node = data.as(MemberTypeIdentifierSyntax.self)!
10927+
return visit(node)
10928+
case .classRestrictionType:
10929+
let node = data.as(ClassRestrictionTypeSyntax.self)!
10930+
return visit(node)
10931+
case .arrayType:
10932+
let node = data.as(ArrayTypeSyntax.self)!
10933+
return visit(node)
10934+
case .dictionaryType:
10935+
let node = data.as(DictionaryTypeSyntax.self)!
10936+
return visit(node)
10937+
case .metatypeType:
10938+
let node = data.as(MetatypeTypeSyntax.self)!
10939+
return visit(node)
10940+
case .optionalType:
10941+
let node = data.as(OptionalTypeSyntax.self)!
10942+
return visit(node)
10943+
case .constrainedSugarType:
10944+
let node = data.as(ConstrainedSugarTypeSyntax.self)!
10945+
return visit(node)
10946+
case .implicitlyUnwrappedOptionalType:
10947+
let node = data.as(ImplicitlyUnwrappedOptionalTypeSyntax.self)!
10948+
return visit(node)
10949+
case .compositionType:
10950+
let node = data.as(CompositionTypeSyntax.self)!
10951+
return visit(node)
10952+
case .tupleType:
10953+
let node = data.as(TupleTypeSyntax.self)!
10954+
return visit(node)
10955+
case .functionType:
10956+
let node = data.as(FunctionTypeSyntax.self)!
10957+
return visit(node)
10958+
case .attributedType:
10959+
let node = data.as(AttributedTypeSyntax.self)!
10960+
return visit(node)
10961+
default:
10962+
fatalError("Not expression?")
10963+
}
10964+
}
1091310965

1091410966
public func visitChildren<SyntaxType: SyntaxProtocol>(_ node: SyntaxType) -> [ResultType] {
1091510967
let syntaxNode = Syntax(node)

0 commit comments

Comments
 (0)