File tree Expand file tree Collapse file tree 2 files changed +9
-13
lines changed
Sources/SwiftCompilerPlugin
Tests/SwiftCompilerPluginTest Expand file tree Collapse file tree 2 files changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ public protocol CompilerPlugin {
6363}
6464
6565extension CompilerPlugin {
66- func resolveMacro( moduleName: String , typeName: String ) throws -> Macro . Type {
66+ @_spi ( Testing)
67+ public func resolveMacro( moduleName: String , typeName: String ) throws -> Macro . Type {
6768 let qualifedName = " \( moduleName) . \( typeName) "
6869
6970 for type in providingMacros {
@@ -78,11 +79,6 @@ extension CompilerPlugin {
7879 let pluginPath = CommandLine . arguments. first ?? Bundle . main. executablePath ?? ProcessInfo . processInfo. processName
7980 throw CompilerPluginError ( message: " macro implementation type ' \( moduleName) . \( typeName) ' could not be found in executable plugin ' \( pluginPath) ' " )
8081 }
81-
82- // @testable
83- public func _resolveMacro( moduleName: String , typeName: String ) -> Macro . Type ? {
84- try ? resolveMacro ( moduleName: moduleName, typeName: typeName)
85- }
8682}
8783
8884struct MacroProviderAdapter < Plugin: CompilerPlugin > : PluginProvider {
Original file line number Diff line number Diff line change 1010//
1111//===----------------------------------------------------------------------===//
1212
13- import SwiftCompilerPlugin
13+ @ _spi ( Testing ) import SwiftCompilerPlugin
1414import SwiftSyntax
1515import SwiftSyntaxMacros
1616import XCTest
@@ -51,20 +51,20 @@ public class CompilerPluginTests: XCTestCase {
5151 func testResolveMacro( ) {
5252 let plugin = MyPlugin ( )
5353
54- let registeredMacro = plugin. _resolveMacro (
54+ let registeredMacro = try ? plugin. resolveMacro (
5555 moduleName: " SwiftCompilerPluginTest " ,
5656 typeName: " RegisteredMacro "
5757 )
5858 XCTAssertNotNil ( registeredMacro)
5959 XCTAssertTrue ( registeredMacro == RegisteredMacro . self)
6060
6161 /// Test the plugin doesn't provide unregistered macros.
62- let dummyMacro = plugin. _resolveMacro (
63- moduleName: " SwiftCompilerPluginTest " ,
64- typeName: " DummyMacro "
62+ XCTAssertThrowsError (
63+ try plugin. resolveMacro (
64+ moduleName: " SwiftCompilerPluginTest " ,
65+ typeName: " DummyMacro "
66+ )
6567 )
66- XCTAssertNil ( dummyMacro)
67- XCTAssertFalse ( dummyMacro == DummyMacro . self)
6868
6969 }
7070}
You can’t perform that action at this time.
0 commit comments