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

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

Issue 1337143002: Add OCCURRENCES_CONTRIBUTOR_EXTENSION_POINT_ID. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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_highlights2.dart'; 9 import 'package:analysis_server/src/computer/computer_highlights2.dart';
10 import 'package:analysis_server/src/computer/computer_occurrences.dart';
11 import 'package:analysis_server/src/computer/computer_outline.dart'; 10 import 'package:analysis_server/src/computer/computer_outline.dart';
12 import 'package:analysis_server/src/computer/computer_overrides.dart'; 11 import 'package:analysis_server/src/computer/computer_overrides.dart';
13 import 'package:analysis_server/src/domains/analysis/navigation.dart'; 12 import 'package:analysis_server/src/domains/analysis/navigation.dart';
13 import 'package:analysis_server/src/domains/analysis/occurrences.dart';
14 import 'package:analysis_server/src/operation/operation.dart'; 14 import 'package:analysis_server/src/operation/operation.dart';
15 import 'package:analysis_server/src/protocol_server.dart' as protocol; 15 import 'package:analysis_server/src/protocol_server.dart' as protocol;
16 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art'; 16 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art';
17 import 'package:analysis_server/src/services/index/index.dart'; 17 import 'package:analysis_server/src/services/index/index.dart';
18 import 'package:analyzer/src/generated/ast.dart'; 18 import 'package:analyzer/src/generated/ast.dart';
19 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/error.dart'; 20 import 'package:analyzer/src/generated/error.dart';
21 import 'package:analyzer/src/generated/html.dart'; 21 import 'package:analyzer/src/generated/html.dart';
22 import 'package:analyzer/src/generated/source.dart'; 22 import 'package:analyzer/src/generated/source.dart';
23 23
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 server.scheduleOperation( 75 server.scheduleOperation(
76 new _DartHighlightsOperation(context, file, resolvedDartUnit)); 76 new _DartHighlightsOperation(context, file, resolvedDartUnit));
77 } 77 }
78 if (server.hasAnalysisSubscription( 78 if (server.hasAnalysisSubscription(
79 protocol.AnalysisService.NAVIGATION, file)) { 79 protocol.AnalysisService.NAVIGATION, file)) {
80 Source source = resolvedDartUnit.element.source; 80 Source source = resolvedDartUnit.element.source;
81 server.scheduleOperation(new NavigationOperation(context, source)); 81 server.scheduleOperation(new NavigationOperation(context, source));
82 } 82 }
83 if (server.hasAnalysisSubscription( 83 if (server.hasAnalysisSubscription(
84 protocol.AnalysisService.OCCURRENCES, file)) { 84 protocol.AnalysisService.OCCURRENCES, file)) {
85 server.scheduleOperation( 85 Source source = resolvedDartUnit.element.source;
86 new _DartOccurrencesOperation(context, file, resolvedDartUnit)); 86 server.scheduleOperation(new OccurrencesOperation(context, source));
87 } 87 }
88 if (server.hasAnalysisSubscription( 88 if (server.hasAnalysisSubscription(
89 protocol.AnalysisService.OVERRIDES, file)) { 89 protocol.AnalysisService.OVERRIDES, file)) {
90 server.scheduleOperation( 90 server.scheduleOperation(
91 new _DartOverridesOperation(context, file, resolvedDartUnit)); 91 new _DartOverridesOperation(context, file, resolvedDartUnit));
92 } 92 }
93 } 93 }
94 if (dartUnit != null) { 94 if (dartUnit != null) {
95 if (server.hasAnalysisSubscription( 95 if (server.hasAnalysisSubscription(
96 protocol.AnalysisService.OUTLINE, file)) { 96 protocol.AnalysisService.OUTLINE, file)) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 NavigationCollectorImpl collector = 172 NavigationCollectorImpl collector =
173 computeNavigation(server, context, source, null, null); 173 computeNavigation(server, context, source, null, null);
174 String file = source.fullName; 174 String file = source.fullName;
175 var params = new protocol.AnalysisNavigationParams( 175 var params = new protocol.AnalysisNavigationParams(
176 file, collector.regions, collector.targets, collector.files); 176 file, collector.regions, collector.targets, collector.files);
177 server.sendNotification(params.toNotification()); 177 server.sendNotification(params.toNotification());
178 }); 178 });
179 } 179 }
180 180
181 void sendAnalysisNotificationOccurrences( 181 void sendAnalysisNotificationOccurrences(
182 AnalysisServer server, String file, CompilationUnit dartUnit) { 182 AnalysisServer server, AnalysisContext context, Source source) {
183 _sendNotification(server, () { 183 _sendNotification(server, () {
184 var occurrences = new DartUnitOccurrencesComputer(dartUnit).compute(); 184 OccurrencesCollectorImpl collector =
185 var params = new protocol.AnalysisOccurrencesParams(file, occurrences); 185 computeOccurrences(server, context, source);
186 String file = source.fullName;
187 var params =
188 new protocol.AnalysisOccurrencesParams(file, collector.allOccurrences);
186 server.sendNotification(params.toNotification()); 189 server.sendNotification(params.toNotification());
187 }); 190 });
188 } 191 }
189 192
190 void sendAnalysisNotificationOutline(AnalysisServer server, String file, 193 void sendAnalysisNotificationOutline(AnalysisServer server, String file,
191 LineInfo lineInfo, CompilationUnit dartUnit) { 194 LineInfo lineInfo, CompilationUnit dartUnit) {
192 _sendNotification(server, () { 195 _sendNotification(server, () {
193 var computer = new DartUnitOutlineComputer(file, lineInfo, dartUnit); 196 var computer = new DartUnitOutlineComputer(file, lineInfo, dartUnit);
194 var outline = computer.compute(); 197 var outline = computer.compute();
195 var params = new protocol.AnalysisOutlineParams(file, outline); 198 var params = new protocol.AnalysisOutlineParams(file, outline);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 231 }
229 }); 232 });
230 } 233 }
231 234
232 class NavigationOperation extends _NotificationOperation 235 class NavigationOperation extends _NotificationOperation
233 implements MergeableOperation { 236 implements MergeableOperation {
234 NavigationOperation(AnalysisContext context, Source source) 237 NavigationOperation(AnalysisContext context, Source source)
235 : super(context, source); 238 : super(context, source);
236 239
237 @override 240 @override
238 void perform(AnalysisServer server) {
239 sendAnalysisNotificationNavigation(server, context, source);
240 }
241
242 @override
243 bool merge(ServerOperation other) { 241 bool merge(ServerOperation other) {
244 return other is NavigationOperation && 242 return other is NavigationOperation &&
245 other.context == context && 243 other.context == context &&
246 other.source == source; 244 other.source == source;
247 } 245 }
246
247 @override
248 void perform(AnalysisServer server) {
249 sendAnalysisNotificationNavigation(server, context, source);
250 }
251 }
252
253 class OccurrencesOperation extends _NotificationOperation
254 implements MergeableOperation {
255 OccurrencesOperation(AnalysisContext context, Source source)
256 : super(context, source);
257
258 @override
259 bool merge(ServerOperation other) {
260 return other is OccurrencesOperation &&
261 other.context == context &&
262 other.source == source;
263 }
264
265 @override
266 void perform(AnalysisServer server) {
267 sendAnalysisNotificationOccurrences(server, context, source);
268 }
248 } 269 }
249 270
250 /** 271 /**
251 * Instances of [PerformAnalysisOperation] perform a single analysis task. 272 * Instances of [PerformAnalysisOperation] perform a single analysis task.
252 */ 273 */
253 class PerformAnalysisOperation extends ServerOperation { 274 class PerformAnalysisOperation extends ServerOperation {
254 static const int IDLE_CACHE_SIZE = AnalysisOptionsImpl.DEFAULT_CACHE_SIZE; 275 static const int IDLE_CACHE_SIZE = AnalysisOptionsImpl.DEFAULT_CACHE_SIZE;
255 static const int WORKING_CACHE_SIZE = 512; 276 static const int WORKING_CACHE_SIZE = 512;
256 277
257 final bool isContinue; 278 final bool isContinue;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 424
404 _DartNotificationOperation(AnalysisContext context, String file, this.unit) 425 _DartNotificationOperation(AnalysisContext context, String file, this.unit)
405 : super(context, file); 426 : super(context, file);
406 427
407 @override 428 @override
408 ServerOperationPriority get priority { 429 ServerOperationPriority get priority {
409 return ServerOperationPriority.ANALYSIS_NOTIFICATION; 430 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
410 } 431 }
411 } 432 }
412 433
413 class _DartOccurrencesOperation extends _DartNotificationOperation {
414 _DartOccurrencesOperation(
415 AnalysisContext context, String file, CompilationUnit unit)
416 : super(context, file, unit);
417
418 @override
419 void perform(AnalysisServer server) {
420 sendAnalysisNotificationOccurrences(server, file, unit);
421 }
422 }
423
424 class _DartOutlineOperation extends _DartNotificationOperation { 434 class _DartOutlineOperation extends _DartNotificationOperation {
425 final LineInfo lineInfo; 435 final LineInfo lineInfo;
426 436
427 _DartOutlineOperation( 437 _DartOutlineOperation(
428 AnalysisContext context, String file, this.lineInfo, CompilationUnit unit) 438 AnalysisContext context, String file, this.lineInfo, CompilationUnit unit)
429 : super(context, file, unit); 439 : super(context, file, unit);
430 440
431 @override 441 @override
432 void perform(AnalysisServer server) { 442 void perform(AnalysisServer server) {
433 sendAnalysisNotificationOutline(server, file, lineInfo, unit); 443 sendAnalysisNotificationOutline(server, file, lineInfo, unit);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 abstract class _SingleFileOperation extends SourceSensitiveOperation { 511 abstract class _SingleFileOperation extends SourceSensitiveOperation {
502 final String file; 512 final String file;
503 513
504 _SingleFileOperation(AnalysisContext context, this.file) : super(context); 514 _SingleFileOperation(AnalysisContext context, this.file) : super(context);
505 515
506 @override 516 @override
507 bool shouldBeDiscardedOnSourceChange(Source source) { 517 bool shouldBeDiscardedOnSourceChange(Source source) {
508 return source.fullName == file; 518 return source.fullName == file;
509 } 519 }
510 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698