Chromium Code Reviews| Index: lib/src/util/dart.dart |
| diff --git a/lib/src/util/dart.dart b/lib/src/util/dart.dart |
| index 3ee861b23de6263d9a02f0fc307e65994db758dd..bd7cec3f5633982f0b08293715dd7d24daf59975 100644 |
| --- a/lib/src/util/dart.dart |
| +++ b/lib/src/util/dart.dart |
| @@ -8,6 +8,7 @@ import 'dart:async'; |
| import 'dart:io'; |
| import 'dart:isolate'; |
| +import 'package:analyzer/analyzer.dart'; |
| import 'package:path/path.dart' as p; |
| import 'io.dart'; |
| @@ -70,3 +71,13 @@ void _isolateBuffer(message) { |
| }); |
| }); |
| } |
| + |
| +/// Parse all the annotations at the beginning of a Dart file. |
| +/// |
| +/// This will parse annotations until the first non-annotation production is |
| +/// reached. |
| +List<Annotation> parseAnnotations(String path) { |
| + var contents = new File(path).readAsStringSync(); |
| + var directives = parseDirectives(contents, name: path).directives; |
| + return directives.first.metadata; |
|
Bob Nystrom
2015/03/12 19:37:40
How does this handle an empty file? I know it's a
nweiz
2015/03/12 19:52:13
Good catch. Fixed.
|
| +} |