call method

  1. @override
List<Node> call(
  1. GroupSettings groupSettings,
  2. Iterable<String> filePaths
)
override

Implementation

@override
List<Node> call(GroupSettings groupSettings, Iterable<String> filePaths) {
  final root = Node();

  for (final filePath in filePaths) {
    final segments = pt.split(filePath);
    var node = root;
    for (var i = 0; i < segments.length; i++) {
      final segment = segments[i];

      if ((i + 1) == segments.length) {
        node.files[pt.basenameWithoutExtension(filePath).camelCase] = filePath;
        continue;
      }

      final child = node.children.firstWhereOrNull((node) => node.dirName == segment);
      if (child == null) {
        final newChild = Node(dirName: segment);
        node.children.add(newChild);
        node = newChild;
        continue;
      }

      node = child;
    }
  }

  return [root];
}