Skip to content

Track using graphs #3980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/lib/src/internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library;

export 'library_cycle_graph/asset_deps.dart';
export 'library_cycle_graph/asset_deps_loader.dart';
export 'library_cycle_graph/asset_set.dart';
export 'library_cycle_graph/library_cycle.dart';
export 'library_cycle_graph/library_cycle_graph.dart';
export 'library_cycle_graph/library_cycle_graph_loader.dart';
Expand Down
48 changes: 48 additions & 0 deletions build/lib/src/library_cycle_graph/asset_set.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

import '../asset/id.dart';
import 'library_cycle_graph.dart';

part 'asset_set.g.dart';

abstract class AssetSet implements Built<AssetSet, AssetSetBuilder> {
static Serializer<AssetSet> get serializer => _$assetSetSerializer;

BuiltSet<AssetId> get assets;
BuiltList<LibraryCycleGraph> get graphs;
BuiltSet<AssetId> get removedAssets;

factory AssetSet([void Function(AssetSetBuilder) updates]) = _$AssetSet;
AssetSet._();

AssetSet difference(Iterable<AssetId> other) {
return rebuild((b) {
for (final asset in other) {
if (!b.assets.remove(asset)) {
b.removedAssets.add(asset);
}
}
});
}

Iterable<AssetId> get iterable {
final seenGraphs = Set<LibraryCycleGraph>.identity();
Iterable<AssetId> result = assets;

for (final graph in graphs) {
for (final graph in graph.transitiveGraphs) {
if (seenGraphs.add(graph)) result = result.followedBy(graph.root.ids);
}
}

return result.where((e) => !removedAssets.contains(e));
}

bool get isEmpty => iterable.isEmpty;
}
244 changes: 244 additions & 0 deletions build/lib/src/library_cycle_graph/asset_set.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions build/lib/src/library_cycle_graph/library_cycle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

import '../asset/id.dart';

Expand All @@ -14,6 +15,8 @@ part 'library_cycle.g.dart';
/// This means they have to be compiled as a single unit.
abstract class LibraryCycle
implements Built<LibraryCycle, LibraryCycleBuilder> {
static Serializer<LibraryCycle> get serializer => _$libraryCycleSerializer;

BuiltSet<AssetId> get ids;

factory LibraryCycle([void Function(LibraryCycleBuilder) updates]) =
Expand Down
60 changes: 60 additions & 0 deletions build/lib/src/library_cycle_graph/library_cycle.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading