Skip to content

Commit 20ea737

Browse files
authored
Smooth degradataion for non-library assets (#123)
If we can't get a LibraryElement for a primary input it should not have any output. Return early rather than throw later.
1 parent f960f4e commit 20ea737

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.5.3+1
2+
3+
* Don't throw when running against a non-library asset and getting no
4+
LibraryElement
5+
16
## 0.5.3
27

38
* Add matchTypes method. As with anything imported from /src/ this is

lib/src/builder.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class GeneratorBuilder extends Builder {
3131
var id = buildStep.input.id;
3232
var resolver = await buildStep.resolve(id, resolveAllConstants: false);
3333
var lib = resolver.getLibrary(id);
34+
if (lib == null) return;
3435
await _generateForLibrary(lib, buildStep);
3536
resolver.release();
3637
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_gen
2-
version: 0.5.3
2+
version: 0.5.3+1
33
author: Dart Team <[email protected]>
44
description: Automatic sourcecode generation for Dart
55
homepage: https://github.com/dart-lang/source_gen

0 commit comments

Comments
 (0)