imports: function imports()

in src/plugins/algebraic-type-initialization.ts [441:484]


    imports: function imports(
      algebraicType: AlgebraicType.Type,
    ): ObjC.Import[] {
      const baseImports: ObjC.Import[] = [
        PUBLIC_FOUNDATION_IMPORT,
        internalImportForFileWithName(algebraicType.name),
      ];
      const makePublicImports =
        makePublicImportsForAlgebraicType(algebraicType);
      const typeLookupImports = algebraicType.typeLookups
        .filter((typeLookup) =>
          isImportRequiredForTypeLookup(algebraicType, typeLookup),
        )
        .map((typeLookup) =>
          ObjCImportUtils.importForTypeLookup(
            algebraicType.libraryName,
            makePublicImports || !typeLookup.canForwardDeclare,
            typeLookup,
          ),
        );
      const skipAttributeImports =
        !makePublicImports &&
        algebraicType.includes.indexOf('SkipImportsInImplementation') !== -1;
      const attributeImports: ObjC.Import[] = skipAttributeImports
        ? []
        : AlgebraicTypeUtils.allAttributesFromSubtypes(algebraicType.subtypes)
            .filter((attribute) =>
              ObjCImportUtils.shouldIncludeImportForType(
                algebraicType.typeLookups,
                attribute.type.name,
              ),
            )
            .map((attribute) =>
              ObjCImportUtils.importForAttribute(
                attribute.type.name,
                attribute.type.underlyingType,
                attribute.type.libraryTypeIsDefinedIn,
                attribute.type.fileTypeIsDefinedIn,
                algebraicType.libraryName,
                makePublicImports,
              ),
            );
      return baseImports.concat(typeLookupImports).concat(attributeImports);
    },