applyProtocolReferences method

TypeDefinition applyProtocolReferences(
  1. List<SerializableModelDefinition> classDefinitions
)

Applies protocol references. This makes the protocol: prefix optional. First, the protocol definition is parsed, then it's check for the protocol: prefix in types. Whenever no url is set and user specified a class/enum with the same symbol name it defaults to the protocol: prefix.

Implementation

TypeDefinition applyProtocolReferences(
  List<SerializableModelDefinition> classDefinitions,
) {
  var modelDefinition = classDefinitions
      .where((c) => c.className == className)
      .where((c) => c.type.moduleAlias == defaultModuleAlias)
      .firstOrNull;
  bool isProjectModel =
      url == defaultModuleAlias || (url == null && modelDefinition != null);
  return TypeDefinition(
    className: className,
    nullable: nullable,
    customClass: customClass,
    dartType: dartType,
    projectModelDefinition: isProjectModel ? modelDefinition : null,
    generics: generics
        .map((e) => e.applyProtocolReferences(classDefinitions))
        .toList(),
    enumDefinition: enumDefinition,
    url: isProjectModel ? defaultModuleAlias : url,
    recordFieldName: recordFieldName,
    vectorDimension: vectorDimension,
  );
}