getLoopTarget method
Safety<List<FileSystemModelRoute> >
getLoopTarget(
- FileSystemModelRoute target,
- FileSystemModelRouteRoster<
FileSystemModelRoute> base
Implementation
Safety<List<FileSystemModelRoute>> getLoopTarget(FileSystemModelRoute target, FileSystemModelRouteRoster<FileSystemModelRoute> base) {
final log = Log(classLocation: runtimeType, functionLocation: 'getLoopTarget');
final List<FileSystemModelRoute> list = [];
// target 自身も list に追加する必要あり
// この時 target name と descendants の各 location(一つ目の要素の部分の) の for alone block 部分の記述を消す.
final newTarget = target.changeName(target.name.replaceFirst(source, ''));
list.add(newTarget);
// 1.
final getDescendantsResult = base.getDescendants(target.route);
log.add(getDescendantsResult);
// location の先頭にだけ for alone block の記述があるのでそれを消す.
// for loop の場合 define の記述の追加も必要
for (final i in getDescendantsResult.wrapped) {
// final location = i.location;
// final newLocation = List.generate(location.length, (index) => location.elementAt(index).replaceFirst(source, ''));
// 1 より 必ず return.
final locationFirstResult = i.location.first;
final replaceResult = locationFirstResult.replaceFirst(source, '');
final newLocation = [replaceResult, ...i.location.skip(1)];
final result = i.changeLocation(newLocation);
list.add(result);
}
return Safety(list, log);
}