| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 services.dependencies.reachable_source_collector; | 5 library services.dependencies.reachable_source_collector; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 /// Collect reachable sources. | 29 /// Collect reachable sources. |
| 30 Map<String, List<String>> collectSources() { | 30 Map<String, List<String>> collectSources() { |
| 31 _addDependencies(source); | 31 _addDependencies(source); |
| 32 return _sourceMap; | 32 return _sourceMap; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void _addDependencies(Source source) { | 35 void _addDependencies(Source source) { |
| 36 | |
| 37 String sourceUri = source.uri.toString(); | 36 String sourceUri = source.uri.toString(); |
| 38 | 37 |
| 39 // Careful not to revisit. | 38 // Careful not to revisit. |
| 40 if (_sourceMap[source.uri.toString()] != null) { | 39 if (_sourceMap[source.uri.toString()] != null) { |
| 41 return; | 40 return; |
| 42 } | 41 } |
| 43 | 42 |
| 44 List<Source> sources = <Source>[]; | 43 List<Source> sources = <Source>[]; |
| 45 sources.addAll(context.computeResult(source, IMPORTED_LIBRARIES)); | 44 sources.addAll(context.computeResult(source, IMPORTED_LIBRARIES)); |
| 46 sources.addAll(context.computeResult(source, EXPORTED_LIBRARIES)); | 45 sources.addAll(context.computeResult(source, EXPORTED_LIBRARIES)); |
| 47 | 46 |
| 48 _sourceMap[sourceUri] = | 47 _sourceMap[sourceUri] = |
| 49 sources.map((source) => source.uri.toString()).toList(); | 48 sources.map((source) => source.uri.toString()).toList(); |
| 50 | 49 |
| 51 sources.forEach((s) => _addDependencies(s)); | 50 sources.forEach((s) => _addDependencies(s)); |
| 52 } | 51 } |
| 53 } | 52 } |
| OLD | NEW |