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 1212
1313import SwiftBasicFormat
1414import SwiftDiagnostics
15+ import SwiftOperators
1516import SwiftSyntax
1617import SwiftSyntaxMacros
1718
@@ -28,7 +29,7 @@ extension CompilerPluginMessageHandler {
2829 expandingSyntax: PluginMessage . Syntax
2930 ) throws {
3031 let sourceManager = SourceManager ( )
31- let syntax = sourceManager. add ( expandingSyntax)
32+ let syntax = sourceManager. add ( expandingSyntax, foldingWith : . standardOperators )
3233
3334 let context = PluginMacroExpansionContext (
3435 sourceManager: sourceManager,
@@ -97,7 +98,10 @@ extension CompilerPluginMessageHandler {
9798 expansionDiscriminator: discriminator
9899 )
99100
100- let attributeNode = sourceManager. add ( attributeSyntax) . cast ( AttributeSyntax . self)
101+ let attributeNode = sourceManager. add (
102+ attributeSyntax,
103+ foldingWith: . standardOperators
104+ ) . cast ( AttributeSyntax . self)
101105 let declarationNode = sourceManager. add ( declSyntax) . cast ( DeclSyntax . self)
102106
103107 let expandedSources : [ String ]
Original file line number Diff line number Diff line change @@ -64,7 +64,10 @@ class SourceManager {
6464
6565 /// Convert syntax information to a `Syntax` node. The location informations
6666 /// 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 {
6871
6972 var node : Syntax
7073 var parser = Parser ( syntaxInfo. source)
@@ -82,7 +85,9 @@ class SourceManager {
8285 case . attribute:
8386 node = Syntax ( AttributeSyntax . parse ( from: & parser) )
8487 }
85- node = OperatorTable . standardOperators. foldAll ( node, errorHandler: { _ in /*ignore*/ } )
88+ if let operatorTable = operatorTable {
89+ node = operatorTable. foldAll ( node, errorHandler: { _ in /*ignore*/ } )
90+ }
8691
8792 // Copy the location info from the plugin message.
8893 let location = KnownSourceSyntax . Location (
You can’t perform that action at this time.
0 commit comments