Skip to content

Commit ab9b3ff

Browse files
committed
[ASTGen] NFC: Run swift-format
1 parent e60785e commit ab9b3ff

File tree

10 files changed

+135
-105
lines changed

10 files changed

+135
-105
lines changed

lib/ASTGen/Sources/ASTGen/ASTGen.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ extension ASTGenVisitor {
171171

172172
/// Obtains a pair of bridged identifier and the bridged source location.
173173
@inline(__always)
174-
func generateIdentifierAndSourceLoc(_ token: TokenSyntax) -> (identifier: BridgedIdentifier, sourceLoc: BridgedSourceLoc) {
174+
func generateIdentifierAndSourceLoc(_ token: TokenSyntax) -> (
175+
identifier: BridgedIdentifier, sourceLoc: BridgedSourceLoc
176+
) {
175177
return (
176178
self.generateIdentifier(token),
177179
self.generateSourceLoc(token)
@@ -182,7 +184,9 @@ extension ASTGenVisitor {
182184
/// If `token` is `nil`, returns a pair of an empty identifier and an invalid
183185
/// source location.
184186
@inline(__always)
185-
func generateIdentifierAndSourceLoc(_ token: TokenSyntax?) -> (identifier: BridgedIdentifier, sourceLoc: BridgedSourceLoc) {
187+
func generateIdentifierAndSourceLoc(_ token: TokenSyntax?) -> (
188+
identifier: BridgedIdentifier, sourceLoc: BridgedSourceLoc
189+
) {
186190
token.map(generateIdentifierAndSourceLoc(_:)) ?? (nil, nil)
187191
}
188192

@@ -454,13 +458,15 @@ private func _build<Node: SyntaxProtocol, Result>(
454458
endLocPtr.pointee = sourceLoc.advanced(by: node.totalLength.utf8Length)
455459

456460
// Convert the syntax node.
457-
return generator(ASTGenVisitor(
458-
diagnosticEngine: diagEngine,
459-
sourceBuffer: sourceFile.pointee.buffer,
460-
declContext: declContext,
461-
astContext: astContext,
462-
legacyParser: legacyParser
463-
))(node)
461+
return generator(
462+
ASTGenVisitor(
463+
diagnosticEngine: diagEngine,
464+
sourceBuffer: sourceFile.pointee.buffer,
465+
declContext: declContext,
466+
astContext: astContext,
467+
legacyParser: legacyParser
468+
)
469+
)(node)
464470
}
465471

466472
@_cdecl("swift_ASTGen_buildTypeRepr")

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ extension ASTGenVisitor {
399399
func generate(operatorDecl node: OperatorDeclSyntax) -> BridgedOperatorDecl {
400400
let (name, nameLoc) = self.generateIdentifierAndSourceLoc(node.name)
401401
let (precedenceGroupName, precedenceGroupLoc) =
402-
self.generateIdentifierAndSourceLoc(node.operatorPrecedenceAndTypes?.precedenceGroup)
402+
self.generateIdentifierAndSourceLoc(node.operatorPrecedenceAndTypes?.precedenceGroup)
403403

404404
let fixity: BridgedOperatorFixity
405405
if let value = BridgedOperatorFixity(from: node.fixitySpecifier.keywordKind) {

lib/ASTGen/Sources/ASTGen/Exprs.swift

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func isExprMigrated(_ node: ExprSyntax) -> Bool {
3939
}
4040
while true {
4141
switch current.kind {
42-
case // Known implemented kinds.
43-
.arrayExpr, .arrowExpr, .assignmentExpr, .awaitExpr, .binaryOperatorExpr,
44-
.booleanLiteralExpr, .borrowExpr, .closureExpr, .consumeExpr, .copyExpr,
45-
.discardAssignmentExpr, .declReferenceExpr, .dictionaryExpr,
46-
.functionCallExpr, .ifExpr, .integerLiteralExpr, .memberAccessExpr,
47-
.nilLiteralExpr, .packElementExpr, .packExpansionExpr,
48-
.postfixOperatorExpr, .prefixOperatorExpr, .sequenceExpr,
49-
.stringLiteralExpr, .tryExpr, .tupleExpr, .typeExpr, .unresolvedAsExpr,
50-
.unresolvedIsExpr, .unresolvedTernaryExpr:
42+
// Known implemented kinds.
43+
case .arrayExpr, .arrowExpr, .assignmentExpr, .awaitExpr, .binaryOperatorExpr,
44+
.booleanLiteralExpr, .borrowExpr, .closureExpr, .consumeExpr, .copyExpr,
45+
.discardAssignmentExpr, .declReferenceExpr, .dictionaryExpr,
46+
.functionCallExpr, .ifExpr, .integerLiteralExpr, .memberAccessExpr,
47+
.nilLiteralExpr, .packElementExpr, .packExpansionExpr,
48+
.postfixOperatorExpr, .prefixOperatorExpr, .sequenceExpr,
49+
.stringLiteralExpr, .tryExpr, .tupleExpr, .typeExpr, .unresolvedAsExpr,
50+
.unresolvedIsExpr, .unresolvedTernaryExpr:
5151

5252
// `generate(stringLiteralExpr:)` doesn't support interpolations.
5353
if let str = current.as(StringLiteralExprSyntax.self) {
@@ -58,17 +58,19 @@ func isExprMigrated(_ node: ExprSyntax) -> Bool {
5858
}
5959

6060
break
61-
case // Known unimplemented kinds.
62-
.asExpr, .canImportExpr, .canImportVersionInfo,
63-
.doExpr, .editorPlaceholderExpr, .floatLiteralExpr, .forceUnwrapExpr,
64-
.inOutExpr, .infixOperatorExpr, .isExpr, .keyPathExpr,
65-
.macroExpansionExpr, .optionalChainingExpr,
66-
.postfixIfConfigExpr, .regexLiteralExpr, .genericSpecializationExpr,
67-
.simpleStringLiteralExpr, .subscriptCallExpr, .superExpr, .switchExpr,
68-
.ternaryExpr, .patternExpr:
61+
62+
// Known unimplemented kinds.
63+
case .asExpr, .canImportExpr, .canImportVersionInfo,
64+
.doExpr, .editorPlaceholderExpr, .floatLiteralExpr, .forceUnwrapExpr,
65+
.inOutExpr, .infixOperatorExpr, .isExpr, .keyPathExpr,
66+
.macroExpansionExpr, .optionalChainingExpr,
67+
.postfixIfConfigExpr, .regexLiteralExpr, .genericSpecializationExpr,
68+
.simpleStringLiteralExpr, .subscriptCallExpr, .superExpr, .switchExpr,
69+
.ternaryExpr, .patternExpr:
6970
return false
70-
case // Unknown expr kinds.
71-
_ where current.is(ExprSyntax.self):
71+
72+
// Unknown expr kinds.
73+
case _ where current.is(ExprSyntax.self):
7274
return false
7375
default:
7476
break
@@ -322,7 +324,9 @@ extension ASTGenVisitor {
322324
return .createParsed(self.ctx, fn: callee, args: argumentTuple)
323325
}
324326

325-
private func createDeclNameRef(declReferenceExpr node: DeclReferenceExprSyntax) -> (name: BridgedDeclNameRef, loc: BridgedDeclNameLoc) {
327+
private func createDeclNameRef(declReferenceExpr node: DeclReferenceExprSyntax) -> (
328+
name: BridgedDeclNameRef, loc: BridgedDeclNameLoc
329+
) {
326330
let baseName: BridgedDeclBaseName
327331
switch node.baseName.keywordKind {
328332
case .`init`:
@@ -428,7 +432,7 @@ extension ASTGenVisitor {
428432
patternExpr: self.generate(expr: node.repetitionPattern)
429433
)
430434
}
431-
435+
432436
func generate(ifExpr node: IfExprSyntax) -> BridgedSingleValueStmtExpr {
433437
let stmt = makeIfStmt(node).asStmt
434438

@@ -611,7 +615,10 @@ extension ASTGenVisitor {
611615
}
612616

613617
extension ASTGenVisitor {
614-
fileprivate func createOperatorRefExpr(token node: TokenSyntax, kind: BridgedDeclRefKind) -> BridgedUnresolvedDeclRefExpr {
618+
fileprivate func createOperatorRefExpr(
619+
token node: TokenSyntax,
620+
kind: BridgedDeclRefKind
621+
) -> BridgedUnresolvedDeclRefExpr {
615622
let (name, nameLoc) = self.generateIdentifierAndSourceLoc(node)
616623

617624
return .createParsed(
@@ -622,9 +629,12 @@ extension ASTGenVisitor {
622629
);
623630
}
624631

625-
626632
/// Generate a tuple expression from a ``LabeledExprListSyntax`` and parentheses.
627-
func generate(labeledExprList node: LabeledExprListSyntax, leftParen: TokenSyntax?, rightParen: TokenSyntax?) -> BridgedTupleExpr {
633+
func generate(
634+
labeledExprList node: LabeledExprListSyntax,
635+
leftParen: TokenSyntax?,
636+
rightParen: TokenSyntax?
637+
) -> BridgedTupleExpr {
628638
let expressions = node.lazy.map {
629639
self.generate(expr: $0.expression)
630640
}

lib/ASTGen/Sources/ASTGen/LegacyParse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
import ASTBridging
1414
import BasicBridging
15-
import SwiftSyntax
1615
import ParseBridging
16+
import SwiftSyntax
1717

1818
extension ASTGenVisitor {
1919

@@ -40,10 +40,10 @@ extension ASTGenVisitor {
4040
}
4141

4242
func generateMatchingPatternWithLegacy(_ node: some PatternSyntaxProtocol) {
43-
// legacyParse.parseMatchingPattern(self.bridgedSourceLoc(syntax: node), self.declContext)
43+
// legacyParse.parseMatchingPattern(self.bridgedSourceLoc(syntax: node), self.declContext)
4444
}
4545

4646
func generateBindingPatternWithLegacy(_ node: some PatternSyntaxProtocol) {
47-
// legacyParse.parseBindingPattern(self.bridgedSourceLoc(syntax: node), self.declContext)
47+
// legacyParse.parseBindingPattern(self.bridgedSourceLoc(syntax: node), self.declContext)
4848
}
4949
}

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ func checkMacroDefinition(
235235
// least for documentation purposes right now. Don't emit a warning for
236236
// them, but do fail operation.
237237
case "FileIDMacro",
238-
"FilePathMacro",
239-
"FileMacro",
240-
"FunctionMacro",
241-
"LineMacro",
242-
"ColumnMacro",
243-
"DSOHandleMacro",
244-
"WarningMacro",
245-
"ErrorMacro":
238+
"FilePathMacro",
239+
"FileMacro",
240+
"FunctionMacro",
241+
"LineMacro",
242+
"ColumnMacro",
243+
"DSOHandleMacro",
244+
"WarningMacro",
245+
"ErrorMacro":
246246
return -1
247247

248248
default:
@@ -640,9 +640,9 @@ func findSyntaxNodeInSourceFile<Node: SyntaxProtocol>(
640640
// E.g. for 'foo.bar' we want the member ref expression instead of the
641641
// identifier expression.
642642
if wantOutermost {
643-
while
644-
let parentSyntax = currentSyntax.parent,
645-
parentSyntax.position == resultSyntax.position {
643+
while let parentSyntax = currentSyntax.parent,
644+
parentSyntax.position == resultSyntax.position
645+
{
646646
currentSyntax = parentSyntax
647647
if let typedParent = currentSyntax.as(type) {
648648
resultSyntax = typedParent

lib/ASTGen/Sources/ASTGen/ParameterClause.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,18 @@ extension ASTGenVisitor {
7474
let specifierLoc: BridgedSourceLoc = nil
7575

7676
let (firstName, firstNameLoc) =
77-
self.generateIdentifierAndSourceLoc(node.optionalFirstName)
77+
self.generateIdentifierAndSourceLoc(node.optionalFirstName)
7878
let (secondName, secondNameLoc) =
79-
self.generateIdentifierAndSourceLoc(node.secondName)
79+
self.generateIdentifierAndSourceLoc(node.secondName)
8080

8181
var type = node.optionalType.map(generate(type:))
8282
if let ellipsis = node.ellipsis, let base = type {
83-
type = BridgedVarargTypeRepr.createParsed(
84-
self.ctx,
85-
base: base,
86-
ellipsisLoc: self.generateSourceLoc(ellipsis)
87-
).asTypeRepr
83+
type =
84+
BridgedVarargTypeRepr.createParsed(
85+
self.ctx,
86+
base: base,
87+
ellipsisLoc: self.generateSourceLoc(ellipsis)
88+
).asTypeRepr
8889
}
8990

9091
return .createParsed(

lib/ASTGen/Sources/ASTGen/Patterns.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ extension ASTGenVisitor {
4545
func generate(identifierPattern node: IdentifierPatternSyntax) -> BridgedNamedPattern {
4646
let (name, nameLoc) = self.generateIdentifierAndSourceLoc(node.identifier)
4747
return .createParsed(
48-
ctx, declContext: declContext,
48+
ctx,
49+
declContext: declContext,
4950
name: name,
5051
loc: nameLoc
5152
)
@@ -105,5 +106,3 @@ extension ASTGenVisitor {
105106
)
106107
}
107108
}
108-
109-

lib/ASTGen/Sources/ASTGen/Regex.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ public func _RegexLiteralLexingFn(
4545
) -> /*CompletelyErroneous*/ Bool {
4646
let inputPtr = curPtrPtr.pointee
4747

48-
guard let (resumePtr, error) = swiftCompilerLexRegexLiteral(
49-
start: inputPtr, bufferEnd: bufferEndPtr, mustBeRegex: mustBeRegex
50-
) else {
48+
guard
49+
let (resumePtr, error) = swiftCompilerLexRegexLiteral(
50+
start: inputPtr,
51+
bufferEnd: bufferEndPtr,
52+
mustBeRegex: mustBeRegex
53+
)
54+
else {
5155
// Not a regex literal, fallback without advancing the pointer.
5256
return false
5357
}
@@ -97,12 +101,16 @@ public func _RegexLiteralParsingFn(
97101
) -> Bool {
98102
let str = String(bridged: input)
99103
let captureBuffer = UnsafeMutableRawBufferPointer(
100-
start: captureStructureOut, count: Int(captureStructureSize))
104+
start: captureStructureOut,
105+
count: Int(captureStructureSize)
106+
)
101107
do {
102108
// FIXME: We need to plumb through the 'regexToEmit' result to the caller.
103109
// For now, it is the same as the input.
104110
let (_, version) = try swiftCompilerParseRegexLiteral(
105-
str, captureBufferOut: captureBuffer)
111+
str,
112+
captureBufferOut: captureBuffer
113+
)
106114
versionOut.pointee = UInt(version)
107115
return false
108116
} catch let error as CompilerParseError {
@@ -126,8 +134,8 @@ public func _RegexLiteralParsingFn(
126134
}
127135
}
128136

129-
#else // canImport(_CompilerRegexParser)
137+
#else // canImport(_CompilerRegexParser)
130138

131139
#warning("Regex parsing is disabled")
132140

133-
#endif // canImport(_CompilerRegexParser)
141+
#endif // canImport(_CompilerRegexParser)

0 commit comments

Comments
 (0)