| 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 | 9 |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 for (Folder root in _contexts.keys) { | 156 for (Folder root in _contexts.keys) { |
| 157 if (root.contains(path)) { | 157 if (root.contains(path)) { |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 // no | 161 // no |
| 162 return false; | 162 return false; |
| 163 } | 163 } |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * Return a list containing all of the contexts contained in the given |
| 167 * [analysisRoot]. |
| 168 */ |
| 169 List<AnalysisContext> contextsInAnalysisRoot(Folder analysisRoot) { |
| 170 List<AnalysisContext> contexts = <AnalysisContext>[]; |
| 171 _contexts.forEach((Folder contextFolder, _ContextInfo info) { |
| 172 if (analysisRoot.isOrContains(contextFolder.path)) { |
| 173 contexts.add(info.context); |
| 174 } |
| 175 }); |
| 176 return contexts; |
| 177 } |
| 178 |
| 179 /** |
| 166 * Rebuild the set of contexts from scratch based on the data last sent to | 180 * Rebuild the set of contexts from scratch based on the data last sent to |
| 167 * setRoots(). | 181 * setRoots(). Only contexts contained in the given list of analysis [roots] |
| 182 * will be rebuilt, unless the list is `null`, in which case every context |
| 183 * will be rebuilt. |
| 168 */ | 184 */ |
| 169 void refresh() { | 185 void refresh(List<Resource> roots) { |
| 170 // Destroy old contexts | 186 // Destroy old contexts |
| 171 List<Folder> contextFolders = _contexts.keys.toList(); | 187 List<Folder> contextFolders = _contexts.keys.toList(); |
| 172 contextFolders.forEach(_destroyContext); | 188 if (roots == null) { |
| 189 contextFolders.forEach(_destroyContext); |
| 190 } else { |
| 191 roots.forEach((Resource resource) { |
| 192 contextFolders.forEach((Folder contextFolder) { |
| 193 if (resource is Folder && resource.isOrContains(contextFolder.path)) { |
| 194 _destroyContext(contextFolder); |
| 195 } |
| 196 }); |
| 197 }); |
| 198 } |
| 173 | 199 |
| 174 // Rebuild contexts based on the data last sent to setRoots(). | 200 // Rebuild contexts based on the data last sent to setRoots(). |
| 175 setRoots(includedPaths, excludedPaths, packageRoots); | 201 setRoots(includedPaths, excludedPaths, packageRoots); |
| 176 } | 202 } |
| 177 | 203 |
| 178 /** | 204 /** |
| 179 * Remove the context associated with the given [folder]. | 205 * Remove the context associated with the given [folder]. |
| 180 */ | 206 */ |
| 181 void removeContext(Folder folder); | 207 void removeContext(Folder folder); |
| 182 | 208 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 return excludes(resource.path); | 777 return excludes(resource.path); |
| 752 } | 778 } |
| 753 | 779 |
| 754 /** | 780 /** |
| 755 * Returns `true` if [path] is the pubspec file of this context. | 781 * Returns `true` if [path] is the pubspec file of this context. |
| 756 */ | 782 */ |
| 757 bool isPubspec(String path) { | 783 bool isPubspec(String path) { |
| 758 return path == pubspecPath; | 784 return path == pubspecPath; |
| 759 } | 785 } |
| 760 } | 786 } |
| OLD | NEW |