Skip to content

Commit c0cee1c

Browse files
committed
Updating README
1 parent fd2f725 commit c0cee1c

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,49 @@ syntaxTree.functions[0].typealiases[0].name // SampleAlias
189189
syntaxTree.functions[0].typealiases[0].initializedType.type // .simple("String")
190190
```
191191

192+
### Modifier Conveniences
193+
194+
Where applicable, types will conform to the `ModifierAssessing` protocol, which lets you assess what modifiers are present based on a `SwiftSyntax.Keyword` type. This is also available on any `Collection` where the element type is `Modifier`
195+
196+
```swift
197+
// Assess if the instnace has `private(set)` and is `public`
198+
conformingInstance.containsModifierWithKeyword(.private, withDetail: "set")
199+
conformingInstance.containsModifierWithKeyword(.public)
200+
// or on a collection of modifiers
201+
variable.modifiers.containsKeyword(.private, withDetail: "set")
202+
```
203+
204+
some common scenarios are available as direct getters:
205+
206+
```swift
207+
conformingInstance.isPrivate
208+
conformingInstance.isPublic
209+
conformingInstance.isOpen
210+
// etc
211+
variable.isPrivateSetter
212+
variable.isFilePrivateSetter
213+
initializer.isConvenience
214+
initializer.isRequired
215+
// etc
216+
```
217+
218+
Conforming types are:
219+
220+
- `Actor`
221+
- `Class`
222+
- `Enumeration`
223+
- `Extension`
224+
- `Function`
225+
- `ProtocolDecl`
226+
- `Structure`
227+
- `Subscript`
228+
- `Typealias`
229+
- `Variable`
230+
- `Initializer`
231+
- Any collection where the type is `Modifier`
232+
192233
### Source Locations and Bounds:
234+
193235
`Declaration` types can can also be sent to the `SyntaxTree` to extract source location and content:
194236

195237
```swift
@@ -294,7 +336,7 @@ Currently, SyntaxSparrow supports Swift Package Manager (SPM).
294336
To add SyntaxSparrow to your project, add the following line to your dependencies in your Package.swift file:
295337

296338
```swift
297-
.package(url: "https://github.com/CheekyGhost-Labs/SyntaxSparrow", from: "4.0.0")
339+
.package(url: "https://github.com/CheekyGhost-Labs/SyntaxSparrow", from: "4.1.0")
298340
```
299341

300342
Then, add SyntaxSparrow as a dependency for your target:

0 commit comments

Comments
 (0)