Skip to content

Commit d7c4d4b

Browse files
committed
Run swift-format to re-format codes
1 parent c347512 commit d7c4d4b

File tree

5 files changed

+53
-52
lines changed

5 files changed

+53
-52
lines changed

Sources/SwiftOperators/SyntaxSynthesis.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
import SwiftSyntax
1414

1515
fileprivate extension OperatorKind {
16-
var keyword: Keyword {
17-
switch self {
18-
case .infix: return .infix
19-
case .prefix: return .prefix
20-
case .postfix: return .postfix
21-
}
22-
}
23-
}
16+
var keyword: Keyword {
17+
switch self {
18+
case .infix: return .infix
19+
case .prefix: return .prefix
20+
case .postfix: return .postfix
21+
}
22+
}
23+
}
2424

2525
extension Operator {
2626
/// Synthesize a syntactic representation of this operator based on its

Sources/SwiftParser/Declarations.swift

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,55 +1877,55 @@ extension Parser {
18771877
/// postfix-operator-declaration → 'postfix' 'operator' operator
18781878
/// infix-operator-declaration → 'infix' 'operator' operator infix-operator-group?
18791879
/// infix-operator-group → ':' precedence-group-name
1880-
1880+
18811881
struct OperatorDeclarationIntroducer {
18821882
var unexpectedBeforeIntroducer: RawUnexpectedNodesSyntax?
18831883
var operatorModifier: RawTokenSyntax
18841884
var unexpectedBetweenModifierAndOperatorKeyword: RawUnexpectedNodesSyntax?
18851885
var operatorKeyword: RawTokenSyntax
18861886
}
1887-
1888-
1887+
18891888
mutating func parseOperatorDeclarationIntroducer(
18901889
_ attrs: DeclAttributes,
1891-
_ handle: RecoveryConsumptionHandle) -> OperatorDeclarationIntroducer {
1892-
var modifier = attrs.modifiers?.elements.first?.name ?? self.missingToken(.prefix)
1893-
1894-
if ![Keyword.prefix, .infix, .postfix]
1895-
.map({$0.defaultText}).contains(modifier.tokenText) {
1896-
modifier = self.missingToken(.prefix)
1897-
}
1898-
1899-
let (unexpectedBeforeOperator, operatorKeyword) = self.eat(handle)
1900-
1901-
let unexpectedBeforeIntroducer = RawUnexpectedNodesSyntax(attrs.attributes?.elements, arena: self.arena)
1902-
1903-
var unexpectedBetweenModifierAndOperatorKeyword = unexpectedBeforeOperator
1904-
1905-
if modifier.presence == .missing {
1906-
unexpectedBetweenModifierAndOperatorKeyword = RawUnexpectedNodesSyntax(combining: unexpectedBeforeOperator, RawUnexpectedNodesSyntax(attrs.modifiers?.elements, arena: self.arena), arena: self.arena)
1907-
} else {
1908-
unexpectedBetweenModifierAndOperatorKeyword = RawUnexpectedNodesSyntax(combining: unexpectedBeforeOperator, RawUnexpectedNodesSyntax(Array((attrs.modifiers?.elements.dropFirst()) ?? []), arena: self.arena), arena: self.arena)
1909-
}
1910-
1911-
1912-
return OperatorDeclarationIntroducer(
1913-
unexpectedBeforeIntroducer: unexpectedBeforeIntroducer,
1914-
operatorModifier: modifier,
1915-
unexpectedBetweenModifierAndOperatorKeyword: unexpectedBetweenModifierAndOperatorKeyword,
1916-
operatorKeyword: operatorKeyword
1917-
)
1918-
1890+
_ handle: RecoveryConsumptionHandle
1891+
) -> OperatorDeclarationIntroducer {
1892+
var modifier = attrs.modifiers?.elements.first?.name ?? self.missingToken(.prefix)
1893+
1894+
if ![Keyword.prefix, .infix, .postfix]
1895+
.map({ $0.defaultText }).contains(modifier.tokenText)
1896+
{
1897+
modifier = self.missingToken(.prefix)
1898+
}
1899+
1900+
let (unexpectedBeforeOperator, operatorKeyword) = self.eat(handle)
1901+
1902+
let unexpectedBeforeIntroducer = RawUnexpectedNodesSyntax(attrs.attributes?.elements, arena: self.arena)
1903+
1904+
var unexpectedBetweenModifierAndOperatorKeyword = unexpectedBeforeOperator
1905+
1906+
if modifier.presence == .missing {
1907+
unexpectedBetweenModifierAndOperatorKeyword = RawUnexpectedNodesSyntax(combining: unexpectedBeforeOperator, RawUnexpectedNodesSyntax(attrs.modifiers?.elements, arena: self.arena), arena: self.arena)
1908+
} else {
1909+
unexpectedBetweenModifierAndOperatorKeyword = RawUnexpectedNodesSyntax(combining: unexpectedBeforeOperator, RawUnexpectedNodesSyntax(Array((attrs.modifiers?.elements.dropFirst()) ?? []), arena: self.arena), arena: self.arena)
1910+
}
1911+
1912+
return OperatorDeclarationIntroducer(
1913+
unexpectedBeforeIntroducer: unexpectedBeforeIntroducer,
1914+
operatorModifier: modifier,
1915+
unexpectedBetweenModifierAndOperatorKeyword: unexpectedBetweenModifierAndOperatorKeyword,
1916+
operatorKeyword: operatorKeyword
1917+
)
1918+
19191919
}
1920-
1920+
19211921
@_spi(RawSyntax)
19221922
public mutating func parseOperatorDeclaration(
19231923
_ attrs: DeclAttributes,
19241924
_ handle: RecoveryConsumptionHandle
19251925
) -> RawOperatorDeclSyntax {
1926-
1926+
19271927
let introducer = parseOperatorDeclarationIntroducer(attrs, handle)
1928-
1928+
19291929
let unexpectedBeforeName: RawUnexpectedNodesSyntax?
19301930
let name: RawTokenSyntax
19311931
switch self.canRecoverTo(anyIn: OperatorLike.self) {

Sources/SwiftParser/SyntaxUtils.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension RawUnexpectedNodesSyntax {
4141
init?<SyntaxType: RawSyntaxNodeProtocol>(_ nodes: [SyntaxType?], arena: __shared SyntaxArena) {
4242
self.init(nodes.compactMap({ $0 }), arena: arena)
4343
}
44-
44+
4545
init?<SyntaxType: RawSyntaxNodeProtocol>(_ nodes: [SyntaxType]?, arena: __shared SyntaxArena) {
4646
guard let nodes = nodes else {
4747
return nil
@@ -87,11 +87,12 @@ extension RawUnexpectedNodesSyntax {
8787
init?<T1: UnexpectedNodesCombinable, T2: UnexpectedNodesCombinable, T3: UnexpectedNodesCombinable>(combining syntax1: T1, _ syntax2: T2, _ syntax3: T3, arena: __shared SyntaxArena) {
8888
self.init(syntax1.elements + syntax2.elements + syntax3.elements, arena: arena)
8989
}
90-
90+
9191
init?<T1: UnexpectedNodesCombinable, T2: UnexpectedNodesCombinable>(combining optionalSyntax1: T1?, _ optionalSyntax2: T2?, arena: __shared SyntaxArena) {
9292
if let syntax1 = optionalSyntax1,
93-
let syntax2 = optionalSyntax2 {
94-
self.init(syntax1.elements+syntax2.elements, arena: arena)
93+
let syntax2 = optionalSyntax2
94+
{
95+
self.init(syntax1.elements + syntax2.elements, arena: arena)
9596
} else if let syntax1 = optionalSyntax1 {
9697
self.init(syntax1.elements, arena: arena)
9798
} else if let syntax2 = optionalSyntax2 {

Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,15 +893,15 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
893893
if shouldSkip(node) {
894894
return .skipChildren
895895
}
896-
896+
897897
if node.operatorModifier.presence == .missing {
898898
addDiagnostic(
899899
node.operatorModifier,
900900
.missingModifierInOperatorDeclaration,
901901
handledNodes: [node.operatorModifier.id]
902902
)
903903
}
904-
904+
905905
if let unexpected = node.unexpectedAfterOperatorPrecedenceAndTypes,
906906
unexpected.contains(where: { $0.is(PrecedenceGroupAttributeListSyntax.self) }) == true
907907
{

Tests/SwiftParserTest/translated/OperatorDeclTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ final class OperatorDeclTests: XCTestCase {
132132
""",
133133
diagnostics: [
134134
DiagnosticSpec(locationMarker: "1️⃣", message: "operator must be declared as 'prefix', 'postfix', or 'infix'"),
135-
DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body")
135+
DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body"),
136136
]
137137
)
138138
}
@@ -143,8 +143,8 @@ final class OperatorDeclTests: XCTestCase {
143143
1️⃣operator +*++* : A 2️⃣{ }
144144
""",
145145
diagnostics: [
146-
DiagnosticSpec(locationMarker: "1️⃣", message:"operator must be declared as 'prefix', 'postfix', or 'infix'"),
147-
DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body")
146+
DiagnosticSpec(locationMarker: "1️⃣", message: "operator must be declared as 'prefix', 'postfix', or 'infix'"),
147+
DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body"),
148148
]
149149
)
150150
}
@@ -168,7 +168,7 @@ final class OperatorDeclTests: XCTestCase {
168168
""",
169169
diagnostics: [
170170
DiagnosticSpec(message: "operator must be declared as 'prefix', 'postfix', or 'infix'"),
171-
DiagnosticSpec(message: "unexpected code before operator declaration")
171+
DiagnosticSpec(message: "unexpected code before operator declaration"),
172172
]
173173
)
174174
}

0 commit comments

Comments
 (0)