Skip to content
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
3 changes: 2 additions & 1 deletion Sources/SwiftSyntax/SyntaxBuilders.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public struct ${Builder} {
% if child_node and child_node.is_syntax_collection():
% child_elt = child_node.collection_element_name
% child_elt_type = child_node.collection_element_type
% child_elt_name = child.name + 'Member'

public mutating func add${child_elt}(_ elt: ${child_elt_type}) {
public mutating func add${child_elt_name}(_ elt: ${child_elt_type}) {
let idx = ${node.name}.Cursor.${child.swift_name}.rawValue
if let list = layout[idx] {
layout[idx] = list.appending(elt.raw)
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftSyntax/SyntaxNodes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ public struct ${node.name}: ${base_type}, _SyntaxBase, Hashable {
% if child_node and child_node.is_syntax_collection():
% child_elt = child_node.collection_element_name
% child_elt_type = child_node.collection_element_type
% child_elt_name = child.name + 'Member'

/// Adds the provided `${child_elt}` to the node's `${child.swift_name}`
/// collection.
/// - param element: The new `${child_elt}` to add to the node's
/// `${child.swift_name}` collection.
/// - returns: A copy of the receiver with the provided `${child_elt}`
/// appended to its `${child.swift_name}` collection.
public func add${child_elt}(_ element: ${child_elt_type}) -> ${node.name} {
public func add${child_elt_name}(_ element: ${child_elt_type}) -> ${node.name} {
var collection: RawSyntax
if let col = raw[Cursor.${child.swift_name}] {
collection = col.appending(element.raw)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftSyntaxTest/ModifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fileprivate func cannedVarDecl() -> VariableDeclSyntax {
initializer: nil, accessor: nil, trailingComma: nil)
return VariableDeclSyntax {
$0.useLetOrVarKeyword(SyntaxFactory.makeLetKeyword())
$0.addPatternBinding(Pattern)
$0.addBindingsMember(Pattern)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftSyntaxTest/SyntaxFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
let call = FunctionCallExprSyntax {
$0.useCalledExpression(printID)
$0.useLeftParen(SyntaxFactory.makeLeftParenToken())
$0.addFunctionCallArgument(arg)
$0.addArgumentListMember(arg)
$0.useRightParen(SyntaxFactory.makeRightParenToken())
}
XCTAssertEqual("\(call)", "print(\"Hello, world!\")")
Expand Down Expand Up @@ -133,7 +133,7 @@ public class SyntaxFactoryAPITestCase: XCTestCase {
let call1 = FunctionCallExprSyntax {
$0.useCalledExpression(printID)
$0.useLeftParen(SyntaxFactory.makeLeftParenToken())
$0.addFunctionCallArgument(arg)
$0.addArgumentListMember(arg)
$0.useRightParen(SyntaxFactory.makeRightParenToken())
}
XCTAssertNotNil(call1.leftParen)
Expand All @@ -145,7 +145,7 @@ public class SyntaxFactoryAPITestCase: XCTestCase {

let call3 = FunctionCallExprSyntax {
$0.useCalledExpression(printID)
$0.addFunctionCallArgument(arg)
$0.addArgumentListMember(arg)
}
XCTAssertNil(call3.leftParen)
XCTAssertNil(call3.rightParen)
Expand Down