Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: pkg/analysis_server/lib/src/operation/operation_analysis.dart

Issue 869153003: Prioritize analysis operations for contexts with priority files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 operation.analysis; 5 library operation.analysis;
6 6
7 import 'package:analysis_server/src/analysis_server.dart'; 7 import 'package:analysis_server/src/analysis_server.dart';
8 import 'package:analysis_server/src/computer/computer_highlights.dart'; 8 import 'package:analysis_server/src/computer/computer_highlights.dart';
9 import 'package:analysis_server/src/computer/computer_navigation.dart'; 9 import 'package:analysis_server/src/computer/computer_navigation.dart';
10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; 10 import 'package:analysis_server/src/computer/computer_occurrences.dart';
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 104
105 /** 105 /**
106 * Instances of [PerformAnalysisOperation] perform a single analysis task. 106 * Instances of [PerformAnalysisOperation] perform a single analysis task.
107 */ 107 */
108 class PerformAnalysisOperation extends ServerOperation { 108 class PerformAnalysisOperation extends ServerOperation {
109 static const int IDLE_CACHE_SIZE = AnalysisOptionsImpl.DEFAULT_CACHE_SIZE; 109 static const int IDLE_CACHE_SIZE = AnalysisOptionsImpl.DEFAULT_CACHE_SIZE;
110 static const int WORKING_CACHE_SIZE = 512; 110 static const int WORKING_CACHE_SIZE = 512;
111 111
112 final AnalysisContext context; 112 final AnalysisContext context;
113 final bool isPriority;
114 final bool isContinue; 113 final bool isContinue;
115 114
116 PerformAnalysisOperation(this.context, this.isPriority, this.isContinue); 115 PerformAnalysisOperation(this.context, this.isContinue);
117 116
118 @override 117 @override
119 ServerOperationPriority get priority { 118 ServerOperationPriority get priority {
120 if (isPriority) { 119 if (_isPriorityContext) {
121 if (isContinue) { 120 if (isContinue) {
122 return ServerOperationPriority.PRIORITY_ANALYSIS_CONTINUE; 121 return ServerOperationPriority.PRIORITY_ANALYSIS_CONTINUE;
123 } else { 122 } else {
124 return ServerOperationPriority.PRIORITY_ANALYSIS; 123 return ServerOperationPriority.PRIORITY_ANALYSIS;
125 } 124 }
126 } else { 125 } else {
127 if (isContinue) { 126 if (isContinue) {
128 return ServerOperationPriority.ANALYSIS_CONTINUE; 127 return ServerOperationPriority.ANALYSIS_CONTINUE;
129 } else { 128 } else {
130 return ServerOperationPriority.ANALYSIS; 129 return ServerOperationPriority.ANALYSIS;
131 } 130 }
132 } 131 }
133 } 132 }
134 133
134 bool get _isPriorityContext =>
135 context is InternalAnalysisContext &&
136 (context as InternalAnalysisContext).prioritySources.isNotEmpty;
137
135 @override 138 @override
136 void perform(AnalysisServer server) { 139 void perform(AnalysisServer server) {
137 // 140 //
138 // TODO(brianwilkerson) Add an optional function-valued parameter to 141 // TODO(brianwilkerson) Add an optional function-valued parameter to
139 // performAnalysisTask that will be called when the task has been computed 142 // performAnalysisTask that will be called when the task has been computed
140 // but before it is performed and send notification in the function: 143 // but before it is performed and send notification in the function:
141 // 144 //
142 // AnalysisResult result = context.performAnalysisTask((taskDescription) { 145 // AnalysisResult result = context.performAnalysisTask((taskDescription) {
143 // sendStatusNotification(context.toString(), taskDescription); 146 // sendStatusNotification(context.toString(), taskDescription);
144 // }); 147 // });
145 if (!isContinue) { 148 if (!isContinue) {
146 _setCacheSize(WORKING_CACHE_SIZE); 149 _setCacheSize(WORKING_CACHE_SIZE);
147 } 150 }
148 // prepare results 151 // prepare results
149 AnalysisResult result = context.performAnalysisTask(); 152 AnalysisResult result = context.performAnalysisTask();
150 List<ChangeNotice> notices = result.changeNotices; 153 List<ChangeNotice> notices = result.changeNotices;
151 if (notices == null) { 154 if (notices == null) {
152 _setCacheSize(IDLE_CACHE_SIZE); 155 _setCacheSize(IDLE_CACHE_SIZE);
153 server.sendContextAnalysisDoneNotifications( 156 server.sendContextAnalysisDoneNotifications(
154 context, 157 context,
155 AnalysisDoneReason.COMPLETE); 158 AnalysisDoneReason.COMPLETE);
156 return; 159 return;
157 } 160 }
158 // process results 161 // process results
159 _sendNotices(server, notices); 162 _sendNotices(server, notices);
160 _updateIndex(server, notices); 163 _updateIndex(server, notices);
161 // continue analysis 164 // continue analysis
162 server.addOperation( 165 server.addOperation(new PerformAnalysisOperation(context, true));
163 new PerformAnalysisOperation(context, isPriority, true));
164 } 166 }
165 167
166 /** 168 /**
167 * Send the information in the given list of notices back to the client. 169 * Send the information in the given list of notices back to the client.
168 */ 170 */
169 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { 171 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) {
170 for (int i = 0; i < notices.length; i++) { 172 for (int i = 0; i < notices.length; i++) {
171 ChangeNotice notice = notices[i]; 173 ChangeNotice notice = notices[i];
172 Source source = notice.source; 174 Source source = notice.source;
173 String file = source.fullName; 175 String file = source.fullName;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 @override 371 @override
370 ServerOperationPriority get priority { 372 ServerOperationPriority get priority {
371 return ServerOperationPriority.ANALYSIS_NOTIFICATION; 373 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
372 } 374 }
373 375
374 @override 376 @override
375 void perform(AnalysisServer server) { 377 void perform(AnalysisServer server) {
376 sendAnalysisNotificationErrors(server, file, lineInfo, errors); 378 sendAnalysisNotificationErrors(server, file, lineInfo, errors);
377 } 379 }
378 } 380 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/operation/operation_queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698