OLD | NEW |
1 // Copyright (c) 2016, the Dart Team. All rights reserved. Use of this | 1 // Copyright (c) 2016, the Dart Team. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in | 2 // source code is governed by a BSD-style license that can be found in |
3 // the LICENSE file. | 3 // the LICENSE file. |
4 | 4 |
5 library reflectable.transformer; | 5 library reflectable.transformer; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:barback/barback.dart'; | 9 import 'package:barback/barback.dart'; |
| 10 import 'package:glob/glob.dart'; |
10 import 'package:logging/logging.dart'; | 11 import 'package:logging/logging.dart'; |
11 import 'src/transformer_implementation.dart' as implementation; | 12 import 'src/transformer_implementation.dart' as implementation; |
12 | 13 |
13 class ReflectableTransformer extends Transformer | 14 class ReflectableTransformer extends Transformer |
14 implements DeclaringTransformer { | 15 implements DeclaringTransformer { |
15 BarbackSettings _settings; | 16 BarbackSettings _settings; |
16 List<String> _entryPoints = <String>[]; | 17 List<String> _entryPoints = <String>[]; |
17 bool _formatted; | 18 bool _formatted; |
18 List<implementation.WarningKind> _suppressWarnings = | 19 List<implementation.WarningKind> _suppressWarnings = |
19 <implementation.WarningKind>[]; | 20 <implementation.WarningKind>[]; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 @override | 137 @override |
137 Future apply(Transform transform) { | 138 Future apply(Transform transform) { |
138 return new implementation.TransformerImplementation() | 139 return new implementation.TransformerImplementation() |
139 .apply(transform, _entryPoints, _formatted, _suppressWarnings); | 140 .apply(transform, _entryPoints, _formatted, _suppressWarnings); |
140 } | 141 } |
141 | 142 |
142 @override | 143 @override |
143 declareOutputs(DeclaringTransform transform) async { | 144 declareOutputs(DeclaringTransform transform) async { |
144 AssetId id = await transform.primaryId; | 145 AssetId id = await transform.primaryId; |
145 _entryPoints.forEach((String entryPoint) { | 146 _entryPoints.forEach((String entryPoint) { |
146 if (id.path.endsWith(entryPoint)) { | 147 Glob glob = new Glob(entryPoint); |
| 148 if (glob.matches(id.path)) { |
147 transform.declareOutput(id); | 149 transform.declareOutput(id); |
148 AssetId dataId = id.changeExtension("_reflectable_original_main.dart"); | 150 AssetId dataId = id.changeExtension("_reflectable_original_main.dart"); |
149 transform.declareOutput(dataId); | 151 transform.declareOutput(dataId); |
150 } | 152 } |
151 // Otherwise there is no such entry point; however, we do not need to | 153 // Otherwise there is no such entry point; however, we do not need to |
152 // emit any diagnostic messages, this is done by `apply` in | 154 // emit any diagnostic messages, this is done by `apply` in |
153 // `TransformerImplementation`. | 155 // `TransformerImplementation`. |
154 }); | 156 }); |
155 } | 157 } |
156 } | 158 } |
OLD | NEW |