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:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 437 } | 437 } |
| 438 | 438 |
| 439 /** | 439 /** |
| 440 * Create a new empty context associated with [folder]. | 440 * Create a new empty context associated with [folder]. |
| 441 */ | 441 */ |
| 442 _ContextInfo _createContext( | 442 _ContextInfo _createContext( |
| 443 Folder folder, File pubspecFile, List<_ContextInfo> children) { | 443 Folder folder, File pubspecFile, List<_ContextInfo> children) { |
| 444 _ContextInfo info = new _ContextInfo( | 444 _ContextInfo info = new _ContextInfo( |
| 445 folder, pubspecFile, children, normalizedPackageRoots[folder.path]); | 445 folder, pubspecFile, children, normalizedPackageRoots[folder.path]); |
| 446 _contexts[folder] = info; | 446 _contexts[folder] = info; |
| 447 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); | |
| 448 info.context = addContext(folder, packageUriResolver); | |
| 449 info.context.name = folder.path; | |
| 450 // Subscribe to file changes after context has been set | |
| 451 // so that no changes will be received before we have a context | |
| 452 // (e.g. _computePackageUriResolver throws an exception) | |
|
Paul Berry
2015/06/18 20:24:42
I don't understand why this is necessary. Subscri
danrubel
2015/06/22 11:22:56
Good point. Per discussion I reworked this to add
| |
| 447 info.changeSubscription = folder.changes.listen((WatchEvent event) { | 453 info.changeSubscription = folder.changes.listen((WatchEvent event) { |
| 448 _handleWatchEvent(folder, info, event); | 454 _handleWatchEvent(folder, info, event); |
| 449 }); | 455 }); |
| 450 UriResolver packageUriResolver = _computePackageUriResolver(folder, info); | |
| 451 info.context = addContext(folder, packageUriResolver); | |
| 452 info.context.name = folder.path; | |
| 453 return info; | 456 return info; |
| 454 } | 457 } |
| 455 | 458 |
| 456 /** | 459 /** |
| 457 * Potentially create a new context associated with the given [folder]. | 460 * Potentially create a new context associated with the given [folder]. |
| 458 * | 461 * |
| 459 * If there are subfolders with 'pubspec.yaml' files, separate contexts are | 462 * If there are subfolders with 'pubspec.yaml' files, separate contexts are |
| 460 * created for them and excluded from the context associated with the | 463 * created for them and excluded from the context associated with the |
| 461 * [folder]. | 464 * [folder]. |
| 462 * | 465 * |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 794 return excludes(resource.path); | 797 return excludes(resource.path); |
| 795 } | 798 } |
| 796 | 799 |
| 797 /** | 800 /** |
| 798 * Returns `true` if [path] is the pubspec file of this context. | 801 * Returns `true` if [path] is the pubspec file of this context. |
| 799 */ | 802 */ |
| 800 bool isPubspec(String path) { | 803 bool isPubspec(String path) { |
| 801 return path == pubspecPath; | 804 return path == pubspecPath; |
| 802 } | 805 } |
| 803 } | 806 } |
| OLD | NEW |