| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library mirrors_util; | 5 library mirrors_util; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue, IterableBase; | 7 import 'dart:collection' show Queue, IterableBase; |
| 8 | 8 |
| 9 // TODO(rnystrom): Use "package:" URL (#4968). | 9 // TODO(rnystrom): Use "package:" URL (#4968). |
| 10 import 'mirrors.dart'; | 10 import 'mirrors.dart'; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // * Foo | 152 // * Foo |
| 153 // */ | 153 // */ |
| 154 // as "\nFoo\n" and not as "\nFoo\n ". | 154 // as "\nFoo\n" and not as "\nFoo\n ". |
| 155 sb.write(line); | 155 sb.write(line); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 return sb.toString(); | 158 return sb.toString(); |
| 159 } | 159 } |
| 160 throw new ArgumentError('Invalid comment $comment'); | 160 throw new ArgumentError('Invalid comment $comment'); |
| 161 } | 161 } |
| 162 |
| 163 /** |
| 164 * Returns an iterable over all exports found transitively from [library]. |
| 165 */ |
| 166 Iterable<LibraryDependencyMirror> getExports(LibraryMirror library) { |
| 167 bool isExport(LibraryDependencyMirror mirror) => mirror.isExport; |
| 168 |
| 169 List<LibraryDependencyMirror> exports = <LibraryDependencyMirror>[]; |
| 170 |
| 171 Set<LibraryMirror> seenLibrarySet = new Set<LibraryMirror>(); |
| 172 Queue<LibraryDependencyMirror> pendingExports = |
| 173 new Queue<LibraryDependencyMirror>(); |
| 174 |
| 175 seenLibrarySet.add(library); |
| 176 pendingExports.addAll(library.libraryDependencies.where(isExport)); |
| 177 |
| 178 while (!pendingExports.isEmpty) { |
| 179 LibraryDependencyMirror export = pendingExports.removeFirst(); |
| 180 exports.add(export); |
| 181 LibraryMirror target = export.targetLibrary; |
| 182 if (!seenLibrarySet.contains(target)) { |
| 183 pendingExports.addAll(target.libraryDependencies.where(isExport)); |
| 184 } |
| 185 } |
| 186 return exports; |
| 187 } |
| OLD | NEW |