Skip to content

Commit 4fa7cca

Browse files
committed
Add convenience initializer for àBinaryOperatorExpr`
1 parent b0beb45 commit 4fa7cca

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 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+
extension BinaryOperatorExpr {
16+
public init(_ text: String) {
17+
self.init(operatorToken: TokenSyntax.spacedBinaryOperator(text))
18+
}
19+
}
20+
21+
extension BinaryOperatorExpr: ExpressibleByStringLiteral {
22+
public init(stringLiteral value: String) {
23+
self.init(value)
24+
}
25+
}

Sources/SwiftSyntaxBuilder/gyb_generated/Buildables.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12318,7 +12318,7 @@ extension VersionTuple: ExpressibleAsVersionTuple {
1231812318
}
1231912319
}
1232012320

12321-
extension TokenSyntax: ExpressibleAsIdentifierList, ExpressibleAsTokenList, ExpressibleAsNonEmptyTokenList {
12321+
extension TokenSyntax: ExpressibleAsIdentifierList, ExpressibleAsTokenList, ExpressibleAsNonEmptyTokenList, ExpressibleAsBinaryOperatorExpr {
1232212322
}
1232312323

1232412324
// MARK: - Syntax Collection buildable expressible as conformances
@@ -12583,6 +12583,12 @@ extension ExpressibleAsMemberDeclList {
1258312583
}
1258412584
}
1258512585

12586+
extension TokenSyntax {
12587+
public func createBinaryOperatorExpr() -> BinaryOperatorExpr {
12588+
BinaryOperatorExpr(operatorToken: self)
12589+
}
12590+
}
12591+
1258612592
extension ExpressibleAsDeclBuildable {
1258712593
public func createCodeBlockItem() -> CodeBlockItem {
1258812594
CodeBlockItem(item: self)

0 commit comments

Comments
 (0)