OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
8 import 'package:analyzer/file_system/physical_file_system.dart'; | 8 import 'package:analyzer/file_system/physical_file_system.dart'; |
9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 9 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
10 import 'package:analyzer/src/dart/analysis/driver.dart' | 10 import 'package:analyzer/src/dart/analysis/driver.dart' |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 */ | 420 */ |
421 void onDone() {} | 421 void onDone() {} |
422 | 422 |
423 /** | 423 /** |
424 * The method that is called when an error has occurred in the analysis | 424 * The method that is called when an error has occurred in the analysis |
425 * server. This method will not be invoked under normal conditions. | 425 * server. This method will not be invoked under normal conditions. |
426 */ | 426 */ |
427 void onError(Object exception, StackTrace stackTrace) {} | 427 void onError(Object exception, StackTrace stackTrace) {} |
428 | 428 |
429 /** | 429 /** |
430 * Send notifications corresponding to the given description of subscriptions. | 430 * If the plugin provides folding information, send a folding notification |
431 * The map is keyed by the path of each file for which notifications should be | 431 * for the file with the given [path] to the server. |
432 * sent and has values representing the list of services associated with the | 432 */ |
433 * notifications to send. | 433 Future<Null> sendFoldingNotification(String path) { |
| 434 return new Future.value(); |
| 435 } |
| 436 |
| 437 /** |
| 438 * If the plugin provides highlighting information, send a highlights |
| 439 * notification for the file with the given [path] to the server. |
| 440 */ |
| 441 Future<Null> sendHighlightsNotification(String path) { |
| 442 return new Future.value(); |
| 443 } |
| 444 |
| 445 /** |
| 446 * If the plugin provides navigation information, send a navigation |
| 447 * notification for the file with the given [path] to the server. |
| 448 */ |
| 449 Future<Null> sendNavigationNotification(String path) { |
| 450 return new Future.value(); |
| 451 } |
| 452 |
| 453 /** |
| 454 * Send notifications for the services subscribed to for the file with the |
| 455 * given [path]. |
| 456 * |
| 457 * This is a convenience method that subclasses can use to send notifications |
| 458 * after analysis has been performed on a file. |
| 459 */ |
| 460 void sendNotificationsForFile(String path) { |
| 461 for (AnalysisService service in subscriptionManager.servicesForFile(path)) { |
| 462 _sendNotificationForFile(path, service); |
| 463 } |
| 464 } |
| 465 |
| 466 /** |
| 467 * Send notifications corresponding to the given description of |
| 468 * [subscriptions]. The map is keyed by the path of each file for which |
| 469 * notifications should be sent and has values representing the list of |
| 470 * services associated with the notifications to send. |
| 471 * |
| 472 * This method is used when the set of subscribed notifications has been |
| 473 * changed and notifications need to be sent even when the specified files |
| 474 * have already been analyzed. |
434 */ | 475 */ |
435 void sendNotificationsForSubscriptions( | 476 void sendNotificationsForSubscriptions( |
436 Map<String, List<AnalysisService>> subscriptions); | 477 Map<String, List<AnalysisService>> subscriptions) { |
| 478 subscriptions.forEach((String path, List<AnalysisService> services) { |
| 479 for (AnalysisService service in services) { |
| 480 _sendNotificationForFile(path, service); |
| 481 } |
| 482 }); |
| 483 } |
| 484 |
| 485 /** |
| 486 * If the plugin provides occurrences information, send an occurrences |
| 487 * notification for the file with the given [path] to the server. |
| 488 */ |
| 489 Future<Null> sendOccurrencesNotification(String path) { |
| 490 return new Future.value(); |
| 491 } |
| 492 |
| 493 /** |
| 494 * If the plugin provides outline information, send an outline notification |
| 495 * for the file with the given [path] to the server. |
| 496 */ |
| 497 Future<Null> sendOutlineNotification(String path) { |
| 498 return new Future.value(); |
| 499 } |
437 | 500 |
438 /** | 501 /** |
439 * Start this plugin by listening to the given communication [channel]. | 502 * Start this plugin by listening to the given communication [channel]. |
440 */ | 503 */ |
441 void start(PluginCommunicationChannel channel) { | 504 void start(PluginCommunicationChannel channel) { |
442 _channel = channel; | 505 _channel = channel; |
443 _channel.listen(_onRequest, onError: onError, onDone: onDone); | 506 _channel.listen(_onRequest, onError: onError, onDone: onDone); |
444 } | 507 } |
445 | 508 |
446 /** | 509 /** |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 } catch (exception, stackTrace) { | 618 } catch (exception, stackTrace) { |
556 response = new Response(id, requestTime, | 619 response = new Response(id, requestTime, |
557 error: new RequestError( | 620 error: new RequestError( |
558 RequestErrorCode.PLUGIN_ERROR, exception.toString(), | 621 RequestErrorCode.PLUGIN_ERROR, exception.toString(), |
559 stackTrace: stackTrace.toString())); | 622 stackTrace: stackTrace.toString())); |
560 } | 623 } |
561 if (response != null) { | 624 if (response != null) { |
562 _channel.sendResponse(response); | 625 _channel.sendResponse(response); |
563 } | 626 } |
564 } | 627 } |
| 628 |
| 629 /** |
| 630 * Send a notification for the file at the given [path] corresponding to the |
| 631 * given [service]. |
| 632 */ |
| 633 void _sendNotificationForFile(String path, AnalysisService service) { |
| 634 switch (service) { |
| 635 case AnalysisService.FOLDING: |
| 636 sendFoldingNotification(path); |
| 637 break; |
| 638 case AnalysisService.HIGHLIGHTS: |
| 639 sendHighlightsNotification(path); |
| 640 break; |
| 641 case AnalysisService.NAVIGATION: |
| 642 sendNavigationNotification(path); |
| 643 break; |
| 644 case AnalysisService.OCCURRENCES: |
| 645 sendOccurrencesNotification(path); |
| 646 break; |
| 647 case AnalysisService.OUTLINE: |
| 648 sendOutlineNotification(path); |
| 649 break; |
| 650 } |
| 651 } |
565 } | 652 } |
OLD | NEW |