| 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 | 8 |
| 9 import 'package:analysis_server/src/resource.dart'; | 9 import 'package:analysis_server/src/resource.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 throw new UnimplementedError( | 73 throw new UnimplementedError( |
| 74 'Excluded paths are not supported yet'); | 74 'Excluded paths are not supported yet'); |
| 75 } | 75 } |
| 76 Set<Folder> excludedFolders = new Set<Folder>(); | 76 Set<Folder> excludedFolders = new Set<Folder>(); |
| 77 // diff | 77 // diff |
| 78 Set<Folder> currentFolders = _currentDirectoryInfo.keys.toSet(); | 78 Set<Folder> currentFolders = _currentDirectoryInfo.keys.toSet(); |
| 79 Set<Folder> newFolders = includedFolders.difference(currentFolders); | 79 Set<Folder> newFolders = includedFolders.difference(currentFolders); |
| 80 Set<Folder> oldFolders = currentFolders.difference(includedFolders); | 80 Set<Folder> oldFolders = currentFolders.difference(includedFolders); |
| 81 // remove old contexts | 81 // remove old contexts |
| 82 for (Folder folder in oldFolders) { | 82 for (Folder folder in oldFolders) { |
| 83 // TODO(scheglov) implement | 83 _currentDirectoryInfo.remove(folder); |
| 84 removeContext(folder); |
| 84 } | 85 } |
| 85 // add new contexts | 86 // add new contexts |
| 86 for (Folder folder in newFolders) { | 87 for (Folder folder in newFolders) { |
| 87 _ContextDirectoryInfo info = new _ContextDirectoryInfo(); | 88 _ContextDirectoryInfo info = new _ContextDirectoryInfo(); |
| 88 _currentDirectoryInfo[folder] = info; | 89 _currentDirectoryInfo[folder] = info; |
| 89 info.changeSubscription = folder.changes.listen((WatchEvent event) { | 90 info.changeSubscription = folder.changes.listen((WatchEvent event) { |
| 90 _handleWatchEvent(folder, info, event); | 91 _handleWatchEvent(folder, info, event); |
| 91 }); | 92 }); |
| 92 File pubspecFile = folder.getChild('pubspec.yaml'); | 93 File pubspecFile = folder.getChild('pubspec.yaml'); |
| 93 addContext(folder, pubspecFile.exists ? pubspecFile : null); | 94 addContext(folder, pubspecFile.exists ? pubspecFile : null); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 * otherwise it is null. | 187 * otherwise it is null. |
| 187 */ | 188 */ |
| 188 void addContext(Folder folder, File pubspecFile); | 189 void addContext(Folder folder, File pubspecFile); |
| 189 | 190 |
| 190 /** | 191 /** |
| 191 * Called when the set of files associated with a context have changed (or | 192 * Called when the set of files associated with a context have changed (or |
| 192 * some of those files have been modified). [changeSet] is the set of | 193 * some of those files have been modified). [changeSet] is the set of |
| 193 * changes that need to be applied to the context. | 194 * changes that need to be applied to the context. |
| 194 */ | 195 */ |
| 195 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); | 196 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet); |
| 196 } | 197 |
| 198 /** |
| 199 * Remove the context associated with the given [folder]. |
| 200 */ |
| 201 void removeContext(Folder folder); |
| 202 } |
| OLD | NEW |