https://github.com/fetch-rewards/swiftsyntaxsugar
Helpful extensions for SwiftSyntax.
https://github.com/fetch-rewards/swiftsyntaxsugar
extension extensions helper helpers macro macros sugar swift swift-macro swift-macros swift-syntax swiftsyntax syntax
Last synced: 9 months ago
JSON representation
Helpful extensions for SwiftSyntax.
- Host: GitHub
- URL: https://github.com/fetch-rewards/swiftsyntaxsugar
- Owner: fetch-rewards
- License: mit
- Created: 2023-11-04T00:51:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-26T18:29:02.000Z (about 1 year ago)
- Last Synced: 2025-10-21T09:54:39.460Z (9 months ago)
- Topics: extension, extensions, helper, helpers, macro, macros, sugar, swift, swift-macro, swift-macros, swift-syntax, swiftsyntax, syntax
- Language: Swift
- Homepage:
- Size: 177 KB
- Stars: 38
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# SwiftSyntaxSugar
[](https://github.com/fetch-rewards/SwiftSyntaxSugar/actions/workflows/ci.yml?query=branch%3Amain)
[](https://codecov.io/gh/fetch-rewards/SwiftSyntaxSugar)
[](https://swiftpackageindex.com/fetch-rewards/SwiftSyntaxSugar)
[](https://swiftpackageindex.com/fetch-rewards/SwiftSyntaxSugar)
[](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/main/LICENSE)
`SwiftSyntaxSugar` is a library that provides syntactic sugar and helpful extensions for [`SwiftSyntax`](https://github.com/swiftlang/swift-syntax).
The purpose of this library is to improve the readability and maintainability of code written using `SwiftSyntax`.
- [Example](#example)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
## Example
With SwiftSyntaxSugar
Without SwiftSyntaxSugar
```swift
protocolDeclaration.isActorConstrained
```
```swift
let isProtocolActorConstrained = protocolDeclaration.inheritanceClause?.inheritedTypes.contains { inheritedType in
let identifierType = inheritedType.type.as(IdentifierTypeSyntax.self)
return identifierType.name.tokenKind == .identifier("Actor")
} ?? false
```
## Installation
To add `SwiftSyntaxSugar` to a Swift package manifest file:
- Add the `SwiftSyntaxSugar` package to your package's `dependencies`:
```swift
.package(
url: "https://github.com/fetch-rewards/SwiftSyntaxSugar.git",
from: "<#latest SwiftSyntaxSugar tag#>"
)
```
- Add the `SwiftSyntaxSugar` product to your target's `dependencies`:
```swift
.product(name: "SwiftSyntaxSugar", package: "SwiftSyntaxSugar")
```
## Usage
- Import `SwiftSyntaxSugar`:
```swift
import SwiftSyntaxSugar
```
- Use `SwiftSyntax` exactly how you normally would!
## Contributing
The simplest way to contribute to this project is by [opening an issue](https://github.com/fetch-rewards/SwiftSyntaxSugar/issues/new).
If you would like to contribute code to this project, please read our [Contributing Guidelines](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/main/CONTRIBUTING.md).
By opening an issue or contributing code to this project, you agree to follow our [Code of Conduct](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/main/CODE_OF_CONDUCT.md).
## License
This library is released under the MIT license. See [LICENSE](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/main/LICENSE) for details.