Skip to content

Commit e4d795d

Browse files
committed
Add ExprBuildable protocol for building ExprSyntax
1 parent 147000e commit e4d795d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import SwiftSyntax
14+
15+
public protocol ExprListBuildable: SyntaxListBuildable {
16+
func buildExprList(format: Format, leadingTrivia: Trivia) -> [ExprSyntax]
17+
}
18+
19+
public protocol ExprBuildable: SyntaxBuildable, ExprListBuildable {
20+
func buildExpr(format: Format, leadingTrivia: Trivia) -> ExprSyntax
21+
}
22+
23+
extension ExprBuildable {
24+
public func buildSyntax(format: Format, leadingTrivia: Trivia) -> Syntax {
25+
buildExpr(format: format, leadingTrivia: leadingTrivia)
26+
}
27+
28+
public func buildExprList(format: Format, leadingTrivia: Trivia) -> [ExprSyntax] {
29+
[buildExpr(format: format, leadingTrivia: leadingTrivia)]
30+
}
31+
}

0 commit comments

Comments
 (0)