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.library; | 5 library services.dependencies.library; |
6 | 6 |
7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
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'; |
11 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
12 | 12 |
13 class LibraryDependencyCollector { | 13 class LibraryDependencyCollector { |
14 final Set<LibraryElement> _visitedLibraries = new Set<LibraryElement>(); | 14 final Set<LibraryElement> _visitedLibraries = new Set<LibraryElement>(); |
15 final Set<String> _dependencies = new Set<String>(); | 15 final Set<String> _dependencies = new Set<String>(); |
16 | 16 |
17 final List<AnalysisContext> _contexts; | 17 final Iterable<AnalysisContext> _contexts; |
18 | 18 |
19 LibraryDependencyCollector(this._contexts); | 19 LibraryDependencyCollector(this._contexts); |
20 | 20 |
21 Map<String, Map<String, List<String>>> calculatePackageMap( | 21 Map<String, Map<String, List<String>>> calculatePackageMap( |
22 Map<Folder, AnalysisContext> folderMap) { | 22 Map<Folder, AnalysisContext> folderMap) { |
23 Map<AnalysisContext, Folder> contextMap = _reverse(folderMap); | 23 Map<AnalysisContext, Folder> contextMap = _reverse(folderMap); |
24 Map<String, Map<String, List<String>>> result = | 24 Map<String, Map<String, List<String>>> result = |
25 new Map<String, Map<String, List<String>>>(); | 25 new Map<String, Map<String, List<String>>>(); |
26 for (AnalysisContext context in _contexts) { | 26 for (AnalysisContext context in _contexts) { |
27 Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap; | 27 Map<String, List<Folder>> packageMap = context.sourceFactory.packageMap; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 Map<AnalysisContext, Folder> _reverse(Map<Folder, AnalysisContext> map) { | 63 Map<AnalysisContext, Folder> _reverse(Map<Folder, AnalysisContext> map) { |
64 Map<AnalysisContext, Folder> reverseMap = | 64 Map<AnalysisContext, Folder> reverseMap = |
65 new Map<AnalysisContext, Folder>(); | 65 new Map<AnalysisContext, Folder>(); |
66 map.forEach((Folder f, AnalysisContext c) => reverseMap[c] = f); | 66 map.forEach((Folder f, AnalysisContext c) => reverseMap[c] = f); |
67 return reverseMap; | 67 return reverseMap; |
68 } | 68 } |
69 } | 69 } |
OLD | NEW |