createPathName function

List<Name> createPathName(
  1. List<Name> path,
  2. NamingScheme? namingScheme, [
  3. Name? currentClassName,
  4. Name? currentFieldName,
  5. Name? alias,
])

Returns the full class name with joined path.

Implementation

List<Name> createPathName(
  List<Name> path,
  NamingScheme? namingScheme, [
  Name? currentClassName,
  Name? currentFieldName,
  Name? alias,
]) {
  final fieldName = alias ?? currentFieldName;
  final className = alias ?? currentClassName;

  List<Name?> fullPath;

  switch (namingScheme) {
    case NamingScheme.simple:
      fullPath = className == null
          ? (path.length == 2 ? path : [path.last])
          : [className];
    case NamingScheme.pathedWithFields:
      fullPath = [...path, fieldName];
    case NamingScheme.pathedWithTypes:
      fullPath = [...path, className];
    case null:
      throw UnimplementedError();
  }

  return fullPath.whereType<Name>().toList();
}