Chromium Code Reviews| 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:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 // no | 93 // no |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Remove the context associated with the given [folder]. | 98 * Remove the context associated with the given [folder]. |
| 99 */ | 99 */ |
| 100 void removeContext(Folder folder); | 100 void removeContext(Folder folder); |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * Rebuild the set of contexts from scratch based on the data last sent to | |
| 104 * setRoots(). | |
| 105 */ | |
| 106 void refresh() { | |
| 107 List<Folder> contextFolders = _contexts.keys.toList(); | |
| 108 // destroy old contexts | |
| 109 contextFolders.forEach(_destroyContext); | |
| 110 // create new contexts, but skip any that are contained inside a parent | |
| 111 // context (those will be automatically created upon creation of the | |
| 112 // parent). | |
| 113 for (Folder newFolder in contextFolders) { | |
|
scheglov
2014/09/10 01:55:54
With this implementation we trust that we have a v
Paul Berry
2014/09/10 18:26:12
Fair enough. I've reworked things so that we acco
| |
| 114 bool insideAnotherFolder = contextFolders.any((folder) { | |
| 115 return folder.path != newFolder.path && | |
| 116 folder.isOrContains(newFolder.path); | |
|
scheglov
2014/09/10 01:55:54
Will folder.contains(newFolder.path) replace both
Paul Berry
2014/09/10 18:26:11
Acknowledged. This code is gone now.
| |
| 117 }); | |
| 118 if (!insideAnotherFolder) { | |
| 119 _createContexts(newFolder, false); | |
| 120 } | |
| 121 } | |
| 122 } | |
| 123 | |
| 124 /** | |
| 103 * Change the set of paths which should be used as starting points to | 125 * Change the set of paths which should be used as starting points to |
| 104 * determine the context directories. | 126 * determine the context directories. |
| 105 */ | 127 */ |
| 106 void setRoots(List<String> includedPaths, List<String> excludedPaths) { | 128 void setRoots(List<String> includedPaths, List<String> excludedPaths) { |
| 107 List<Folder> contextFolders = _contexts.keys.toList(); | 129 List<Folder> contextFolders = _contexts.keys.toList(); |
| 108 // included | 130 // included |
| 109 Set<Folder> includedFolders = new HashSet<Folder>(); | 131 Set<Folder> includedFolders = new HashSet<Folder>(); |
| 110 for (int i = 0; i < includedPaths.length; i++) { | 132 for (int i = 0; i < includedPaths.length; i++) { |
| 111 String path = includedPaths[i]; | 133 String path = includedPaths[i]; |
| 112 Resource resource = resourceProvider.getResource(path); | 134 Resource resource = resourceProvider.getResource(path); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 return excludes(resource.path); | 582 return excludes(resource.path); |
| 561 } | 583 } |
| 562 | 584 |
| 563 /** | 585 /** |
| 564 * Returns `true` if [path] is the pubspec file of this context. | 586 * Returns `true` if [path] is the pubspec file of this context. |
| 565 */ | 587 */ |
| 566 bool isPubspec(String path) { | 588 bool isPubspec(String path) { |
| 567 return path == pubspecPath; | 589 return path == pubspecPath; |
| 568 } | 590 } |
| 569 } | 591 } |
| OLD | NEW |