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

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

Issue 899753004: Send notificatinos after no-op changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Schedule source analysis only if a change was made Created 5 years, 10 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';
11 import 'package:analysis_server/src/computer/computer_outline.dart'; 11 import 'package:analysis_server/src/computer/computer_outline.dart';
12 import 'package:analysis_server/src/computer/computer_overrides.dart'; 12 import 'package:analysis_server/src/computer/computer_overrides.dart';
13 import 'package:analysis_server/src/operation/operation.dart'; 13 import 'package:analysis_server/src/operation/operation.dart';
14 import 'package:analysis_server/src/protocol_server.dart' as protocol; 14 import 'package:analysis_server/src/protocol_server.dart' as protocol;
15 import 'package:analysis_server/src/services/index/index.dart'; 15 import 'package:analysis_server/src/services/index/index.dart';
16 import 'package:analyzer/src/generated/ast.dart'; 16 import 'package:analyzer/src/generated/ast.dart';
17 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
18 import 'package:analyzer/src/generated/error.dart'; 18 import 'package:analyzer/src/generated/error.dart';
19 import 'package:analyzer/src/generated/html.dart'; 19 import 'package:analyzer/src/generated/html.dart';
20 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
21 21
22 22
23 /**
24 * Schedules sending notifications for the given [file] using the resolved
25 * [resolvedDartUnit].
26 */
27 void scheduleNotificationOperations(AnalysisServer server, String file,
28 LineInfo lineInfo, AnalysisContext context, CompilationUnit parsedDartUnit,
29 CompilationUnit resolvedDartUnit, List<AnalysisError> errors) {
30 // Only send notifications if the current context is the preferred
31 // context for the file. This avoids redundant notification messages
32 // being sent to the client (see dartbug.com/22210).
33 // TODO(paulberry): note that there is a small risk that this will cause
34 // notifications to be lost if the preferred context for a file changes
35 // while analysis is in progress (e.g. because the client sent an
36 // analysis.setAnalysisRoots message).
37 if (server.getAnalysisContext(file) != context) {
38 return;
39 }
40 // Dart
41 CompilationUnit dartUnit =
42 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit;
43 if (resolvedDartUnit != null) {
44 if (server.hasAnalysisSubscription(
45 protocol.AnalysisService.HIGHLIGHTS,
46 file)) {
47 server.scheduleOperation(
48 new _DartHighlightsOperation(file, resolvedDartUnit));
49 }
50 if (server.hasAnalysisSubscription(
51 protocol.AnalysisService.NAVIGATION,
52 file)) {
53 server.scheduleOperation(
54 new _DartNavigationOperation(file, resolvedDartUnit));
55 }
56 if (server.hasAnalysisSubscription(
57 protocol.AnalysisService.OCCURRENCES,
58 file)) {
59 server.scheduleOperation(
60 new _DartOccurrencesOperation(file, resolvedDartUnit));
61 }
62 if (server.hasAnalysisSubscription(
63 protocol.AnalysisService.OVERRIDES,
64 file)) {
65 server.scheduleOperation(
66 new _DartOverridesOperation(file, resolvedDartUnit));
67 }
68 }
69 if (dartUnit != null) {
70 if (server.hasAnalysisSubscription(
71 protocol.AnalysisService.OUTLINE,
72 file)) {
73 server.scheduleOperation(
74 new _DartOutlineOperation(file, lineInfo, dartUnit));
75 }
76 }
77 // errors
78 if (server.shouldSendErrorsNotificationFor(file)) {
79 server.scheduleOperation(
80 new _NotificationErrorsOperation(file, lineInfo, errors));
81 }
82 }
83
84
23 void sendAnalysisNotificationErrors(AnalysisServer server, String file, 85 void sendAnalysisNotificationErrors(AnalysisServer server, String file,
24 LineInfo lineInfo, List<AnalysisError> errors) { 86 LineInfo lineInfo, List<AnalysisError> errors) {
25 try { 87 try {
26 if (errors == null) { 88 if (errors == null) {
27 errors = <AnalysisError>[]; 89 errors = <AnalysisError>[];
28 } 90 }
29 var serverErrors = 91 var serverErrors =
30 protocol.doAnalysisError_listFromEngine(lineInfo, errors); 92 protocol.doAnalysisError_listFromEngine(lineInfo, errors);
31 var params = new protocol.AnalysisErrorsParams(file, serverErrors); 93 var params = new protocol.AnalysisErrorsParams(file, serverErrors);
32 server.sendNotification(params.toNotification()); 94 server.sendNotification(params.toNotification());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 228 }
167 229
168 /** 230 /**
169 * Send the information in the given list of notices back to the client. 231 * Send the information in the given list of notices back to the client.
170 */ 232 */
171 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { 233 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) {
172 for (int i = 0; i < notices.length; i++) { 234 for (int i = 0; i < notices.length; i++) {
173 ChangeNotice notice = notices[i]; 235 ChangeNotice notice = notices[i];
174 Source source = notice.source; 236 Source source = notice.source;
175 String file = source.fullName; 237 String file = source.fullName;
176 // Only send notifications if the current context is the preferred
177 // context for the file. This avoids redundant notification messages
178 // being sent to the client (see dartbug.com/22210).
179 // TODO(paulberry): note that there is a small risk that this will cause
180 // notifications to be lost if the preferred context for a file changes
181 // while analysis is in progress (e.g. because the client sent an
182 // analysis.setAnalysisRoots message).
183 if (server.getAnalysisContext(file) != context) {
184 continue;
185 }
186 // Dart 238 // Dart
187 CompilationUnit parsedDartUnit = notice.parsedDartUnit; 239 CompilationUnit parsedDartUnit = notice.parsedDartUnit;
188 CompilationUnit resolvedDartUnit = notice.resolvedDartUnit; 240 CompilationUnit resolvedDartUnit = notice.resolvedDartUnit;
189 CompilationUnit dartUnit = 241 scheduleNotificationOperations(
190 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit; 242 server,
191 if (resolvedDartUnit != null) { 243 file,
192 if (server.hasAnalysisSubscription( 244 notice.lineInfo,
193 protocol.AnalysisService.HIGHLIGHTS, 245 context,
194 file)) { 246 parsedDartUnit,
195 server.addOperation( 247 resolvedDartUnit,
196 new _DartHighlightsOperation(file, resolvedDartUnit)); 248 notice.errors);
197 }
198 if (server.hasAnalysisSubscription(
199 protocol.AnalysisService.NAVIGATION,
200 file)) {
201 server.addOperation(
202 new _DartNavigationOperation(file, resolvedDartUnit));
203 }
204 if (server.hasAnalysisSubscription(
205 protocol.AnalysisService.OCCURRENCES,
206 file)) {
207 server.addOperation(
208 new _DartOccurrencesOperation(file, resolvedDartUnit));
209 }
210 if (server.hasAnalysisSubscription(
211 protocol.AnalysisService.OVERRIDES,
212 file)) {
213 server.addOperation(
214 new _DartOverridesOperation(file, resolvedDartUnit));
215 }
216 }
217 if (dartUnit != null) {
218 if (server.hasAnalysisSubscription(
219 protocol.AnalysisService.OUTLINE,
220 file)) {
221 LineInfo lineInfo = notice.lineInfo;
222 server.addOperation(
223 new _DartOutlineOperation(file, lineInfo, dartUnit));
224 }
225 }
226 // errors
227 if (server.shouldSendErrorsNotificationFor(file)) {
228 server.addOperation(
229 new _NotificationErrorsOperation(file, notice.lineInfo, notice.error s));
230 }
231 // done 249 // done
232 server.fileAnalyzed(notice); 250 server.fileAnalyzed(notice);
233 } 251 }
234 } 252 }
235 253
236 void _setCacheSize(int cacheSize) { 254 void _setCacheSize(int cacheSize) {
237 AnalysisOptionsImpl options = 255 AnalysisOptionsImpl options =
238 new AnalysisOptionsImpl.con1(context.analysisOptions); 256 new AnalysisOptionsImpl.con1(context.analysisOptions);
239 options.cacheSize = cacheSize; 257 options.cacheSize = cacheSize;
240 context.analysisOptions = options; 258 context.analysisOptions = options;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 @override 405 @override
388 ServerOperationPriority get priority { 406 ServerOperationPriority get priority {
389 return ServerOperationPriority.ANALYSIS_NOTIFICATION; 407 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
390 } 408 }
391 409
392 @override 410 @override
393 void perform(AnalysisServer server) { 411 void perform(AnalysisServer server) {
394 sendAnalysisNotificationErrors(server, file, lineInfo, errors); 412 sendAnalysisNotificationErrors(server, file, lineInfo, errors);
395 } 413 }
396 } 414 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/analysis/update_content_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698