File tree 2 files changed +6
-12
lines changed
Sources/SwiftCompilerPlugin
Tests/SwiftCompilerPluginTest 2 files changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ public protocol CompilerPlugin {
63
63
}
64
64
65
65
extension 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 {
67
68
let qualifedName = " \( moduleName) . \( typeName) "
68
69
69
70
for type in providingMacros {
@@ -78,11 +79,6 @@ extension CompilerPlugin {
78
79
let pluginPath = CommandLine . arguments. first ?? Bundle . main. executablePath ?? ProcessInfo . processInfo. processName
79
80
throw CompilerPluginError ( message: " macro implementation type ' \( moduleName) . \( typeName) ' could not be found in executable plugin ' \( pluginPath) ' " )
80
81
}
81
-
82
- // @testable
83
- public func _resolveMacro( moduleName: String , typeName: String ) -> Macro . Type ? {
84
- try ? resolveMacro ( moduleName: moduleName, typeName: typeName)
85
- }
86
82
}
87
83
88
84
struct MacroProviderAdapter < Plugin: CompilerPlugin > : PluginProvider {
Original file line number Diff line number Diff line change 10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
- import SwiftCompilerPlugin
13
+ @ _spi ( Testing ) import SwiftCompilerPlugin
14
14
import SwiftSyntax
15
15
import SwiftSyntaxMacros
16
16
import XCTest
@@ -51,20 +51,18 @@ public class CompilerPluginTests: XCTestCase {
51
51
func testResolveMacro( ) {
52
52
let plugin = MyPlugin ( )
53
53
54
- let registeredMacro = plugin. _resolveMacro (
54
+ let registeredMacro = try ? plugin. resolveMacro (
55
55
moduleName: " SwiftCompilerPluginTest " ,
56
56
typeName: " RegisteredMacro "
57
57
)
58
58
XCTAssertNotNil ( registeredMacro)
59
59
XCTAssertTrue ( registeredMacro == RegisteredMacro . self)
60
60
61
61
/// Test the plugin doesn't provide unregistered macros.
62
- let dummyMacro = plugin. _resolveMacro (
62
+ XCTAssertThrowsError ( try plugin. resolveMacro (
63
63
moduleName: " SwiftCompilerPluginTest " ,
64
64
typeName: " DummyMacro "
65
- )
66
- XCTAssertNil ( dummyMacro)
67
- XCTAssertFalse ( dummyMacro == DummyMacro . self)
65
+ ) )
68
66
69
67
}
70
68
}
You can’t perform that action at this time.
0 commit comments