File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Sources/SwiftSyntaxBuilderGeneration Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ extension Node {
45
45
46
46
/// Assuming this node has a single child without a default value, that child.
47
47
var singleNonDefaultedChild : Child {
48
- let nonDefaultedParams = children. filter ( \ . type. defaultInitialization. isEmpty )
48
+ let nonDefaultedParams = children. filter { $0 . type. defaultInitialization == nil }
49
49
assert ( nonDefaultedParams. count == 1 )
50
50
return nonDefaultedParams [ 0 ]
51
51
}
Original file line number Diff line number Diff line change 10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ import SwiftSyntax
14
+ import SwiftSyntaxBuilder
15
+
13
16
/// Wrapper around the syntax kind strings to provide functionality specific to
14
17
/// SwiftSyntaxBuilder. In particular, this includes the functionality to create
15
18
/// the `*Buildable`, `ExpressibleAs*` and `*Syntax` Swift types from the syntax
@@ -43,17 +46,17 @@ struct SyntaxBuildableType: Hashable {
43
46
/// with fixed test), return an expression of the form ` = defaultValue`
44
47
/// that can be used as the default value for a function parameter.
45
48
/// Otherwise, return the empty string.
46
- var defaultInitialization : String {
49
+ var defaultInitialization : ExpressibleAsExprBuildable ? {
47
50
if isOptional {
48
- return " = nil"
51
+ return " nil "
49
52
} else if isToken {
50
53
if let token = token, token. text != nil {
51
- return " = TokenSyntax.` \( lowercaseFirstWord ( name: token. name) ) ` "
54
+ return MemberAccessExpr ( base : " TokenSyntax " , name : lowercaseFirstWord ( name: token. name) )
52
55
} else if tokenKind == " EOFToken " {
53
- return " = TokenSyntax. eof"
56
+ return MemberAccessExpr ( base : " TokenSyntax " , name : " eof " )
54
57
}
55
58
}
56
- return " "
59
+ return nil
57
60
}
58
61
59
62
/// Whether the type is a syntax collection.
You can’t perform that action at this time.
0 commit comments