OLD | NEW |
(Empty) | |
| 1 library di.transformer.options; |
| 2 |
| 3 import 'dart:async'; |
| 4 |
| 5 import 'package:barback/barback.dart'; |
| 6 import 'package:code_transformers/resolver.dart'; |
| 7 |
| 8 const List<String> DEFAULT_INJECTABLE_ANNOTATIONS = |
| 9 const ['di.annotations.Injectable']; |
| 10 |
| 11 /// Returns either a bool or a Future<bool> when complete. |
| 12 typedef EntryFilter(Asset asset); |
| 13 |
| 14 /** Options used by DI transformers */ |
| 15 class TransformOptions { |
| 16 |
| 17 /** |
| 18 * Filter to determine which assets should be modified. |
| 19 */ |
| 20 final EntryFilter entryFilter; |
| 21 |
| 22 /** |
| 23 * List of additional annotations which are used to indicate types as being |
| 24 * injectable. |
| 25 */ |
| 26 final List<String> injectableAnnotations; |
| 27 |
| 28 /** |
| 29 * Set of additional types which should be injected. |
| 30 */ |
| 31 final Set<String> injectedTypes; |
| 32 |
| 33 /** |
| 34 * Path to the Dart SDK directory, for resolving Dart libraries. |
| 35 */ |
| 36 final String sdkDirectory; |
| 37 |
| 38 TransformOptions({EntryFilter entryFilter, String sdkDirectory, |
| 39 List<String> injectableAnnotations, List<String> injectedTypes}) |
| 40 : entryFilter = entryFilter != null ? entryFilter : isPossibleDartEntry, |
| 41 sdkDirectory = sdkDirectory, |
| 42 injectableAnnotations = |
| 43 (injectableAnnotations != null ? injectableAnnotations : []) |
| 44 ..addAll(DEFAULT_INJECTABLE_ANNOTATIONS), |
| 45 injectedTypes = |
| 46 new Set.from(injectedTypes != null ? injectedTypes : []) { |
| 47 if (sdkDirectory == null) |
| 48 throw new ArgumentError('sdkDirectory must be provided.'); |
| 49 } |
| 50 |
| 51 Future<bool> isDartEntry(Asset asset) => new Future.value(entryFilter(asset)); |
| 52 } |
OLD | NEW |