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 analysis.server; | 5 library analysis.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:math' show max; | 9 import 'dart:math' show max; |
10 | 10 |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 if (_onAnalysisCompleteCompleter != null) { | 726 if (_onAnalysisCompleteCompleter != null) { |
727 _onAnalysisCompleteCompleter.complete(); | 727 _onAnalysisCompleteCompleter.complete(); |
728 _onAnalysisCompleteCompleter = null; | 728 _onAnalysisCompleteCompleter = null; |
729 } | 729 } |
730 ServerPerformanceStatistics.idle.makeCurrent(); | 730 ServerPerformanceStatistics.idle.makeCurrent(); |
731 } | 731 } |
732 } | 732 } |
733 } | 733 } |
734 | 734 |
735 /** | 735 /** |
736 * Trigger reanalysis of all files from disk. | 736 * Trigger reanalysis of all files in the given list of analysis [roots], or |
737 * everything if the analysis roots is `null`. | |
737 */ | 738 */ |
738 void reanalyze() { | 739 void reanalyze(List<Resource> roots) { |
739 // Clear any operations that are pending. | 740 // Clear any operations that are pending. |
740 operationQueue.clear(); | 741 if (roots == null) { |
742 operationQueue.clear(); | |
743 } else { | |
744 for (AnalysisContext context in _getContexts(roots)) { | |
745 operationQueue.contextRemoved(context); | |
746 } | |
747 } | |
741 // Instruct the contextDirectoryManager to rebuild all contexts from | 748 // Instruct the contextDirectoryManager to rebuild all contexts from |
742 // scratch. | 749 // scratch. |
743 contextDirectoryManager.refresh(); | 750 contextDirectoryManager.refresh(roots); |
744 } | 751 } |
745 | 752 |
746 /** | 753 /** |
747 * Schedules execution of the given [ServerOperation]. | 754 * Schedules execution of the given [ServerOperation]. |
748 */ | 755 */ |
749 void scheduleOperation(ServerOperation operation) { | 756 void scheduleOperation(ServerOperation operation) { |
750 addOperation(operation); | 757 addOperation(operation); |
751 _schedulePerformOperation(); | 758 _schedulePerformOperation(); |
752 } | 759 } |
753 | 760 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 // | 1096 // |
1090 // Update the defaults used to create new contexts. | 1097 // Update the defaults used to create new contexts. |
1091 // | 1098 // |
1092 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions; | 1099 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions; |
1093 optionUpdaters.forEach((OptionUpdater optionUpdater) { | 1100 optionUpdaters.forEach((OptionUpdater optionUpdater) { |
1094 optionUpdater(options); | 1101 optionUpdater(options); |
1095 }); | 1102 }); |
1096 } | 1103 } |
1097 | 1104 |
1098 /** | 1105 /** |
1106 * Return a set of contexts containing all of the resources in the given list | |
1107 * of [resources]. | |
1108 */ | |
1109 Set<AnalysisContext> _getContexts(List<Resource> resources) { | |
1110 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); | |
1111 resources.forEach((Resource resource) { | |
1112 AnalysisContext context = getContainingContext(resource.path); | |
scheglov
2015/03/30 20:38:07
There might be more that one context in a root.
I
Brian Wilkerson
2015/03/30 21:01:25
Yes, of course. I was thinking backward.
| |
1113 if (context != null) { | |
1114 contexts.add(context); | |
1115 } | |
1116 }); | |
1117 return contexts; | |
1118 } | |
1119 | |
1120 /** | |
1099 * Returns the [CompilationUnit] of the Dart file with the given [source] that | 1121 * Returns the [CompilationUnit] of the Dart file with the given [source] that |
1100 * should be used to resend notifications for already resolved unit. | 1122 * should be used to resend notifications for already resolved unit. |
1101 * Returns `null` if the file is not a part of any context, library has not | 1123 * Returns `null` if the file is not a part of any context, library has not |
1102 * been yet resolved, or any problem happened. | 1124 * been yet resolved, or any problem happened. |
1103 */ | 1125 */ |
1104 CompilationUnit _getResolvedCompilationUnitToResendNotification( | 1126 CompilationUnit _getResolvedCompilationUnitToResendNotification( |
1105 AnalysisContext context, Source source) { | 1127 AnalysisContext context, Source source) { |
1106 List<Source> librarySources = context.getLibrariesContaining(source); | 1128 List<Source> librarySources = context.getLibrariesContaining(source); |
1107 if (librarySources.isEmpty) { | 1129 if (librarySources.isEmpty) { |
1108 return null; | 1130 return null; |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 /** | 1445 /** |
1424 * The [PerformanceTag] for time spent in server request handlers. | 1446 * The [PerformanceTag] for time spent in server request handlers. |
1425 */ | 1447 */ |
1426 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1448 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
1427 | 1449 |
1428 /** | 1450 /** |
1429 * The [PerformanceTag] for time spent in split store microtasks. | 1451 * The [PerformanceTag] for time spent in split store microtasks. |
1430 */ | 1452 */ |
1431 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1453 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1432 } | 1454 } |
OLD | NEW |