Skip to content

Commit 917f5a4

Browse files
committed
Add TypeSyntax visitor.
1 parent d8aaef8 commit 917f5a4

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
@@ -10933,6 +10933,58 @@ extension SyntaxTransformVisitor {
1093310933
fatalError("Not expression?")
1093410934
}
1093510935
}
10936+
10937+
public func visit(_ data: TypeSyntax) -> [ResultType] {
10938+
switch data.raw.kind {
10939+
case .unknownType:
10940+
let node = data.as(UnknownTypeSyntax.self)!
10941+
return visit(node)
10942+
case .missingType:
10943+
let node = data.as(MissingTypeSyntax.self)!
10944+
return visit(node)
10945+
case .simpleTypeIdentifier:
10946+
let node = data.as(SimpleTypeIdentifierSyntax.self)!
10947+
return visit(node)
10948+
case .memberTypeIdentifier:
10949+
let node = data.as(MemberTypeIdentifierSyntax.self)!
10950+
return visit(node)
10951+
case .classRestrictionType:
10952+
let node = data.as(ClassRestrictionTypeSyntax.self)!
10953+
return visit(node)
10954+
case .arrayType:
10955+
let node = data.as(ArrayTypeSyntax.self)!
10956+
return visit(node)
10957+
case .dictionaryType:
10958+
let node = data.as(DictionaryTypeSyntax.self)!
10959+
return visit(node)
10960+
case .metatypeType:
10961+
let node = data.as(MetatypeTypeSyntax.self)!
10962+
return visit(node)
10963+
case .optionalType:
10964+
let node = data.as(OptionalTypeSyntax.self)!
10965+
return visit(node)
10966+
case .constrainedSugarType:
10967+
let node = data.as(ConstrainedSugarTypeSyntax.self)!
10968+
return visit(node)
10969+
case .implicitlyUnwrappedOptionalType:
10970+
let node = data.as(ImplicitlyUnwrappedOptionalTypeSyntax.self)!
10971+
return visit(node)
10972+
case .compositionType:
10973+
let node = data.as(CompositionTypeSyntax.self)!
10974+
return visit(node)
10975+
case .tupleType:
10976+
let node = data.as(TupleTypeSyntax.self)!
10977+
return visit(node)
10978+
case .functionType:
10979+
let node = data.as(FunctionTypeSyntax.self)!
10980+
return visit(node)
10981+
case .attributedType:
10982+
let node = data.as(AttributedTypeSyntax.self)!
10983+
return visit(node)
10984+
default:
10985+
fatalError("Not expression?")
10986+
}
10987+
}
1093610988

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

0 commit comments

Comments
 (0)