diff --git a/CHANGELOG.md b/CHANGELOG.md index 2556164..f813b37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Master +## 0.3.2 + +#### Fixed +- Fixed the parsing of files with anonymous functions within the public functions #15 + +[Commits](https://github.com/yonaskolb/Beak/compare/0.3.1...0.3.2) + ## 0.3.1 #### Added diff --git a/Sources/BeakCore/Beak.swift b/Sources/BeakCore/Beak.swift index 242eb1a..1d66ee3 100644 --- a/Sources/BeakCore/Beak.swift +++ b/Sources/BeakCore/Beak.swift @@ -18,7 +18,7 @@ public struct BeakOptions { public class Beak { - public let version: String = "0.3.1" + public let version: String = "0.3.2" public let options: BeakOptions public init(options: BeakOptions) { diff --git a/Sources/BeakCore/SwiftParser.swift b/Sources/BeakCore/SwiftParser.swift index 3208985..b914c24 100644 --- a/Sources/BeakCore/SwiftParser.swift +++ b/Sources/BeakCore/SwiftParser.swift @@ -61,7 +61,7 @@ public struct SwiftParser { let publicNames = functionSignature.split(separator: "(").last!.split(separator: ":") var index = 0 let bodyOffset = structure.int(.bodyOffset) - let params: [Function.Param] = try structure.substructure.filter { $0.kind == .varParameter && ($0.int(.offset) ?? 0) < (bodyOffset ?? 1) }.map { paramStructure in + let params: [Function.Param] = try structure.substructure.filter { $0.kind == .varParameter && ($0.int(.offset) ?? 0) < (bodyOffset ?? 1) }.map { paramStructure in let paramName = paramStructure.string(.name) ?? "" var name = String(publicNames[index]) var unnamed = false diff --git a/Tests/BeakTests/BeakTests.swift b/Tests/BeakTests/BeakTests.swift index a953ea1..6578513 100644 --- a/Tests/BeakTests/BeakTests.swift +++ b/Tests/BeakTests/BeakTests.swift @@ -67,7 +67,7 @@ class BeakTests: XCTestCase { } """, parsedTo: Function(name: "topFunction", params: [ .init(name: "path", type: .string, optional: false), - ])) + ])) try expectFunction("public func unnamed(_ noName: String) {}", parsedTo: Function(name: "unnamed", params: [ .init(name: "noName", type: .string, optional: false, unnamed: true),