       implements: [],
       typealiasses: [],
       properties: colorLets,
-      functions: groupedColors.uniques.map { [ colorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName),
-                                               watchOSColorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName)] }.flatMap { $0 },
+      functions: groupedColors.uniques.map { [ generateColorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName),
+                                               generateWatchOSColorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName)] }.flatMap { $0 },
       structs: structs,
       classes: [],
       os: []

//

import Foundation

fileprivate func colorFunction(for name: String, at externalAccessLevel: AccessLevel, prefix: SwiftIdentifier) -> Function {
  let structName = SwiftIdentifier(name: name)
  let qualifiedName = prefix + structName

  return Function(
    availables: ["tvOS 11.0, *", "iOS 11.0, *"],
    comments: ["`UIColor(named: \"\(name)\", bundle: ..., traitCollection: ...)`"],
    accessModifier: externalAccessLevel,
    isStatic: true,
    name: structName,
    generics: nil,
    parameters: [
      Function.Parameter(
        name: "compatibleWith",
        localName: "traitCollection",
        type: Type._UITraitCollection.asOptional(),
        defaultValue: "nil"
      )
    ],
    doesThrow: false,
    returnType: Type._UIColor.asOptional(),
    body: "return UIKit.UIColor(resource: \(qualifiedName), compatibleWith: traitCollection)",
    os: ["iOS", "tvOS"]
  )
}

fileprivate func watchOSColorFunction(for name: String, at externalAccessLevel: AccessLevel, prefix: SwiftIdentifier) -> Function {
  let structName = SwiftIdentifier(name: name)
  let qualifiedName = prefix + structName

  return Function(
    availables: ["watchOSApplicationExtension 4.0, *"],
    comments: ["`UIColor(named: \"\(name)\", bundle: ..., traitCollection: ...)`"],
    accessModifier: externalAccessLevel,
    isStatic: true,
    name: structName,
    generics: nil,
    parameters: [
      Function.Parameter(name: "_", type: Type._Void, defaultValue: "()")
    ],
    doesThrow: false,
    returnType: Type._UIColor.asOptional(),
    body: "return UIKit.UIColor(named: \(qualifiedName).name)",
    os: ["watchOS"]
  )
}

struct ColorStructGenerator: ExternalOnlyStructGenerator {
  private let assetFolders: [AssetFolder]

      implements: [],
      typealiasses: [],
      properties: colorLets,
      functions: groupedFunctions.uniques.map { [ generateColorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName),
                                                  generateWatchOSColorFunction(for: $0, at: externalAccessLevel, prefix: qualifiedName)] }.flatMap { $0 },
      structs: structs,
      classes: [],
      os: []
    )
  }
}

private func generateColorFunction(for name: String, at externalAccessLevel: AccessLevel, prefix: SwiftIdentifier) -> Function {
  let structName = SwiftIdentifier(name: name)
  let qualifiedName = prefix + structName

  return Function(
    availables: ["tvOS 11.0, *", "iOS 11.0, *"],
    comments: ["`UIColor(named: \"\(name)\", bundle: ..., traitCollection: ...)`"],
    accessModifier: externalAccessLevel,
    isStatic: true,
    name: structName,
    generics: nil,
    parameters: [
      Function.Parameter(
        name: "compatibleWith",
        localName: "traitCollection",
        type: Type._UITraitCollection.asOptional(),
        defaultValue: "nil"
      )
    ],
    doesThrow: false,
    returnType: Type._UIColor.asOptional(),
    body: "return UIKit.UIColor(resource: \(qualifiedName), compatibleWith: traitCollection)",
    os: ["iOS", "tvOS"]
  )
}

private func generateWatchOSColorFunction(for name: String, at externalAccessLevel: AccessLevel, prefix: SwiftIdentifier) -> Function {
  let structName = SwiftIdentifier(name: name)
  let qualifiedName = prefix + structName

  return Function(
    availables: ["watchOSApplicationExtension 4.0, *"],
    comments: ["`UIColor(named: \"\(name)\", bundle: ..., traitCollection: ...)`"],
    accessModifier: externalAccessLevel,
    isStatic: true,
    name: structName,
    generics: nil,
    parameters: [
      Function.Parameter(name: "_", type: Type._Void, defaultValue: "()")
    ],
    doesThrow: false,
    returnType: Type._UIColor.asOptional(),
    body: "return UIKit.UIColor(named: \(qualifiedName).name)",
    os: ["watchOS"]
  )
}
