From 4533c9cd0ffa7f1a25b4b06c4378537b355fe6fc Mon Sep 17 00:00:00 2001 From: Ruslan Alikhamov Date: Sat, 23 Dec 2023 18:02:16 +0400 Subject: [PATCH] added dynamic to Variable --- SourceryRuntime/Sources/AST/Variable.swift | 10 ++++++++-- SourceryRuntime/Sources/AST/Variable_Linux.swift | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) 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