Skip to content

Commit

Permalink
remove trackAsDependency and addDependency apis
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Jan 29, 2016
1 parent f5cfda9 commit bc03328
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 53 deletions.
16 changes: 2 additions & 14 deletions lib/src/builder/build_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,12 @@ abstract class BuildStep {
Asset get input;

/// Checks if an [Asset] by [id] exists as an input for this [BuildStep].
///
/// If [trackAsDependency] is true, then [id] will be marked as a dependency
/// of all [expectedOutputs].
Future<bool> hasInput(AssetId id, {bool trackAsDependency: true});
Future<bool> hasInput(AssetId id);

/// Reads an [Asset] by [id] as a [String] using [encoding].
///
/// If [trackAsDependency] is true, then [id] will be marked as a dependency
/// of all [expectedOutputs].
Future<String> readAsString(AssetId id,
{Encoding encoding: UTF8, bool trackAsDependency: true});
Future<String> readAsString(AssetId id, {Encoding encoding: UTF8});

/// Outputs an [Asset] using the current [AssetWriter], and adds [asset] to
/// [outputs].
void writeAsString(Asset asset, {Encoding encoding: UTF8});

/// Explicitly adds [id] as a dependency of all [expectedOutputs]. This is
/// not generally necessary unless forcing `trackAsDependency: false` when
/// calling [readAsString].
void addDependency(AssetId id);
}
23 changes: 4 additions & 19 deletions lib/src/builder/build_step_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,15 @@ class BuildStepImpl implements BuildStep {
}

/// Checks if an [Asset] by [id] exists as an input for this [BuildStep].
///
/// If [trackAsDependency] is true, then [id] will be marked as a dependency
/// of all [expectedOutputs].
Future<bool> hasInput(AssetId id, {bool trackAsDependency: true}) {
if (trackAsDependency) _dependencies.add(id);
Future<bool> hasInput(AssetId id) {
_dependencies.add(id);
return _reader.hasInput(id);
}

/// Reads an [Asset] by [id] as a [String] using [encoding].
///
/// If [trackAsDependency] is true, then [id] will be marked as a dependency
/// of all [expectedOutputs].
@override
Future<String> readAsString(AssetId id,
{Encoding encoding: UTF8, bool trackAsDependency: true}) {
if (trackAsDependency) _dependencies.add(id);
Future<String> readAsString(AssetId id, {Encoding encoding: UTF8}) {
_dependencies.add(id);
return _reader.readAsString(id, encoding: encoding);
}

Expand All @@ -83,12 +76,4 @@ class BuildStepImpl implements BuildStep {
var done = _writer.writeAsString(asset, encoding: encoding);
_outputsCompleted = _outputsCompleted.then((_) => done);
}

/// Explicitly adds [id] as a dependency of all [expectedOutputs]. This is
/// not generally necessary unless forcing `trackAsDependency: false` when
/// calling [readAsString].
@override
void addDependency(AssetId id) {
_dependencies.add(id);
}
}
20 changes: 0 additions & 20 deletions test/builder/build_step_impl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ main() {
var a2 = makeAssetId();
await buildStep.readAsString(a2);
expect(buildStep.dependencies, [primary.id, a1, a2]);

var a3 = makeAssetId();
await buildStep.readAsString(a3, trackAsDependency: false);
expect(buildStep.dependencies.contains(a3), isFalse);
});

test('tracks dependencies on hasInput', () async {
Expand All @@ -51,22 +47,6 @@ main() {
var a2 = makeAssetId();
await buildStep.hasInput(a2);
expect(buildStep.dependencies, [primary.id, a1, a2]);

var a3 = makeAssetId();
await buildStep.hasInput(a3, trackAsDependency: false);
expect(buildStep.dependencies.contains(a3), isFalse);
});

test('addDependency adds dependencies', () {
expect(buildStep.dependencies, [primary.id]);

var a1 = makeAssetId();
buildStep.addDependency(a1);
expect(buildStep.dependencies, [primary.id, a1]);

var a2 = makeAssetId();
buildStep.addDependency(a2);
expect(buildStep.dependencies, [primary.id, a1, a2]);
});

test('tracks outputs', () async {
Expand Down

0 comments on commit bc03328

Please sign in to comment.