diff --git a/Gemfile.lock b/Gemfile.lock index f781b9eed..4ce856464 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,6 +140,8 @@ GEM racc (~> 1.4) nokogiri (1.15.4-arm64-darwin) racc (~> 1.4) + nokogiri (1.15.4-x86_64-darwin) + racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) octokit (4.22.0) @@ -191,6 +193,7 @@ PLATFORMS aarch64-linux arm64-darwin-21 arm64-darwin-23 + x86_64-darwin-21 x86_64-linux DEPENDENCIES diff --git a/Package.resolved b/Package.resolved index 1086cdbcd..ab0a02a6e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/art-divin/Stencil.git", "state" : { - "revision" : "ea58733eb66b063f37288d009959d47c09f520c7", - "version" : "0.15.2" + "revision" : "03a1dca8923bef5a34c08f5a560fb420326f7244", + "version" : "0.15.3" } }, { @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/art-divin/StencilSwiftKit.git", "state" : { - "revision" : "60bd09805246f788154aefd74dfbbba512408c84", - "version" : "2.10.3" + "revision" : "6b07f85def6984e7015d65502d41b91f3f8db6d5", + "version" : "2.10.4" } }, { diff --git a/Package.swift b/Package.swift index 62cb45052..ee6218750 100644 --- a/Package.swift +++ b/Package.swift @@ -4,19 +4,19 @@ import PackageDescription import Foundation var sourceryLibDependencies: [Target.Dependency] = [ - "SourceryFramework", - "SourceryRuntime", - "SourceryStencil", - "SourceryJS", - "SourcerySwift", - "Commander", - "PathKit", - "Yams", - "StencilSwiftKit", - .product(name: "SwiftSyntax", package: "swift-syntax"), - "XcodeProj", - .product(name: "SwiftPM-auto", package: "swift-package-manager"), - ] + "SourceryFramework", + "SourceryRuntime", + "SourceryStencil", + "SourceryJS", + "SourcerySwift", + "Commander", + "PathKit", + "Yams", + "StencilSwiftKit", + .product(name: "SwiftSyntax", package: "swift-syntax"), + "XcodeProj", + .product(name: "SwiftPM-auto", package: "swift-package-manager"), +] // Note: when Swift Linux doesn't bug out on [String: String], add a test back for it // See https://github.com/krzysztofzablocki/Sourcery/pull/1208#issuecomment-1752185381 @@ -65,171 +65,171 @@ let sourceryLibTestsResources: [Resource] = [ #endif var targets: [Target] = [ - .executableTarget( - name: "SourceryExecutable", - dependencies: ["SourceryLib"], - path: "SourceryExecutable", - exclude: [ - "Info.plist" - ] - ), - .target( - // Xcode doesn't like when a target has the same name as a product but in different case. - name: "SourceryLib", - dependencies: sourceryLibDependencies, - path: "Sourcery", - exclude: [ - "Templates", - ] - ), - .target( - name: "SourceryRuntime", - dependencies: [ - "StencilSwiftKit" - ], - path: "SourceryRuntime", - exclude: [ - "Supporting Files/Info.plist" - ] - ), - .target( - name: "SourceryFramework", - dependencies: [ - "PathKit", - .product(name: "SwiftSyntax", package: "swift-syntax"), - .product(name: "SwiftParser", package: "swift-syntax"), - "SourceryUtils", - "SourceryRuntime" - ], - path: "SourceryFramework", - exclude: [ - "Info.plist" - ] - ), - .target( - name: "SourceryStencil", - dependencies: [ - "PathKit", - "SourceryRuntime", - "StencilSwiftKit", - ], - path: "SourceryStencil", - exclude: [ - "Info.plist" - ] - ), - .target( - name: "SourceryJS", - dependencies: [ - "PathKit" - ], - path: "SourceryJS", - exclude: [ - "Info.plist" - ], - resources: [ - .copy("Resources/ejs.js") - ] - ), - .target( - name: "SourcerySwift", - dependencies: [ - "PathKit", - "SourceryRuntime", - "SourceryUtils" - ], - path: "SourcerySwift", - exclude: [ - "Info.plist" - ] - ), - .target( - name: "CodableContext", - path: "Templates/Tests", - exclude: [ - "Context/AutoCases.swift", - "Context/AutoEquatable.swift", - "Context/AutoHashable.swift", - "Context/AutoLenses.swift", - "Context/AutoMockable.swift", - "Context/LinuxMain.swift", - "Generated/AutoCases.generated.swift", - "Generated/AutoEquatable.generated.swift", - "Generated/AutoHashable.generated.swift", - "Generated/AutoLenses.generated.swift", - "Generated/AutoMockable.generated.swift", - "Generated/LinuxMain.generated.swift", - "Expected", - "Info.plist", - "TemplatesTests.swift" - ], - sources: [ - "Context/AutoCodable.swift", - "Generated/AutoCodable.generated.swift" + .executableTarget( + name: "SourceryExecutable", + dependencies: ["SourceryLib"], + path: "SourceryExecutable", + exclude: [ + "Info.plist" + ] + ), + .target( + // Xcode doesn't like when a target has the same name as a product but in different case. + name: "SourceryLib", + dependencies: sourceryLibDependencies, + path: "Sourcery", + exclude: [ + "Templates", + ] + ), + .target( + name: "SourceryRuntime", + dependencies: [ + "StencilSwiftKit" + ], + path: "SourceryRuntime", + exclude: [ + "Supporting Files/Info.plist" + ] + ), + .target( + name: "SourceryFramework", + dependencies: [ + "PathKit", + .product(name: "SwiftSyntax", package: "swift-syntax"), + .product(name: "SwiftParser", package: "swift-syntax"), + "SourceryUtils", + "SourceryRuntime" + ], + path: "SourceryFramework", + exclude: [ + "Info.plist" + ] + ), + .target( + name: "SourceryStencil", + dependencies: [ + "PathKit", + "SourceryRuntime", + "StencilSwiftKit", + ], + path: "SourceryStencil", + exclude: [ + "Info.plist" + ] + ), + .target( + name: "SourceryJS", + dependencies: [ + "PathKit" + ], + path: "SourceryJS", + exclude: [ + "Info.plist" + ], + resources: [ + .copy("Resources/ejs.js") + ] + ), + .target( + name: "SourcerySwift", + dependencies: [ + "PathKit", + "SourceryRuntime", + "SourceryUtils" + ], + path: "SourcerySwift", + exclude: [ + "Info.plist" + ] + ), + .target( + name: "CodableContext", + path: "Templates/Tests", + exclude: [ + "Context/AutoCases.swift", + "Context/AutoEquatable.swift", + "Context/AutoHashable.swift", + "Context/AutoLenses.swift", + "Context/AutoMockable.swift", + "Context/LinuxMain.swift", + "Generated/AutoCases.generated.swift", + "Generated/AutoEquatable.generated.swift", + "Generated/AutoHashable.generated.swift", + "Generated/AutoLenses.generated.swift", + "Generated/AutoMockable.generated.swift", + "Generated/LinuxMain.generated.swift", + "Expected", + "Info.plist", + "TemplatesTests.swift" + ], + sources: [ + "Context/AutoCodable.swift", + "Generated/AutoCodable.generated.swift" + ] + ), + .testTarget( + name: "SourceryLibTests", + dependencies: [ + "SourceryLib", + "Quick", + "Nimble" + ], + exclude: [ + "Info.plist" + ], + resources: sourceryLibTestsResources, + swiftSettings: [.unsafeFlags(["-enable-testing"])] + ), + .testTarget( + name: "CodableContextTests", + dependencies: [ + "CodableContext", + "Quick", + "Nimble" + ], + path: "Templates/CodableContextTests", + exclude: [ + "Info.plist" + ], + swiftSettings: [.unsafeFlags(["-enable-testing"])] + ), + .testTarget( + name: "TemplatesTests", + dependencies: [ + "Quick", + "Nimble", + "PathKit" + ], + path: "Templates", + exclude: [ + "CodableContext", + "CodableContextTests", + "Tests/Generated", + "Tests/Info.plist" + ], + sources: [ + // LinuxMain is not compiled as part of the target + // since there is no way to run script before compilation begins. + "Tests/TemplatesTests.swift" + ], + resources: templatesTestsResourcesCopy, + swiftSettings: [.unsafeFlags(["-enable-testing"])] + ), + .plugin( + name: "SourceryCommandPlugin", + capability: .command( + intent: .custom( + verb: "sourcery-command", + description: "Sourcery command plugin for code generation" + ), + permissions: [ + .writeToPackageDirectory(reason: "Need permission to write generated files to package directory") ] ), - .testTarget( - name: "SourceryLibTests", - dependencies: [ - "SourceryLib", - "Quick", - "Nimble" - ], - exclude: [ - "Info.plist" - ], - resources: sourceryLibTestsResources, - swiftSettings: [.unsafeFlags(["-enable-testing"])] - ), - .testTarget( - name: "CodableContextTests", - dependencies: [ - "CodableContext", - "Quick", - "Nimble" - ], - path: "Templates/CodableContextTests", - exclude: [ - "Info.plist" - ], - swiftSettings: [.unsafeFlags(["-enable-testing"])] - ), - .testTarget( - name: "TemplatesTests", - dependencies: [ - "Quick", - "Nimble", - "PathKit" - ], - path: "Templates", - exclude: [ - "CodableContext", - "CodableContextTests", - "Tests/Generated", - "Tests/Info.plist" - ], - sources: [ - // LinuxMain is not compiled as part of the target - // since there is no way to run script before compilation begins. - "Tests/TemplatesTests.swift" - ], - resources: templatesTestsResourcesCopy, - swiftSettings: [.unsafeFlags(["-enable-testing"])] - ), - .plugin( - name: "SourceryCommandPlugin", - capability: .command( - intent: .custom( - verb: "sourcery-command", - description: "Sourcery command plugin for code generation" - ), - permissions: [ - .writeToPackageDirectory(reason: "Need permission to write generated files to package directory") - ] - ), - dependencies: ["SourceryExecutable"] - ) - ] + dependencies: ["SourceryExecutable"] + ) +] #if canImport(ObjectiveC) let sourceryUtilsDependencies: [Target.Dependency] = ["PathKit"] @@ -242,13 +242,13 @@ let sourceryUtilsDependencies: [Target.Dependency] = [ #endif targets.append( .target( - name: "SourceryUtils", - dependencies: sourceryUtilsDependencies, - path: "SourceryUtils", - exclude: [ - "Supporting Files/Info.plist" - ] - ) + name: "SourceryUtils", + dependencies: sourceryUtilsDependencies, + path: "SourceryUtils", + exclude: [ + "Supporting Files/Info.plist" + ] + ) ) var dependencies: [Package.Dependency] = [ @@ -256,7 +256,7 @@ var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/kylef/Commander.git", exact: "0.9.1"), // PathKit needs to be exact to avoid a SwiftPM bug where dependency resolution takes a very long time. .package(url: "https://github.com/kylef/PathKit.git", exact: "1.0.1"), - .package(url: "https://github.com/art-divin/StencilSwiftKit.git", exact: "2.10.3"), + .package(url: "https://github.com/art-divin/StencilSwiftKit.git", exact: "2.10.4"), .package(url: "https://github.com/tuist/XcodeProj.git", exact: "8.16.0"), .package(url: "https://github.com/apple/swift-syntax.git", from: "508.0.0"), .package(url: "https://github.com/Quick/Quick.git", from: "3.0.0"), @@ -271,7 +271,7 @@ dependencies.append(.package(url: "https://github.com/apple/swift-crypto", from: let package = Package( name: "Sourcery", platforms: [ - .macOS(.v12), + .macOS(.v12), ], products: [ // SPM won't generate .swiftmodule for a target directly used by a product, diff --git a/Sourcery.podspec b/Sourcery.podspec index 8e43e2dbb..84ba2d441 100644 --- a/Sourcery.podspec +++ b/Sourcery.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Sourcery" - s.version = "2.1.2" + s.version = "2.1.3" s.summary = "A tool that brings meta-programming to Swift, allowing you to code generate Swift code." s.description = <<-DESC diff --git a/SourceryFramework.podspec b/SourceryFramework.podspec index b7f5847b1..aed21608d 100644 --- a/SourceryFramework.podspec +++ b/SourceryFramework.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SourceryFramework" - s.version = "2.1.2" + s.version = "2.1.3" s.summary = "A tool that brings meta-programming to Swift, allowing you to code generate Swift code." s.platform = :osx, '10.15' diff --git a/SourceryRuntime.podspec b/SourceryRuntime.podspec index fc8bd2afd..e1a2ff146 100644 --- a/SourceryRuntime.podspec +++ b/SourceryRuntime.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SourceryRuntime" - s.version = "2.1.2" + s.version = "2.1.3" s.summary = "A tool that brings meta-programming to Swift, allowing you to code generate Swift code." s.platform = :osx, '10.15' diff --git a/SourceryRuntime/Sources/AST/AccessLevel.swift b/SourceryRuntime/Sources/AST/AccessLevel.swift index 91dd12255..c293f99dc 100644 --- a/SourceryRuntime/Sources/AST/AccessLevel.swift +++ b/SourceryRuntime/Sources/AST/AccessLevel.swift @@ -7,6 +7,7 @@ import Foundation /// :nodoc: public enum AccessLevel: String { + case `package` = "package" case `internal` = "internal" case `private` = "private" case `fileprivate` = "fileprivate" diff --git a/SourceryRuntime/Sources/AST/Attribute.swift b/SourceryRuntime/Sources/AST/Attribute.swift index 1e0a2aac9..4120f7974 100644 --- a/SourceryRuntime/Sources/AST/Attribute.swift +++ b/SourceryRuntime/Sources/AST/Attribute.swift @@ -56,10 +56,13 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case autoclosure case convention case mutating + case nonisolated + case isolated case escaping case final case open case lazy + case `package` = "package" case `public` = "public" case `internal` = "internal" case `private` = "private" @@ -69,6 +72,7 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case privateSetter = "setter_access.private" case fileprivateSetter = "setter_access.fileprivate" case optional + case dynamic public init?(identifier: String) { let identifier = identifier.trimmingPrefix("source.decl.attribute.") diff --git a/SourceryRuntime/Sources/AST/Method.swift b/SourceryRuntime/Sources/AST/Method.swift index 9735277d9..22847ff7d 100644 --- a/SourceryRuntime/Sources/AST/Method.swift +++ b/SourceryRuntime/Sources/AST/Method.swift @@ -96,25 +96,25 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is a convenience initializer public var isConvenienceInitializer: Bool { - modifiers.contains { $0.name == "convenience" } + modifiers.contains { $0.name == Attribute.Identifier.convenience.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is required public var isRequired: Bool { - modifiers.contains { $0.name == "required" } + modifiers.contains { $0.name == Attribute.Identifier.required.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is final public var isFinal: Bool { - modifiers.contains { $0.name == "final" } + modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is mutating public var isMutating: Bool { - modifiers.contains { $0.name == "mutating" } + modifiers.contains { $0.name == Attribute.Identifier.mutating.rawValue } } // sourcery: skipEquality, skipDescription @@ -126,13 +126,19 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is optional (in an Objective-C protocol) public var isOptional: Bool { - modifiers.contains { $0.name == "optional" } + modifiers.contains { $0.name == Attribute.Identifier.optional.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is nonisolated (this modifier only applies to actor methods) public var isNonisolated: Bool { - modifiers.contains { $0.name == "nonisolated" } + modifiers.contains { $0.name == Attribute.Identifier.nonisolated.rawValue } + } + + // sourcery: skipEquality, skipDescription + /// Whether method is dynamic + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Annotations, that were created with // sourcery: annotation1, other = "annotation value", alterantive = 2 diff --git a/SourceryRuntime/Sources/AST/Method_Linux.swift b/SourceryRuntime/Sources/AST/Method_Linux.swift index f97d315db..f4458ad01 100644 --- a/SourceryRuntime/Sources/AST/Method_Linux.swift +++ b/SourceryRuntime/Sources/AST/Method_Linux.swift @@ -42,6 +42,8 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin return isOptionalReturnType case "actualReturnTypeName": return actualReturnTypeName + case "isDynamic": + return isDynamic default: fatalError("unable to lookup: \(member) in \(self)") } @@ -135,25 +137,25 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is a convenience initializer public var isConvenienceInitializer: Bool { - modifiers.contains { $0.name == "convenience" } + modifiers.contains { $0.name == Attribute.Identifier.convenience.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is required public var isRequired: Bool { - modifiers.contains { $0.name == "required" } + modifiers.contains { $0.name == Attribute.Identifier.required.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is final public var isFinal: Bool { - modifiers.contains { $0.name == "final" } + modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is mutating public var isMutating: Bool { - modifiers.contains { $0.name == "mutating" } + modifiers.contains { $0.name == Attribute.Identifier.mutating.rawValue } } // sourcery: skipEquality, skipDescription @@ -165,13 +167,19 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is optional (in an Objective-C protocol) public var isOptional: Bool { - modifiers.contains { $0.name == "optional" } + modifiers.contains { $0.name == Attribute.Identifier.optional.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is nonisolated (this modifier only applies to actor methods) public var isNonisolated: Bool { - modifiers.contains { $0.name == "nonisolated" } + modifiers.contains { $0.name == Attribute.Identifier.nonisolated.rawValue } + } + + // sourcery: skipEquality, skipDescription + /// Whether method is dynamic + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Annotations, that were created with // sourcery: annotation1, other = "annotation value", alterantive = 2 diff --git a/SourceryRuntime/Sources/AST/Variable.swift b/SourceryRuntime/Sources/AST/Variable.swift index 2cf3c13d0..b326c65d7 100644 --- a/SourceryRuntime/Sources/AST/Variable.swift +++ b/SourceryRuntime/Sources/AST/Variable.swift @@ -70,12 +70,17 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document /// Whether variable is final or not public var isFinal: Bool { - return modifiers.contains { $0.name == "final" } + return modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } /// Whether variable is lazy or not public var isLazy: Bool { - return modifiers.contains { $0.name == "lazy" } + return modifiers.contains { $0.name == Attribute.Identifier.lazy.rawValue } + } + + /// Whether variable is dynamic or not + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Reference to type name where the variable is defined, @@ -145,6 +150,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document string += "modifiers = \(String(describing: self.modifiers)), " string += "isFinal = \(String(describing: self.isFinal)), " string += "isLazy = \(String(describing: self.isLazy)), " + string += "isDynamic = \(String(describing: self.isDynamic)), " string += "definedInTypeName = \(String(describing: self.definedInTypeName)), " string += "actualDefinedInTypeName = \(String(describing: self.actualDefinedInTypeName))" return string diff --git a/SourceryRuntime/Sources/AST/Variable_Linux.swift b/SourceryRuntime/Sources/AST/Variable_Linux.swift index 49615d629..95a899d5c 100644 --- a/SourceryRuntime/Sources/AST/Variable_Linux.swift +++ b/SourceryRuntime/Sources/AST/Variable_Linux.swift @@ -40,6 +40,8 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document return isArray case "isDictionary": return isDictionary + case "isDynamic": + return isDynamic default: fatalError("unable to lookup: \(member) in \(self)") } @@ -102,12 +104,17 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document /// Whether variable is final or not public var isFinal: Bool { - return modifiers.contains { $0.name == "final" } + return modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } /// Whether variable is lazy or not public var isLazy: Bool { - return modifiers.contains { $0.name == "lazy" } + return modifiers.contains { $0.name == Attribute.Identifier.lazy.rawValue } + } + + /// Whether variable is dynamic or not + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Reference to type name where the variable is defined, @@ -177,6 +184,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document string += "modifiers = \(String(describing: self.modifiers)), " string += "isFinal = \(String(describing: self.isFinal)), " string += "isLazy = \(String(describing: self.isLazy)), " + string += "isDynamic = \(String(describing: self.isDynamic)), " string += "definedInTypeName = \(String(describing: self.definedInTypeName)), " string += "actualDefinedInTypeName = \(String(describing: self.actualDefinedInTypeName))" return string diff --git a/SourceryRuntime/Sources/Generated/Coding.generated.swift b/SourceryRuntime/Sources/Generated/Coding.generated.swift index a68c22348..f0315e3e8 100644 --- a/SourceryRuntime/Sources/Generated/Coding.generated.swift +++ b/SourceryRuntime/Sources/Generated/Coding.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline diff --git a/SourceryRuntime/Sources/Generated/JSExport.generated.swift b/SourceryRuntime/Sources/Generated/JSExport.generated.swift index 860ab4120..83028452b 100644 --- a/SourceryRuntime/Sources/Generated/JSExport.generated.swift +++ b/SourceryRuntime/Sources/Generated/JSExport.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace trailing_newline #if canImport(JavaScriptCore) diff --git a/SourceryRuntime/Sources/Generated/Typed.generated.swift b/SourceryRuntime/Sources/Generated/Typed.generated.swift index b173a4323..1f1a2bda9 100644 --- a/SourceryRuntime/Sources/Generated/Typed.generated.swift +++ b/SourceryRuntime/Sources/Generated/Typed.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable vertical_whitespace diff --git a/SourcerySwift/Sources/SourceryRuntime.content.generated.swift b/SourcerySwift/Sources/SourceryRuntime.content.generated.swift index 75168e5bb..19314b00f 100644 --- a/SourcerySwift/Sources/SourceryRuntime.content.generated.swift +++ b/SourcerySwift/Sources/SourceryRuntime.content.generated.swift @@ -500,6 +500,8 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case autoclosure case convention case mutating + case nonisolated + case isolated case escaping case final case open @@ -513,6 +515,7 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case privateSetter = "setter_access.private" case fileprivateSetter = "setter_access.fileprivate" case optional + case dynamic public init?(identifier: String) { let identifier = identifier.trimmingPrefix("source.decl.attribute.") @@ -4068,25 +4071,25 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is a convenience initializer public var isConvenienceInitializer: Bool { - modifiers.contains { $0.name == "convenience" } + modifiers.contains { $0.name == Attribute.Identifier.convenience.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is required public var isRequired: Bool { - modifiers.contains { $0.name == "required" } + modifiers.contains { $0.name == Attribute.Identifier.required.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is final public var isFinal: Bool { - modifiers.contains { $0.name == "final" } + modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is mutating public var isMutating: Bool { - modifiers.contains { $0.name == "mutating" } + modifiers.contains { $0.name == Attribute.Identifier.mutating.rawValue } } // sourcery: skipEquality, skipDescription @@ -4098,13 +4101,19 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is optional (in an Objective-C protocol) public var isOptional: Bool { - modifiers.contains { $0.name == "optional" } + modifiers.contains { $0.name == Attribute.Identifier.optional.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is nonisolated (this modifier only applies to actor methods) public var isNonisolated: Bool { - modifiers.contains { $0.name == "nonisolated" } + modifiers.contains { $0.name == Attribute.Identifier.nonisolated.rawValue } + } + + // sourcery: skipEquality, skipDescription + /// Whether method is dynamic + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Annotations, that were created with // sourcery: annotation1, other = "annotation value", alterantive = 2 @@ -7575,12 +7584,17 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document /// Whether variable is final or not public var isFinal: Bool { - return modifiers.contains { $0.name == "final" } + return modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } /// Whether variable is lazy or not public var isLazy: Bool { - return modifiers.contains { $0.name == "lazy" } + return modifiers.contains { $0.name == Attribute.Identifier.lazy.rawValue } + } + + /// Whether variable is dynamic or not + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Reference to type name where the variable is defined, @@ -7650,6 +7664,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document string += "modifiers = \\(String(describing: self.modifiers)), " string += "isFinal = \\(String(describing: self.isFinal)), " string += "isLazy = \\(String(describing: self.isLazy)), " + string += "isDynamic = \\(String(describing: self.isDynamic)), " string += "definedInTypeName = \\(String(describing: self.definedInTypeName)), " string += "actualDefinedInTypeName = \\(String(describing: self.actualDefinedInTypeName))" return string diff --git a/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift b/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift index f64088488..e1b43ac35 100644 --- a/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift +++ b/SourcerySwift/Sources/SourceryRuntime_Linux.content.generated.swift @@ -514,6 +514,8 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case autoclosure case convention case mutating + case nonisolated + case isolated case escaping case final case open @@ -527,6 +529,7 @@ public class Attribute: NSObject, AutoCoding, AutoEquatable, AutoDiffable, AutoJ case privateSetter = "setter_access.private" case fileprivateSetter = "setter_access.fileprivate" case optional + case dynamic public init?(identifier: String) { let identifier = identifier.trimmingPrefix("source.decl.attribute.") @@ -3444,25 +3447,25 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is a convenience initializer public var isConvenienceInitializer: Bool { - modifiers.contains { $0.name == "convenience" } + modifiers.contains { $0.name == Attribute.Identifier.convenience.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is required public var isRequired: Bool { - modifiers.contains { $0.name == "required" } + modifiers.contains { $0.name == Attribute.Identifier.required.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is final public var isFinal: Bool { - modifiers.contains { $0.name == "final" } + modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is mutating public var isMutating: Bool { - modifiers.contains { $0.name == "mutating" } + modifiers.contains { $0.name == Attribute.Identifier.mutating.rawValue } } // sourcery: skipEquality, skipDescription @@ -3474,13 +3477,19 @@ public final class Method: NSObject, SourceryModel, Annotated, Documented, Defin // sourcery: skipEquality, skipDescription /// Whether method is optional (in an Objective-C protocol) public var isOptional: Bool { - modifiers.contains { $0.name == "optional" } + modifiers.contains { $0.name == Attribute.Identifier.optional.rawValue } } // sourcery: skipEquality, skipDescription /// Whether method is nonisolated (this modifier only applies to actor methods) public var isNonisolated: Bool { - modifiers.contains { $0.name == "nonisolated" } + modifiers.contains { $0.name == Attribute.Identifier.nonisolated.rawValue } + } + + // sourcery: skipEquality, skipDescription + /// Whether method is dynamic + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Annotations, that were created with // sourcery: annotation1, other = "annotation value", alterantive = 2 @@ -6923,12 +6932,17 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document /// Whether variable is final or not public var isFinal: Bool { - return modifiers.contains { $0.name == "final" } + return modifiers.contains { $0.name == Attribute.Identifier.final.rawValue } } /// Whether variable is lazy or not public var isLazy: Bool { - return modifiers.contains { $0.name == "lazy" } + return modifiers.contains { $0.name == Attribute.Identifier.lazy.rawValue } + } + + /// Whether variable is dynamic or not + public var isDynamic: Bool { + modifiers.contains { $0.name == Attribute.Identifier.dynamic.rawValue } } /// Reference to type name where the variable is defined, @@ -6998,6 +7012,7 @@ public final class Variable: NSObject, SourceryModel, Typed, Annotated, Document string += "modifiers = \\(String(describing: self.modifiers)), " string += "isFinal = \\(String(describing: self.isFinal)), " string += "isLazy = \\(String(describing: self.isLazy)), " + string += "isDynamic = \\(String(describing: self.isDynamic)), " string += "definedInTypeName = \\(String(describing: self.definedInTypeName)), " string += "actualDefinedInTypeName = \\(String(describing: self.actualDefinedInTypeName))" return string diff --git a/SourceryTests/Models/ClassSpec.swift b/SourceryTests/Models/ClassSpec.swift index 7291d3c86..a3bf3fb46 100644 --- a/SourceryTests/Models/ClassSpec.swift +++ b/SourceryTests/Models/ClassSpec.swift @@ -24,6 +24,10 @@ class ClassSpec: QuickSpec { expect(sut?.kind).to(equal("class")) } + it("supports package access level") { + expect(Class(name: "Foo", accessLevel: .package).accessLevel == AccessLevel.package.rawValue).to(beTrue()) + expect(Class(name: "Foo", accessLevel: .internal).accessLevel == AccessLevel.package.rawValue).to(beFalse()) + } } } } diff --git a/SourceryTests/Models/MethodSpec.swift b/SourceryTests/Models/MethodSpec.swift index 33633f6a6..fd70f6651 100644 --- a/SourceryTests/Models/MethodSpec.swift +++ b/SourceryTests/Models/MethodSpec.swift @@ -26,6 +26,11 @@ class MethodSpec: QuickSpec { expect(sut?.shortName).to(equal("foo")) } + it("reports isDynamic properly") { + expect(Method(name: "foo()", modifiers: [Modifier(name: "dynamic", detail: nil)]).isDynamic).to(beTrue()) + expect(Method(name: "foo()", modifiers: [Modifier(name: "mutating", detail: nil)]).isDynamic).to(beFalse()) + } + it("reports definedInTypeName propertly") { expect(Method(name: "foo()", definedInTypeName: TypeName(name: "BarAlias", actualTypeName: TypeName(name: "Bar"))).definedInTypeName).to(equal(TypeName(name: "BarAlias"))) expect(Method(name: "foo()", definedInTypeName: TypeName(name: "Foo")).definedInTypeName).to(equal(TypeName(name: "Foo"))) @@ -55,6 +60,11 @@ class MethodSpec: QuickSpec { expect(Method(name: "foo()").isGeneric).to(beFalse()) } + it("has correct access level") { + expect(Method(name: "foo()", accessLevel: .package).accessLevel == AccessLevel.package.rawValue).to(beTrue()) + expect(Method(name: "foo()", accessLevel: .open).accessLevel == AccessLevel.package.rawValue).to(beFalse()) + } + describe("When testing equality") { context("given same items") { diff --git a/SourceryTests/Models/ProtocolSpec.swift b/SourceryTests/Models/ProtocolSpec.swift index 5c516a035..4c30f532a 100644 --- a/SourceryTests/Models/ProtocolSpec.swift +++ b/SourceryTests/Models/ProtocolSpec.swift @@ -24,6 +24,10 @@ class ProtocolSpec: QuickSpec { expect(sut?.kind).to(equal("protocol")) } + it("supports package access level") { + expect(Protocol(name: "Foo", accessLevel: .package).accessLevel == AccessLevel.package.rawValue).to(beTrue()) + expect(Protocol(name: "Foo", accessLevel: .internal).accessLevel == AccessLevel.package.rawValue).to(beFalse()) + } } } } diff --git a/SourceryTests/Models/TypedSpec.generated.swift b/SourceryTests/Models/TypedSpec.generated.swift index 50a6d27cf..ae05389d6 100644 --- a/SourceryTests/Models/TypedSpec.generated.swift +++ b/SourceryTests/Models/TypedSpec.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT import Quick import Nimble diff --git a/SourceryTests/Models/VariableSpec.swift b/SourceryTests/Models/VariableSpec.swift index 959f8f7d2..af698412a 100644 --- a/SourceryTests/Models/VariableSpec.swift +++ b/SourceryTests/Models/VariableSpec.swift @@ -26,10 +26,17 @@ class VariableSpec: QuickSpec { it("has proper read access") { expect(sut?.readAccess == AccessLevel.public.rawValue).to(beTrue()) + expect(Variable(name: "variable", typeName: TypeName(name: "Int"), accessLevel: (read: .package, write: .public), isComputed: true).readAccess == AccessLevel.package.rawValue).to(beTrue()) + } + + it("has proper dynamic state") { + expect(Variable(name: "variable", typeName: TypeName(name: "Int"), accessLevel: (read: .public, write: .internal), isComputed: true, modifiers: [Modifier(name: "dynamic")]).isDynamic).to(beTrue()) + expect(Variable(name: "variable", typeName: TypeName(name: "Int"), accessLevel: (read: .public, write: .internal), isComputed: true, modifiers: [Modifier(name: "lazy")]).isDynamic).to(beFalse()) } it("has proper write access") { expect(sut?.writeAccess == AccessLevel.internal.rawValue).to(beTrue()) + expect(Variable(name: "variable", typeName: TypeName(name: "Int"), accessLevel: (read: .public, write: .package), isComputed: true).writeAccess == AccessLevel.package.rawValue).to(beTrue()) } describe("When testing equality") { diff --git a/SourceryUtils.podspec b/SourceryUtils.podspec index 02ee7d73f..91532fb05 100644 --- a/SourceryUtils.podspec +++ b/SourceryUtils.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "SourceryUtils" - s.version = "2.1.2" + s.version = "2.1.3" s.summary = "A tool that brings meta-programming to Swift, allowing you to code generate Swift code." s.platform = :osx, '10.15' diff --git a/SourceryUtils/Sources/Version.swift b/SourceryUtils/Sources/Version.swift index d9cf99c49..f2c31746d 100644 --- a/SourceryUtils/Sources/Version.swift +++ b/SourceryUtils/Sources/Version.swift @@ -10,7 +10,7 @@ import Foundation public struct SourceryVersion { public let value: String - public static let current = SourceryVersion(value: inUnitTests ? "Major.Minor.Patch" : "2.1.2") + public static let current = SourceryVersion(value: inUnitTests ? "Major.Minor.Patch" : "2.1.3") } #if canImport(ObjectiveC) diff --git a/Templates/Tests/Expected/AutoMockable.expected b/Templates/Tests/Expected/AutoMockable.expected index af41ce38e..fedf24990 100644 --- a/Templates/Tests/Expected/AutoMockable.expected +++ b/Templates/Tests/Expected/AutoMockable.expected @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.2 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable line_length // swiftlint:disable variable_name