OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
(...skipping 28 matching lines...) Expand all Loading... |
39 import 'package:package_config/src/packages_impl.dart' show MapPackages; | 39 import 'package:package_config/src/packages_impl.dart' show MapPackages; |
40 import 'package:path/path.dart' as pathos; | 40 import 'package:path/path.dart' as pathos; |
41 import 'package:watcher/watcher.dart'; | 41 import 'package:watcher/watcher.dart'; |
42 import 'package:yaml/yaml.dart'; | 42 import 'package:yaml/yaml.dart'; |
43 | 43 |
44 /** | 44 /** |
45 * Information tracked by the [ContextManager] for each context. | 45 * Information tracked by the [ContextManager] for each context. |
46 */ | 46 */ |
47 class ContextInfo { | 47 class ContextInfo { |
48 /** | 48 /** |
49 * The [ContextManager] which is tracking this information. | |
50 */ | |
51 final ContextManagerImpl contextManager; | |
52 | |
53 /** | |
54 * The [Folder] for which this information object is created. | 49 * The [Folder] for which this information object is created. |
55 */ | 50 */ |
56 final Folder folder; | 51 final Folder folder; |
57 | 52 |
58 /// The [PathFilter] used to filter sources from being analyzed. | 53 /// The [PathFilter] used to filter sources from being analyzed. |
59 final PathFilter pathFilter; | 54 final PathFilter pathFilter; |
60 | 55 |
61 /** | 56 /** |
62 * The enclosed pubspec-based contexts. | 57 * The enclosed pubspec-based contexts. |
63 */ | 58 */ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 AnalysisContext context; | 90 AnalysisContext context; |
96 | 91 |
97 /** | 92 /** |
98 * Map from full path to the [Source] object, for each source that has been | 93 * Map from full path to the [Source] object, for each source that has been |
99 * added to the context. | 94 * added to the context. |
100 */ | 95 */ |
101 Map<String, Source> sources = new HashMap<String, Source>(); | 96 Map<String, Source> sources = new HashMap<String, Source>(); |
102 | 97 |
103 ContextInfo(ContextManagerImpl contextManager, this.parent, Folder folder, | 98 ContextInfo(ContextManagerImpl contextManager, this.parent, Folder folder, |
104 File packagespecFile, this.packageRoot) | 99 File packagespecFile, this.packageRoot) |
105 : contextManager = contextManager, | 100 : folder = folder, |
106 folder = folder, | |
107 pathFilter = new PathFilter( | 101 pathFilter = new PathFilter( |
108 folder.path, null, contextManager.resourceProvider.pathContext) { | 102 folder.path, null, contextManager.resourceProvider.pathContext) { |
109 packageDescriptionPath = packagespecFile.path; | 103 packageDescriptionPath = packagespecFile.path; |
110 parent.children.add(this); | 104 parent.children.add(this); |
111 } | 105 } |
112 | 106 |
113 /** | 107 /** |
114 * Create the virtual [ContextInfo] which acts as an ancestor to all other | 108 * Create the virtual [ContextInfo] which acts as an ancestor to all other |
115 * [ContextInfo]s. | 109 * [ContextInfo]s. |
116 */ | 110 */ |
117 ContextInfo._root() | 111 ContextInfo._root() |
118 : contextManager = null, | 112 : folder = null, |
119 folder = null, | |
120 pathFilter = null; | 113 pathFilter = null; |
121 | 114 |
122 /** | 115 /** |
123 * Iterate through all [children] and their children, recursively. | 116 * Iterate through all [children] and their children, recursively. |
124 */ | 117 */ |
125 Iterable<ContextInfo> get descendants sync* { | 118 Iterable<ContextInfo> get descendants sync* { |
126 for (ContextInfo child in children) { | 119 for (ContextInfo child in children) { |
127 yield child; | 120 yield child; |
128 yield* child.descendants; | 121 yield* child.descendants; |
129 } | 122 } |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 ResourceProvider resourceProvider) { | 1788 ResourceProvider resourceProvider) { |
1796 if (packages != null) { | 1789 if (packages != null) { |
1797 // Construct package map for the SdkExtUriResolver. | 1790 // Construct package map for the SdkExtUriResolver. |
1798 Map<String, List<Folder>> packageMap = buildPackageMap(resourceProvider); | 1791 Map<String, List<Folder>> packageMap = buildPackageMap(resourceProvider); |
1799 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1792 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
1800 } else { | 1793 } else { |
1801 return const <UriResolver>[]; | 1794 return const <UriResolver>[]; |
1802 } | 1795 } |
1803 } | 1796 } |
1804 } | 1797 } |
OLD | NEW |