swift-macro-toolkit
swift-macro-toolkit copied to clipboard
Add Wrappers for Class, Actor, Extension
This PR introduces wrappers for the remaining declaration groups: Class, Actor, Extension, and Protocol. This enhancement allows the toolkit to handle a broader range of Swift declarations, improving its utility and versatility.
Key Changes:
- Added wrappers for
Class,Actor,Extension, andProtocoldeclarations. - Introduced the
DeclGroupProtocolto enable macros to generically operate over the members of a declaration group.
New Wrappers
The new wrappers are implemented in a manner consistent with existing Enum and Struct wrappers. Each new wrapper is defined in its respective file and conforms to the DeclGroupProtocol.
DeclGroupProtocol
The DeclGroupProtocol enables macros to generically operate over the members of a declaration group without needing to know the specific type of the declaration group. This protocol standardizes access to common properties like members, properties, inheritedTypes, accessLevel, and declarationContext.
Tests
Comprehensive tests have been added to cover the new wrappers and the DeclGroupProtocol. The tests validate the initialization and properties of each declaration group wrapper, ensuring correct functionality.
Benefits:
- Expands the toolkit's capabilities to handle more types of declaration groups.
- Improves code maintainability and readability by using a unified protocol for declaration groups.
- Facilitates the development of more generic macros that can operate over any declaration group.
Closes:
Resolves #9