| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 ChangeSet changeSet = new ChangeSet(); | 459 ChangeSet changeSet = new ChangeSet(); |
| 460 extractedSources.forEach((path, source) { | 460 extractedSources.forEach((path, source) { |
| 461 oldInfo.sources.remove(path); | 461 oldInfo.sources.remove(path); |
| 462 changeSet.removedSource(source); | 462 changeSet.removedSource(source); |
| 463 }); | 463 }); |
| 464 applyChangesToContext(oldInfo.folder, changeSet); | 464 applyChangesToContext(oldInfo.folder, changeSet); |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 | 467 |
| 468 void _handleWatchEvent(Folder folder, _ContextInfo info, WatchEvent event) { | 468 void _handleWatchEvent(Folder folder, _ContextInfo info, WatchEvent event) { |
| 469 // TODO(brianwilkerson) If a file is explicitly included in one context |
| 470 // but implicitly referenced in another context, we will only send a |
| 471 // changeSet to the context that explicitly includes the file (because |
| 472 // that's the only context that's watching the file). |
| 469 _instrumentationService.logWatchEvent( | 473 _instrumentationService.logWatchEvent( |
| 470 folder.path, event.path, event.type.toString()); | 474 folder.path, event.path, event.type.toString()); |
| 471 String path = event.path; | 475 String path = event.path; |
| 472 // maybe excluded globally | 476 // maybe excluded globally |
| 473 if (_isExcluded(path)) { | 477 if (_isExcluded(path)) { |
| 474 return; | 478 return; |
| 475 } | 479 } |
| 476 // maybe excluded from the context, so other context will handle it | 480 // maybe excluded from the context, so other context will handle it |
| 477 if (info.excludes(path)) { | 481 if (info.excludes(path)) { |
| 478 return; | 482 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 502 info.sources[path] = source; | 506 info.sources[path] = source; |
| 503 } | 507 } |
| 504 } | 508 } |
| 505 break; | 509 break; |
| 506 case ChangeType.REMOVE: | 510 case ChangeType.REMOVE: |
| 507 // pubspec was removed, merge the context into its parent | 511 // pubspec was removed, merge the context into its parent |
| 508 if (info.isPubspec(path) && !info.isRoot) { | 512 if (info.isPubspec(path) && !info.isRoot) { |
| 509 _mergeContext(info); | 513 _mergeContext(info); |
| 510 return; | 514 return; |
| 511 } | 515 } |
| 512 Source source = info.sources[path]; | 516 List<Source> sources = info.context.getSourcesWithFullName(path); |
| 513 if (source != null) { | 517 if (!sources.isEmpty) { |
| 514 ChangeSet changeSet = new ChangeSet(); | 518 ChangeSet changeSet = new ChangeSet(); |
| 515 changeSet.removedSource(source); | 519 sources.forEach((Source source) { |
| 520 changeSet.removedSource(source); |
| 521 }); |
| 516 applyChangesToContext(folder, changeSet); | 522 applyChangesToContext(folder, changeSet); |
| 517 info.sources.remove(path); | 523 info.sources.remove(path); |
| 518 } | 524 } |
| 519 break; | 525 break; |
| 520 case ChangeType.MODIFY: | 526 case ChangeType.MODIFY: |
| 521 Source source = info.sources[path]; | 527 List<Source> sources = info.context.getSourcesWithFullName(path); |
| 522 if (source != null) { | 528 if (!sources.isEmpty) { |
| 523 ChangeSet changeSet = new ChangeSet(); | 529 ChangeSet changeSet = new ChangeSet(); |
| 524 changeSet.changedSource(source); | 530 sources.forEach((Source source) { |
| 531 changeSet.changedSource(source); |
| 532 }); |
| 525 applyChangesToContext(folder, changeSet); | 533 applyChangesToContext(folder, changeSet); |
| 526 } | 534 } |
| 527 break; | 535 break; |
| 528 } | 536 } |
| 529 | 537 |
| 530 if (info.packageMapDependencies.contains(path)) { | 538 if (info.packageMapDependencies.contains(path)) { |
| 531 _recomputePackageUriResolver(info); | 539 _recomputePackageUriResolver(info); |
| 532 } | 540 } |
| 533 } | 541 } |
| 534 | 542 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 return excludes(resource.path); | 718 return excludes(resource.path); |
| 711 } | 719 } |
| 712 | 720 |
| 713 /** | 721 /** |
| 714 * Returns `true` if [path] is the pubspec file of this context. | 722 * Returns `true` if [path] is the pubspec file of this context. |
| 715 */ | 723 */ |
| 716 bool isPubspec(String path) { | 724 bool isPubspec(String path) { |
| 717 return path == pubspecPath; | 725 return path == pubspecPath; |
| 718 } | 726 } |
| 719 } | 727 } |
| OLD | NEW |