OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// This library uses the Dart analyzer to find the exports for a set of | 5 /// This library uses the Dart analyzer to find the exports for a set of |
6 /// libraries. It stores these exports in an [ExportMap]. This is used to | 6 /// libraries. It stores these exports in an [ExportMap]. This is used to |
7 /// display exported members as part of the exporting library, since dart2js | 7 /// display exported members as part of the exporting library, since dart2js |
8 /// doesn't provide this information itself. | 8 /// doesn't provide this information itself. |
9 library export_map; | 9 library export_map; |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 /// `import` or `export`. | 39 /// `import` or `export`. |
40 factory ExportMap.parse(Iterable<Uri> libraries, String packageRoot) { | 40 factory ExportMap.parse(Iterable<Uri> libraries, String packageRoot) { |
41 var exports = <String, List<Export>>{}; | 41 var exports = <String, List<Export>>{}; |
42 | 42 |
43 void traverse(String path) { | 43 void traverse(String path) { |
44 if (exports.containsKey(path)) return; | 44 if (exports.containsKey(path)) return; |
45 | 45 |
46 var importsAndExports; | 46 var importsAndExports; |
47 try { | 47 try { |
48 importsAndExports = _importsAndExportsForFile(path, packageRoot); | 48 importsAndExports = _importsAndExportsForFile(path, packageRoot); |
49 } on FileException catch (_) { | 49 } on FileSystemException catch (_) { |
50 // Ignore unreadable/nonexistent files. | 50 // Ignore unreadable/nonexistent files. |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 var exportsForLibrary = <String, Export>{}; | 54 var exportsForLibrary = <String, Export>{}; |
55 for (var export in importsAndExports.last) { | 55 for (var export in importsAndExports.last) { |
56 addOrMergeExport(exportsForLibrary, export.path, export); | 56 addOrMergeExport(exportsForLibrary, export.path, export); |
57 } | 57 } |
58 exports[path] = new List.from(exportsForLibrary.values); | 58 exports[path] = new List.from(exportsForLibrary.values); |
59 exports[path].map((directive) => directive.path).forEach(traverse); | 59 exports[path].map((directive) => directive.path).forEach(traverse); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 /// A simple visitor that collects import and export nodes. | 289 /// A simple visitor that collects import and export nodes. |
290 class _ImportExportCollector extends GeneralizingASTVisitor { | 290 class _ImportExportCollector extends GeneralizingASTVisitor { |
291 final imports = <ImportDirective>[]; | 291 final imports = <ImportDirective>[]; |
292 final exports = <ExportDirective>[]; | 292 final exports = <ExportDirective>[]; |
293 | 293 |
294 _ImportExportCollector(); | 294 _ImportExportCollector(); |
295 | 295 |
296 visitImportDirective(ImportDirective node) => imports.add(node); | 296 visitImportDirective(ImportDirective node) => imports.add(node); |
297 visitExportDirective(ExportDirective node) => exports.add(node); | 297 visitExportDirective(ExportDirective node) => exports.add(node); |
298 } | 298 } |
OLD | NEW |