Skip to content

Commit 2f5d3b9

Browse files
committed
add support for resolving all constants
1 parent e835376 commit 2f5d3b9

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

lib/src/analyzer/resolver.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ class Resolver {
2626
///
2727
/// [release] must be called when done handling this [Resolver] to allow it
2828
/// to be used by later phases.
29+
///
30+
/// If you pass a value of [false] for [resolveAllConstants], then constants
31+
/// will only be resolved in [entryPoints], and not any other libraries. This
32+
/// gives a significant speed boost, at the cost of not being able to assume
33+
/// all constants are already resolved.
2934
Future<Resolver> resolve(BuildStep buildStep,
30-
[List<AssetId> entryPoints]) async {
35+
{List<AssetId> entryPoints, bool resolveAllConstants}) async {
3136
return new Resolver(await resolver.resolve(toBarbackTransform(buildStep),
32-
entryPoints?.map(toBarbackAssetId)?.toList()));
37+
entryPoints?.map(toBarbackAssetId)?.toList(), resolveAllConstants));
3338
}
3439

3540
/// Release this resolver so it can be updated by following build steps.

lib/src/builder/build_step.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@ abstract class BuildStep {
3131

3232
/// Gives a [Resolver] for [id]. This must be released when it is done being
3333
/// used.
34-
Future<Resolver> resolve(AssetId id);
34+
///
35+
/// If you pass a value of [false] for [resolveAllConstants], then constants
36+
/// will only be resolved in [id], and not any other libraries. This gives a
37+
/// significant speed boost, at the cost of not being able to assume all
38+
/// constants are already resolved.
39+
Future<Resolver> resolve(AssetId id, {bool resolveAllConstants});
3540
}

lib/src/builder/build_step_impl.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ class BuildStepImpl implements BuildStep {
9999
}
100100

101101
/// Resolves [id] and returns a [Future<Resolver>] once that is done.
102-
Future<Resolver> resolve(AssetId id) async => new Resolver(
103-
await _resolvers.get(toBarbackTransform(this), [toBarbackAssetId(id)]));
102+
@override
103+
Future<Resolver> resolve(AssetId id, {bool resolveAllConstants}) async =>
104+
new Resolver(await _resolvers.get(toBarbackTransform(this),
105+
[toBarbackAssetId(id)], resolveAllConstants));
104106

105107
/// Should be called after `build` has completed. This will wait until for
106108
/// [_outputsCompleted].

0 commit comments

Comments
 (0)