| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 * Rebuild the set of contexts from scratch based on the data last sent to | 166 * Rebuild the set of contexts from scratch based on the data last sent to |
| 167 * setRoots(). | 167 * setRoots(). Only contexts contained in the given list of analysis [roots] |
| 168 * will be rebuilt, unless the list is `null`, in which case every context |
| 169 * will be rebuilt. |
| 168 */ | 170 */ |
| 169 void refresh() { | 171 void refresh(List<Resource> roots) { |
| 170 // Destroy old contexts | 172 // Destroy old contexts |
| 171 List<Folder> contextFolders = _contexts.keys.toList(); | 173 List<Folder> contextFolders = _contexts.keys.toList(); |
| 172 contextFolders.forEach(_destroyContext); | 174 if (roots == null) { |
| 175 contextFolders.forEach(_destroyContext); |
| 176 } else { |
| 177 roots.forEach((Resource resource) { |
| 178 contextFolders.forEach((Folder contextFolder) { |
| 179 if (resource is Folder && resource.isOrContains(contextFolder.path)) { |
| 180 _destroyContext(contextFolder); |
| 181 } |
| 182 }); |
| 183 }); |
| 184 } |
| 173 | 185 |
| 174 // Rebuild contexts based on the data last sent to setRoots(). | 186 // Rebuild contexts based on the data last sent to setRoots(). |
| 175 setRoots(includedPaths, excludedPaths, packageRoots); | 187 setRoots(includedPaths, excludedPaths, packageRoots); |
| 176 } | 188 } |
| 177 | 189 |
| 178 /** | 190 /** |
| 179 * Remove the context associated with the given [folder]. | 191 * Remove the context associated with the given [folder]. |
| 180 */ | 192 */ |
| 181 void removeContext(Folder folder); | 193 void removeContext(Folder folder); |
| 182 | 194 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 return excludes(resource.path); | 763 return excludes(resource.path); |
| 752 } | 764 } |
| 753 | 765 |
| 754 /** | 766 /** |
| 755 * Returns `true` if [path] is the pubspec file of this context. | 767 * Returns `true` if [path] is the pubspec file of this context. |
| 756 */ | 768 */ |
| 757 bool isPubspec(String path) { | 769 bool isPubspec(String path) { |
| 758 return path == pubspecPath; | 770 return path == pubspecPath; |
| 759 } | 771 } |
| 760 } | 772 } |
| OLD | NEW |