getDependencySummary method

String getDependencySummary(
  1. List<ZenScope> scopes
)

Get a summary of all dependencies across scopes

Implementation

String getDependencySummary(List<ZenScope> scopes) {
  final buffer = StringBuffer();

  buffer.writeln('=== ZEN DEPENDENCY SUMMARY ===\n');

  var totalDependencies = 0;
  final allTypes = <Type>{};

  for (final scope in scopes) {
    if (scope.isDisposed) continue;

    final deps = scope.findAllOfType<Object>();
    totalDependencies += deps.length;

    for (final dep in deps) {
      allTypes.add(dep.runtimeType);
    }
  }

  buffer
      .writeln('Total Scopes: ${scopes.where((s) => !s.isDisposed).length}');
  buffer.writeln('Total Dependencies: $totalDependencies');
  buffer.writeln('Unique Types: ${allTypes.length}');
  buffer.writeln();

  // List all unique types
  if (allTypes.isNotEmpty) {
    buffer.writeln('Registered Types:');
    final sortedTypes = allTypes.toList()
      ..sort((a, b) => a.toString().compareTo(b.toString()));
    for (final type in sortedTypes) {
      buffer.writeln('  - $type');
    }
  }

  return buffer.toString();
}