|
| 1 | +# SwiftSyntaxSugar |
| 2 | + |
| 3 | +[](https://github.com/fetch-rewards/SwiftSyntaxSugar/actions/workflows/ci.yml?query=branch%3Amain) |
| 4 | +[](https://codecov.io/gh/fetch-rewards/SwiftSyntaxSugar) |
| 5 | +[](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/feature/readme/LICENSE) |
| 6 | + |
| 7 | +`SwiftSyntaxSugar` is a library that provides syntactic sugar and helpful extensions for [`SwiftSyntax`](https://github.com/swiftlang/swift-syntax). |
| 8 | +The purpose of this library is to improve the readability and maintainability of code written using `SwiftSyntax`. |
| 9 | + |
| 10 | +- [Example](#example) |
| 11 | +- [Installation](#installation) |
| 12 | +- [Usage](#usage) |
| 13 | +- [Contributing](#contributing) |
| 14 | +- [License](#license) |
| 15 | + |
| 16 | +## Example |
| 17 | + |
| 18 | +<table> |
| 19 | +<tr> |
| 20 | +<td> With <code>SwiftSyntaxSugar</code> </td> |
| 21 | +<td> Without <code>SwiftSyntaxSugar</code> </td> |
| 22 | +</tr> |
| 23 | +<tr> |
| 24 | +<td> |
| 25 | + |
| 26 | +```swift |
| 27 | +protocolDeclaration.isActorConstrained |
| 28 | +``` |
| 29 | + |
| 30 | +</td> |
| 31 | +<td> |
| 32 | + |
| 33 | +```swift |
| 34 | +let isProtocolActorConstrained = protocolDeclaration.inheritanceClause?.inheritedTypes.contains { inheritedType in |
| 35 | + let identifierType = inheritedType.type.as(IdentifierTypeSyntax.self) |
| 36 | + return identifierType.name.tokenKind == .identifier("Actor") |
| 37 | +} ?? false |
| 38 | +``` |
| 39 | + |
| 40 | +</td> |
| 41 | +</tr> |
| 42 | +</table> |
| 43 | + |
| 44 | +## Installation |
| 45 | + |
| 46 | +To add `SwiftSyntaxSugar` to a Swift package manifest file: |
| 47 | +- Add the `SwiftSyntaxSugar` package to your package's `dependencies`: |
| 48 | + ```swift |
| 49 | + .package( |
| 50 | + url: "https://github.com/fetch-rewards/SwiftSyntaxSugar.git", |
| 51 | + from: "<#latest SwiftSyntaxSugar tag#>" |
| 52 | + ) |
| 53 | + ``` |
| 54 | +- Add the `SwiftSyntaxSugar` product to your target's `dependencies`: |
| 55 | + ```swift |
| 56 | + .product(name: "SwiftSyntaxSugar", package: "SwiftSyntaxSugar") |
| 57 | + ``` |
| 58 | + |
| 59 | +## Usage |
| 60 | + |
| 61 | +- Import `SwiftSyntaxSugar`: |
| 62 | + ```swift |
| 63 | + import SwiftSyntaxSugar |
| 64 | + ``` |
| 65 | +- Use `SwiftSyntax` exactly how you normally would! |
| 66 | + |
| 67 | +## Contributing |
| 68 | + |
| 69 | +The simplest way to contribute to this project is by [opening an issue](https://github.com/fetch-rewards/SwiftSyntaxSugar/issues/new). |
| 70 | + |
| 71 | +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). |
| 72 | + |
| 73 | +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). |
| 74 | + |
| 75 | +## License |
| 76 | + |
| 77 | +This library is released under the MIT license. See [LICENSE](https://github.com/fetch-rewards/SwiftSyntaxSugar/blob/main/LICENSE) for details. |
0 commit comments