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
import SwiftSyntaxMacroExpansion
@@ -29,7 +30,7 @@ extension CompilerPluginMessageHandler {
29
30
expandingSyntax: PluginMessage . Syntax
30
31
) throws {
31
32
let sourceManager = SourceManager ( )
32
- let syntax = sourceManager. add ( expandingSyntax)
33
+ let syntax = sourceManager. add ( expandingSyntax, foldingWith : . standardOperators )
33
34
34
35
let context = PluginMacroExpansionContext (
35
36
sourceManager: sourceManager,
@@ -78,7 +79,10 @@ extension CompilerPluginMessageHandler {
78
79
expansionDiscriminator: discriminator
79
80
)
80
81
81
- let attributeNode = sourceManager. add ( attributeSyntax) . cast ( AttributeSyntax . self)
82
+ let attributeNode = sourceManager. add (
83
+ attributeSyntax,
84
+ foldingWith: . standardOperators
85
+ ) . cast ( AttributeSyntax . self)
82
86
let declarationNode = sourceManager. add ( declSyntax) . cast ( DeclSyntax . self)
83
87
let parentDeclNode = parentDeclSyntax. map { sourceManager. add ( $0) . cast ( DeclSyntax . self) }
84
88
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