Skip to content

Commit

Permalink
Adding Function Signature Node, Subscript hasSetter, bumping swift-sy…
Browse files Browse the repository at this point in the history
…ntax version (#34)

* Exposing Function Signature Node, Subscript hasSetter, Bumping swift-syntax version
* Adding convenience method for parameter collections
* Assigning manual Xcode version in GitHub actions workflow
  • Loading branch information
mobrien-ghost authored Mar 10, 2024
1 parent 692a719 commit f4507db
Show file tree
Hide file tree
Showing 21 changed files with 238 additions and 247 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.3.1"
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
system
32 changes: 0 additions & 32 deletions .swiftpm/SyntaxSparrow.xctestplan

This file was deleted.

This file was deleted.

This file was deleted.

97 changes: 0 additions & 97 deletions .swiftpm/xcode/xcshareddata/xcschemes/SyntaxSparrow.xcscheme

This file was deleted.

4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
"revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd",
"version" : "510.0.1"
}
},
{
Expand Down
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ let package = Package(
name: "SyntaxSparrow",
platforms: [
.macOS(.v10_15),
.iOS(.v13)
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -17,7 +20,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.1"),
],
targets: [
.target(
Expand Down
7 changes: 5 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ let package = Package(
name: "SyntaxSparrow",
platforms: [
.macOS(.v10_15),
.iOS(.v13)
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -17,7 +20,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.1"),
],
targets: [
.target(
Expand Down
7 changes: 5 additions & 2 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ let package = Package(
name: "SyntaxSparrow",
platforms: [
.macOS(.v10_15),
.iOS(.v13)
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand All @@ -17,7 +20,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"),
.package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.1"),
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class RootDeclarationCollector: SyntaxVisitor {
/// `DeclarationCollection` instance to collect results into.
private(set) var declarationCollection: DeclarationCollection = .init()

/// Transient entry node used when walking over a node. The entry node will be ignored and it's children visited.
private(set) var tree: SourceFileSyntax = SourceFileSyntax(statements: .init([]))

/// Transient entry node used when walking over a node. The entry node will be ignored and it's children visited.
private(set) var entryNode: SyntaxProtocol?

Expand All @@ -30,7 +33,7 @@ class RootDeclarationCollector: SyntaxVisitor {
/// - Parameter source: The source code being analyzed by this instance.
@discardableResult func collect(fromSource source: String) -> DeclarationCollection {
declarationCollection.reset()
let tree = Parser.parse(source: source)
tree = Parser.parse(source: source)
walk(tree)
return declarationCollection
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct FunctionSemanticsResolver: SemanticsResolving {
effectSpecifiers = EffectSpecifiers(node: specifiers)
}
return Function.Signature(
node: node.signature,
input: inputParameters,
output: outputType,
outputIsOptional: isOutputOptional,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ struct SubscriptSemanticsResolver: SemanticsResolving {
node.returnClause.type.resolveIsTypeOptional()
}

func resolveHasSetter() -> Bool {
return resolveAccessors().contains(where: { $0.kind == .set })
}

func resolveAccessors() -> [Accessor] {
guard let accessor = node.accessorBlock?.as(AccessorBlockSyntax.self) else { return [] }
guard let accessor = node.accessorBlock else { return [] }
switch accessor.accessors {
case .accessors(let accessorList):
return accessorList.map(Accessor.init)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct VariableSemanticsResolver: SemanticsResolving {
// MARK: - Resolvers

func resolveAccessors() -> [Accessor] {
guard let accessor = node.accessorBlock?.as(AccessorBlockSyntax.self) else { return [] }
guard let accessor = node.accessorBlock else { return [] }
switch accessor.accessors {
case .accessors(let accessorList):
return accessorList.map(Accessor.init)
Expand Down
Loading

0 comments on commit f4507db

Please sign in to comment.