| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 */ | 54 */ |
| 55 List<String> excludedPaths = <String>[]; | 55 List<String> excludedPaths = <String>[]; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * The list of included paths (folders and files) most recently passed to | 58 * The list of included paths (folders and files) most recently passed to |
| 59 * [setRoots]. | 59 * [setRoots]. |
| 60 */ | 60 */ |
| 61 List<String> includedPaths = <String>[]; | 61 List<String> includedPaths = <String>[]; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * The map of package roots most recently passed to [setRoots]. |
| 65 */ |
| 66 Map<String, String> packageRoots = <String, String>{}; |
| 67 |
| 68 /** |
| 64 * Provider which is used to determine the mapping from package name to | 69 * Provider which is used to determine the mapping from package name to |
| 65 * package folder. | 70 * package folder. |
| 66 */ | 71 */ |
| 67 final PackageMapProvider packageMapProvider; | 72 final PackageMapProvider packageMapProvider; |
| 68 | 73 |
| 69 ContextManager(this.resourceProvider, this.packageMapProvider) { | 74 ContextManager(this.resourceProvider, this.packageMapProvider) { |
| 70 pathContext = resourceProvider.pathContext; | 75 pathContext = resourceProvider.pathContext; |
| 71 } | 76 } |
| 72 | 77 |
| 73 /** | 78 /** |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 /** | 114 /** |
| 110 * Rebuild the set of contexts from scratch based on the data last sent to | 115 * Rebuild the set of contexts from scratch based on the data last sent to |
| 111 * setRoots(). | 116 * setRoots(). |
| 112 */ | 117 */ |
| 113 void refresh() { | 118 void refresh() { |
| 114 // Destroy old contexts | 119 // Destroy old contexts |
| 115 List<Folder> contextFolders = _contexts.keys.toList(); | 120 List<Folder> contextFolders = _contexts.keys.toList(); |
| 116 contextFolders.forEach(_destroyContext); | 121 contextFolders.forEach(_destroyContext); |
| 117 | 122 |
| 118 // Rebuild contexts based on the data last sent to setRoots(). | 123 // Rebuild contexts based on the data last sent to setRoots(). |
| 119 setRoots(includedPaths, excludedPaths); | 124 setRoots(includedPaths, excludedPaths, packageRoots); |
| 120 } | 125 } |
| 121 | 126 |
| 122 /** | 127 /** |
| 123 * Change the set of paths which should be used as starting points to | 128 * Change the set of paths which should be used as starting points to |
| 124 * determine the context directories. | 129 * determine the context directories. |
| 125 */ | 130 */ |
| 126 void setRoots(List<String> includedPaths, List<String> excludedPaths) { | 131 void setRoots(List<String> includedPaths, List<String> excludedPaths, |
| 132 Map<String, String> packageRoots) { |
| 133 // TODO(paulberry): process package roots. |
| 134 this.packageRoots = packageRoots; |
| 127 List<Folder> contextFolders = _contexts.keys.toList(); | 135 List<Folder> contextFolders = _contexts.keys.toList(); |
| 128 // included | 136 // included |
| 129 Set<Folder> includedFolders = new HashSet<Folder>(); | 137 Set<Folder> includedFolders = new HashSet<Folder>(); |
| 130 for (int i = 0; i < includedPaths.length; i++) { | 138 for (int i = 0; i < includedPaths.length; i++) { |
| 131 String path = includedPaths[i]; | 139 String path = includedPaths[i]; |
| 132 Resource resource = resourceProvider.getResource(path); | 140 Resource resource = resourceProvider.getResource(path); |
| 133 if (resource is Folder) { | 141 if (resource is Folder) { |
| 134 includedFolders.add(resource); | 142 includedFolders.add(resource); |
| 135 } else { | 143 } else { |
| 136 // TODO(scheglov) implemented separate files analysis | 144 // TODO(scheglov) implemented separate files analysis |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 return excludes(resource.path); | 589 return excludes(resource.path); |
| 582 } | 590 } |
| 583 | 591 |
| 584 /** | 592 /** |
| 585 * Returns `true` if [path] is the pubspec file of this context. | 593 * Returns `true` if [path] is the pubspec file of this context. |
| 586 */ | 594 */ |
| 587 bool isPubspec(String path) { | 595 bool isPubspec(String path) { |
| 588 return path == pubspecPath; | 596 return path == pubspecPath; |
| 589 } | 597 } |
| 590 } | 598 } |
| OLD | NEW |