Skip to content

Commit

Permalink
Fix consistency when context state is not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
sidepelican committed Nov 6, 2024
1 parent de68c4c commit 7676296
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
15 changes: 5 additions & 10 deletions Sources/MockoloFramework/Models/MethodModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,13 @@ final class MethodModel: Model {
return nil
}

return applyMethodTemplate(name: name,
kind: kind,
guard let overloadingResolvedName = context.overloadingResolvedName else {
return nil
}

return applyMethodTemplate(overloadingResolvedName: overloadingResolvedName,
arguments: arguments,
isStatic: isStatic,
customModifiers: customModifiers,
isOverride: shouldOverride,
genericTypeParams: genericTypeParams,
genericWhereClause: genericWhereClause,
params: params,
returnType: returnType,
accessLevel: accessLevel,
argsHistory: argsHistory,
handler: handler(),
context: context)
}
Expand Down
17 changes: 2 additions & 15 deletions Sources/MockoloFramework/Templates/MethodTemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,11 @@
import Foundation

extension MethodModel {
func applyMethodTemplate(name: String,
kind: MethodKind,
func applyMethodTemplate(overloadingResolvedName: String,
arguments: GenerationArguments,
isStatic: Bool,
customModifiers: [String: Modifier]?,
isOverride: Bool,
genericTypeParams: [ParamModel],
genericWhereClause: String?,
params: [ParamModel],
returnType: SwiftType,
accessLevel: String,
argsHistory: ArgumentsHistoryModel?,
handler: ClosureModel?,
context: RenderContext) -> String {
guard let overloadingResolvedName = context.overloadingResolvedName else {
preconditionFailure("context broken")
}
var template = ""

let returnTypeName = returnType.isUnknown ? "" : returnType.typeName
Expand Down Expand Up @@ -122,8 +110,7 @@ extension MethodModel {

let overrideStr = isOverride ? "\(String.override) " : ""
let modifierTypeStr: String
if let customModifiers = customModifiers,
let customModifier: Modifier = customModifiers[name] {
if let customModifier: Modifier = customModifiers[name] {
modifierTypeStr = customModifier.rawValue + " "
} else {
modifierTypeStr = ""
Expand Down

0 comments on commit 7676296

Please sign in to comment.