File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Sources/SwiftCompilerPluginMessageHandling Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import SwiftBasicFormat
14
14
import SwiftDiagnostics
15
+ import SwiftOperators
15
16
import SwiftSyntax
16
17
import SwiftSyntaxMacros
17
18
@@ -28,7 +29,7 @@ extension CompilerPluginMessageHandler {
28
29
expandingSyntax: PluginMessage . Syntax
29
30
) throws {
30
31
let sourceManager = SourceManager ( )
31
- let syntax = sourceManager. add ( expandingSyntax)
32
+ let syntax = sourceManager. add ( expandingSyntax, foldingWith : . standardOperators )
32
33
33
34
let context = PluginMacroExpansionContext (
34
35
sourceManager: sourceManager,
@@ -97,7 +98,10 @@ extension CompilerPluginMessageHandler {
97
98
expansionDiscriminator: discriminator
98
99
)
99
100
100
- let attributeNode = sourceManager. add ( attributeSyntax) . cast ( AttributeSyntax . self)
101
+ let attributeNode = sourceManager. add (
102
+ attributeSyntax,
103
+ foldingWith: . standardOperators
104
+ ) . cast ( AttributeSyntax . self)
101
105
let declarationNode = sourceManager. add ( declSyntax) . cast ( DeclSyntax . self)
102
106
103
107
let expandedSources : [ String ]
Original file line number Diff line number Diff line change @@ -64,7 +64,10 @@ class SourceManager {
64
64
65
65
/// Convert syntax information to a `Syntax` node. The location informations
66
66
/// are cached in the source manager to provide `location(of:)` et al.
67
- func add( _ syntaxInfo: PluginMessage . Syntax ) -> Syntax {
67
+ func add(
68
+ _ syntaxInfo: PluginMessage . Syntax ,
69
+ foldingWith operatorTable: OperatorTable ? = nil
70
+ ) -> Syntax {
68
71
69
72
var node : Syntax
70
73
var parser = Parser ( syntaxInfo. source)
@@ -82,7 +85,9 @@ class SourceManager {
82
85
case . attribute:
83
86
node = Syntax ( AttributeSyntax . parse ( from: & parser) )
84
87
}
85
- node = OperatorTable . standardOperators. foldAll ( node, errorHandler: { _ in /*ignore*/ } )
88
+ if let operatorTable = operatorTable {
89
+ node = operatorTable. foldAll ( node, errorHandler: { _ in /*ignore*/ } )
90
+ }
86
91
87
92
// Copy the location info from the plugin message.
88
93
let location = KnownSourceSyntax . Location (
You can’t perform that action at this time.
0 commit comments