| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 break; | 145 break; |
| 146 } | 146 } |
| 147 Resource resource = resourceProvider.getResource(event.path); | 147 Resource resource = resourceProvider.getResource(event.path); |
| 148 // If the file went away and was replaced by a folder before we | 148 // If the file went away and was replaced by a folder before we |
| 149 // had a chance to process the event, resource might be a Folder. In | 149 // had a chance to process the event, resource might be a Folder. In |
| 150 // that case don't add it. | 150 // that case don't add it. |
| 151 if (resource is File) { | 151 if (resource is File) { |
| 152 File file = resource; | 152 File file = resource; |
| 153 if (_shouldFileBeAnalyzed(file)) { | 153 if (_shouldFileBeAnalyzed(file)) { |
| 154 ChangeSet changeSet = new ChangeSet(); | 154 ChangeSet changeSet = new ChangeSet(); |
| 155 Source source = file.createSource(UriKind.FILE_URI); | 155 Source source = file.createSource(); |
| 156 changeSet.addedSource(source); | 156 changeSet.addedSource(source); |
| 157 applyChangesToContext(folder, changeSet); | 157 applyChangesToContext(folder, changeSet); |
| 158 info.sources[event.path]= source; | 158 info.sources[event.path]= source; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 break; | 161 break; |
| 162 case ChangeType.REMOVE: | 162 case ChangeType.REMOVE: |
| 163 Source source = info.sources[event.path]; | 163 Source source = info.sources[event.path]; |
| 164 if (source != null) { | 164 if (source != null) { |
| 165 ChangeSet changeSet = new ChangeSet(); | 165 ChangeSet changeSet = new ChangeSet(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 /** | 207 /** |
| 208 * Resursively adds all Dart and HTML files to the [changeSet]. | 208 * Resursively adds all Dart and HTML files to the [changeSet]. |
| 209 */ | 209 */ |
| 210 static void _addSourceFiles(ChangeSet changeSet, Folder folder, _ContextDirect
oryInfo info) { | 210 static void _addSourceFiles(ChangeSet changeSet, Folder folder, _ContextDirect
oryInfo info) { |
| 211 List<Resource> children = folder.getChildren(); | 211 List<Resource> children = folder.getChildren(); |
| 212 for (Resource child in children) { | 212 for (Resource child in children) { |
| 213 if (child is File) { | 213 if (child is File) { |
| 214 if (_shouldFileBeAnalyzed(child)) { | 214 if (_shouldFileBeAnalyzed(child)) { |
| 215 Source source = child.createSource(UriKind.FILE_URI); | 215 Source source = child.createSource(); |
| 216 changeSet.addedSource(source); | 216 changeSet.addedSource(source); |
| 217 info.sources[child.path] = source; | 217 info.sources[child.path] = source; |
| 218 } | 218 } |
| 219 } else if (child is Folder) { | 219 } else if (child is Folder) { |
| 220 if (child.shortName == 'packages') { | 220 if (child.shortName == 'packages') { |
| 221 // TODO(paulberry): perhaps we should only skip packages dirs if | 221 // TODO(paulberry): perhaps we should only skip packages dirs if |
| 222 // there is a pubspec.yaml? | 222 // there is a pubspec.yaml? |
| 223 continue; | 223 continue; |
| 224 } | 224 } |
| 225 _addSourceFiles(changeSet, child, info); | 225 _addSourceFiles(changeSet, child, info); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 256 * Remove the context associated with the given [folder]. | 256 * Remove the context associated with the given [folder]. |
| 257 */ | 257 */ |
| 258 void removeContext(Folder folder); | 258 void removeContext(Folder folder); |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * Called when the package map for a context has changed. | 261 * Called when the package map for a context has changed. |
| 262 */ | 262 */ |
| 263 void updateContextPackageMap(Folder contextFolder, | 263 void updateContextPackageMap(Folder contextFolder, |
| 264 Map<String, List<Folder>> packageMap); | 264 Map<String, List<Folder>> packageMap); |
| 265 } | 265 } |
| OLD | NEW |