Skip to content

Commit fc769da

Browse files
committed
Merge branch 'develop'
2 parents 442fa1b + 540001c commit fc769da

18 files changed

+163
-49
lines changed

.github/workflows/unit-tests.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# This workflow uses actions that are not certified by GitHub.
32
# They are provided by a third-party and are governed by
43
# separate terms of service, privacy policy, and support
@@ -23,49 +22,64 @@ on:
2322
- '*' # Push events to every tag
2423

2524
jobs:
26-
swift_tests:
27-
name: Swift Version ${{ matrix.swift }}
28-
strategy:
29-
matrix:
30-
os: [macos-13]
31-
swift: ["5.9", "5.8", "5.7"]
32-
runs-on: ${{ matrix.os }}
25+
swift_tests_latest:
26+
name: Latest Swift
27+
runs-on: macos-15
3328
steps:
34-
- uses: swift-actions/setup-swift@v1
29+
- uses: maxim-lobanov/setup-xcode@v1
3530
with:
36-
swift-version: ${{ matrix.swift }}
31+
xcode-version: "16.0"
32+
- uses: actions/checkout@v3
33+
- uses: actions/cache@v3
34+
with:
35+
path: .build
36+
key: macos-latest-spm-${{ hashFiles('**/Package.resolved') }}
37+
restore-keys: |
38+
macos-latest-spm-
39+
- name: Build
40+
run: swift build
41+
- name: Run tests
42+
run: swift test
43+
swift_tests_previous:
44+
name: Swift 5.10
45+
runs-on: macos-14
46+
steps:
3747
- uses: maxim-lobanov/setup-xcode@v1
3848
with:
39-
xcode-version: "14.3.1"
49+
xcode-version: "15.0"
4050
- uses: actions/checkout@v3
4151
- uses: actions/cache@v3
4252
with:
4353
path: .build
44-
key: ${{ matrix.os }}-spm-${{ hashFiles('**/Package.resolved') }}
54+
key: macos-14-swift-510-spm-${{ hashFiles('**/Package.resolved') }}
4555
restore-keys: |
46-
${{ matrix.os }}-spm-
56+
macos-14-swift-510-spm-
4757
- name: Build
4858
run: swift build
4959
- name: Run tests
5060
run: swift test
51-
52-
ios_tests:
53-
name: iOS Unit Tests
54-
runs-on: macos-13
61+
swift_tests_legacy:
62+
name: Swift ${{ matrix.swift }}
63+
strategy:
64+
matrix:
65+
os: [macos-13]
66+
swift: ["5.9", "5.8"]
67+
runs-on: ${{ matrix.os }}
5568
steps:
5669
- uses: swift-actions/setup-swift@v1
5770
with:
58-
swift-version: 5.9
71+
swift-version: ${{ matrix.swift }}
72+
- uses: maxim-lobanov/setup-xcode@v1
73+
with:
74+
xcode-version: "14.3.1"
5975
- uses: actions/checkout@v3
6076
- uses: actions/cache@v3
6177
with:
6278
path: .build
63-
key: ${{ matrix.os }}-spm-${{ hashFiles('**/Package.resolved') }}
79+
key: ${{ matrix.os }}-${{ matrix.swift }}-spm-${{ hashFiles('**/Package.resolved') }}
6480
restore-keys: |
6581
${{ matrix.os }}-spm-
66-
6782
- name: Build
68-
run: xcodebuild build -scheme SyntaxSparrow -destination "OS=17.2,name=iPhone 13"
69-
70-
- name: Test
71-
run: xcodebuild test-without-building -scheme SyntaxSparrow -destination "name=iPhone 13" -enableCodeCoverage YES
83+
run: swift build
84+
- name: Run tests
85+
run: swift test

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version: 6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -20,7 +20,7 @@ let package = Package(
2020
),
2121
],
2222
dependencies: [
23-
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "510.0.1"),
23+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
2424
],
2525
targets: [
2626
.target(
@@ -31,6 +31,9 @@ let package = Package(
3131
],
3232
resources: [
3333
.copy("Resources/PrivacyInfo.xcprivacy")
34+
],
35+
swiftSettings: [
36+
.swiftLanguageMode(.v6)
3437
]
3538
),
3639
.testTarget(

Package@swift-5.10.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version: 5.10
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SyntaxSparrow",
8+
platforms: [
9+
.macOS(.v10_15),
10+
.iOS(.v13),
11+
.tvOS(.v13),
12+
.watchOS(.v6),
13+
.macCatalyst(.v13)
14+
],
15+
products: [
16+
// Products define the executables and libraries a package produces, and make them visible to other packages.
17+
.library(
18+
name: "SyntaxSparrow",
19+
targets: ["SyntaxSparrow"]
20+
),
21+
],
22+
dependencies: [
23+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
24+
],
25+
targets: [
26+
.target(
27+
name: "SyntaxSparrow",
28+
dependencies: [
29+
.product(name: "SwiftSyntax", package: "swift-syntax"),
30+
.product(name: "SwiftParser", package: "swift-syntax"),
31+
],
32+
resources: [
33+
.copy("Resources/PrivacyInfo.xcprivacy")
34+
]
35+
),
36+
.testTarget(
37+
name: "SyntaxSparrowTests",
38+
dependencies: [
39+
"SyntaxSparrow",
40+
]
41+
),
42+
]
43+
)
44+
45+
// Supplementary
46+
package.dependencies.append(contentsOf: [
47+
.package(url: "https://github.com/SwiftPackageIndex/SPIManifest.git", from: "0.12.0"),
48+
])

Package@swift-5.8.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let package = Package(
2020
),
2121
],
2222
dependencies: [
23-
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "510.0.1"),
23+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
2424
],
2525
targets: [
2626
.target(

Package@swift-5.7.swift renamed to Package@swift-5.9.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.7
1+
// swift-tools-version: 5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -20,7 +20,7 @@ let package = Package(
2020
),
2121
],
2222
dependencies: [
23-
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "510.0.1"),
23+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
2424
],
2525
targets: [
2626
.target(

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ SyntaxSparrow is a Swift library designed to facilitate the analysis and interac
2626
- [License](#license)
2727
- [Contributing](#contributing)
2828

29+
## Swift 6 Support
30+
SyntaxSparrow added explicit support for Swift 6 (and the Swift 6 language mode) as of version `5.0.0`. It is still compatible back to Swift 5.8, however, the package manifests for version 5.8, 5.9, and 5.10 do not include the explicit swift 6 language mode setting.
31+
32+
## Note on Swift 5.7 Support
33+
34+
The latest version of the underlying [swift-syntax](https://github.com/swiftlang/swift-syntax) library no longer supports swift 5.7, as such, Syntax Sparrow will stop active support for Swift 5.7 from version 5.0.0
35+
36+
If you need support for 5.7, and specifically want features added after the 5.0.0 bump, you may need to fork the repo and add support yourself. If there is a backwards compatible change that can be captured as a minor update we will gladly release it via the PR process. However, if there are changes resulting in a major bump with 5.7 support, we would like to look at an alternate release process for that version (or let you maintain it on your own fork).
37+
2938
## About the Project
3039
SyntaxSparrow was built on heavy inspiration from the now archived [SwiftSemantics](https://github.com/SwiftDocOrg/SwiftSemantics) project. `SwiftSemantics` was awesome, but being archived the only option is to fork and add features yourself, or hope someone has added your feature to their fork. `SyntaxSparrow` aims to pick up where this left off and add more support for conveniences, features, and harden parsing where needed.
3140

@@ -336,7 +345,7 @@ Currently, SyntaxSparrow supports Swift Package Manager (SPM).
336345
To add SyntaxSparrow to your project, add the following line to your dependencies in your Package.swift file:
337346

338347
```swift
339-
.package(url: "https://github.com/CheekyGhost-Labs/SyntaxSparrow", from: "4.3.0")
348+
.package(url: "https://github.com/CheekyGhost-Labs/SyntaxSparrow", from: "5.0.0")
340349
```
341350

342351
Then, add SyntaxSparrow as a dependency for your target:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// SyntaxChildren+InOut.swift
3+
//
4+
//
5+
// Created by Michael O'Brien on 20/10/2024.
6+
//
7+
8+
import SwiftSyntax
9+
10+
extension SyntaxChildren {
11+
12+
/// Will assess the children in the current collection and search for inout token kinds with a shallow strategy.
13+
/// Shallow referring to the child being a direct `TokenSyntax` type or a `TypeSpecifierListSyntax` containing a
14+
/// child that is a `SimpleTypeSpecifierSyntax` whose token kind is an `inout`
15+
/// - Returns: `Bool`
16+
func resolveIsInOut() -> Bool {
17+
contains(where: {
18+
// Ignoring experimental `LifetimeTypeSpecifierSyntax` type for now.
19+
if let specifierListType = $0.as(TypeSpecifierListSyntax.self) {
20+
let nodes = specifierListType.compactMap { $0.as(SimpleTypeSpecifierSyntax.self) }
21+
let tokens = nodes.flatMap { $0.tokens(viewMode: .fixedUp) }
22+
return tokens.contains(where: { $0.tokenKind == TokenKind.keyword(.inout) })
23+
}
24+
// returning expected syntax type (if valid)
25+
return $0.as(TokenSyntax.self)?.tokenKind == TokenKind.keyword(.inout)
26+
})
27+
}
28+
}
29+

Sources/SyntaxSparrow/Internal/Resolvers/Declaration/FunctionSemanticsResolver.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct FunctionSemanticsResolver: SemanticsResolving {
3939
node.funcKeyword.text.trimmed
4040
}
4141

42+
func resolveKeywordIsPresent() -> Bool {
43+
node.funcKeyword.presence == .present
44+
}
45+
4246
func resolveModifiers() -> [Modifier] {
4347
node.modifiers.map { Modifier(node: $0) }
4448
}

Sources/SyntaxSparrow/Internal/Resolvers/Declaration/InitializerSemanticsResolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct InitializerSemanticsResolver: SemanticsResolving {
5656
}
5757

5858
func resolveThrowsOrRethrowsKeyword() -> String? {
59-
node.signature.effectSpecifiers?.throwsSpecifier?.text.trimmed
59+
node.signature.effectSpecifiers?.throwsClause?.throwsSpecifier.text.trimmed
6060
}
6161

6262
func resolveEffectSpecifiers() -> EffectSpecifiers? {

0 commit comments

Comments
 (0)