File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed
CapacitorPluginSyntaxTools Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,19 @@ class AddPluginToClass: SyntaxRewriter {
1111 }
1212
1313 override func visit( _ node: ClassDeclSyntax ) -> DeclSyntax {
14- var newNode = capacitorPluginSyntax. addBridgedPluginConformance ( node)
15- newNode. memberBlock. members. insert ( contentsOf: capacitorPluginSyntax. createMemberBlock ( ) ,
16- at: node. memberBlock. members. startIndex)
17- return DeclSyntax ( newNode)
14+ guard let inheritedTypes = node. inheritanceClause? . inheritedTypes else {
15+ return DeclSyntax ( node)
16+ }
17+
18+ if let inheritedType = inheritedTypes. first ( where: { $0. isNamed ( " CAPPlugin " ) } ) {
19+ var newNode = capacitorPluginSyntax. addBridgedPluginConformance ( node)
20+ newNode. memberBlock. members. insert ( contentsOf: capacitorPluginSyntax. createMemberBlock ( ) ,
21+ at: node. memberBlock. members. startIndex)
22+ return DeclSyntax ( newNode)
23+ } else {
24+ return DeclSyntax ( node)
25+ }
1826 }
27+
1928}
29+
Original file line number Diff line number Diff line change 1+ import Foundation
2+ import SwiftSyntax
3+ import SwiftParser
4+
5+ extension InheritedTypeSyntax {
6+ func isNamed( _ searchName: String ) -> Bool {
7+ if let foundName = self . type. as ( IdentifierTypeSyntax . self) ? . name. text {
8+ return foundName == searchName
9+ } else {
10+ return false
11+ }
12+ }
13+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ public enum CapacitorPluginError: Error {
2222 }
2323}
2424
25+ struct StandardError : TextOutputStream , Sendable {
26+ private static let handle = FileHandle . standardError
27+
28+ public func write( _ string: String ) {
29+ Self . handle. write ( Data ( string. utf8) )
30+ }
31+ }
32+
2533public class CapacitorPluginPackage {
2634 public let pluginDirectoryName : String
2735 public let basePathURL : URL
You can’t perform that action at this time.
0 commit comments