Skip to content

Commit 9093d1b

Browse files
committed
Reformat
1 parent 1e00efc commit 9093d1b

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

Sources/_SwiftSyntaxMacros/BasicMacroExpansionContext.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ public class BasicMacroExpansionContext {
3131
}
3232

3333
/// Create a new macro evaluation context.
34-
public init(expansionDiscriminator: String = "__macro_local_",
35-
sourceFiles: [SourceFileSyntax: KnownSourceFile] = [:]) {
34+
public init(
35+
expansionDiscriminator: String = "__macro_local_",
36+
sourceFiles: [SourceFileSyntax: KnownSourceFile] = [:]
37+
) {
3638
self.expansionDiscriminator = expansionDiscriminator
3739
self.sourceFiles = sourceFiles
3840
}
@@ -120,7 +122,7 @@ extension BasicMacroExpansionContext: MacroExpansionContext {
120122
diagnostics.append(diagnostic)
121123
}
122124

123-
public func location<Node: SyntaxProtocol> (
125+
public func location<Node: SyntaxProtocol>(
124126
of node: Node,
125127
at position: PositionInSyntaxNode,
126128
filePathMode: SourceLocationFilePathMode

Sources/_SwiftSyntaxMacros/MacroExpansionContext.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public protocol MacroExpansionContext: AnyObject {
4141
/// - Returns: the source location within the given node, or `nil` if the
4242
/// given syntax node is not rooted in a source file that the macro
4343
/// expansion context knows about.
44-
func location<Node: SyntaxProtocol> (
44+
func location<Node: SyntaxProtocol>(
4545
of node: Node,
4646
at position: PositionInSyntaxNode,
4747
filePathMode: SourceLocationFilePathMode
@@ -58,7 +58,7 @@ extension MacroExpansionContext {
5858
/// - Returns: the source location within the given node, or `nil` if the
5959
/// given syntax node is not rooted in a source file that the macro
6060
/// expansion context knows about.
61-
public func location<Node: SyntaxProtocol> (
61+
public func location<Node: SyntaxProtocol>(
6262
of node: Node
6363
) -> SourceLocation? {
6464
return location(of: node, at: .afterLeadingTrivia, filePathMode: .fileID)

Sources/_SwiftSyntaxMacros/Syntax+MacroEvaluation.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ extension SyntaxProtocol {
3535
//
3636
// TODO: Should this be generalized?
3737
if let testingContext = context as? BasicMacroExpansionContext,
38-
let parentSourceFile = root.as(SourceFileSyntax.self) {
38+
let parentSourceFile = root.as(SourceFileSyntax.self)
39+
{
3940
testingContext.addDisconnected(
40-
Syntax(detached), at: position, in: parentSourceFile
41+
Syntax(detached),
42+
at: position,
43+
in: parentSourceFile
4144
)
4245
}
4346

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ public struct ColumnMacro: ExpressionMacro {
131131
in context: Context
132132
) throws -> ExprSyntax {
133133
guard let sourceLoc = context.location(of: macro),
134-
let column = sourceLoc.column else {
134+
let column = sourceLoc.column
135+
else {
135136
throw CustomError.message("can't find location for macro")
136137
}
137138

138-
139139
let fileLiteral: ExprSyntax = "\(literal: column)"
140140
if let leadingTrivia = macro.leadingTrivia {
141141
return fileLiteral.with(\.leadingTrivia, leadingTrivia)
@@ -153,11 +153,11 @@ public struct FileIDMacro: ExpressionMacro {
153153
in context: Context
154154
) throws -> ExprSyntax {
155155
guard let sourceLoc = context.location(of: macro),
156-
let fileID = sourceLoc.file else {
156+
let fileID = sourceLoc.file
157+
else {
157158
throw CustomError.message("can't find location for macro")
158159
}
159160

160-
161161
let fileLiteral: ExprSyntax = "\(literal: fileID)"
162162
if let leadingTrivia = macro.leadingTrivia {
163163
return fileLiteral.with(\.leadingTrivia, leadingTrivia)
@@ -637,7 +637,7 @@ public func AssertMacroExpansion(
637637

638638
// Expand all macros in the source.
639639
let context = BasicMacroExpansionContext(
640-
sourceFiles: [origSourceFile : .init(moduleName: testModuleName, fullFilePath: testFileName) ]
640+
sourceFiles: [origSourceFile: .init(moduleName: testModuleName, fullFilePath: testFileName)]
641641
)
642642
let expandedSourceFile = origSourceFile.expand(macros: macros, in: context)
643643

0 commit comments

Comments
 (0)