Skip to content
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

remove trackAsDependency and addDependency apis #18

Merged
merged 1 commit into from
Jan 29, 2016
Merged
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
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