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
          // fix for https://github.com/comigor/artemis/issues/226
          ? (path.length == 2 ? path : [path.last])
          : [className];
      break;
    case NamingScheme.pathedWithFields:
      fullPath = [...path, fieldName];
      break;
    case NamingScheme.pathedWithTypes:
    default:
      fullPath = [...path, className];
      break;
  }

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