analysis_server_client API tweaks before publish

* Rename ClientListener to ServerListener
* Change ServerConnectionHandler on --> implements NotificationHandler

Change-Id: I459e4c566971d49790e12b8f1386ae80db33b38b
Reviewed-on: https://dart-review.googlesource.com/c/84560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
danrubel
2018-11-15 21:44:03 +00:00
committed by commit-bot@chromium.org
parent 8414e2240c
commit e39fa29bd6
8 changed files with 24 additions and 24 deletions
@@ -20,7 +20,7 @@ import 'package:pub_semver/pub_semver.dart';
/// and [onServerError] to display connection failure information.
///
/// Clients may mix-in this class, but may not extend or implement it.
mixin ConnectionHandler on NotificationHandler {
mixin ConnectionHandler implements NotificationHandler {
Completer<bool> _connected = new Completer();
/// Clients should implement this method to return the server being managed.
@@ -2,22 +2,22 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Instances of the class [ClientListener] receive information from [Client]
/// Instances of the class [ServerListener] receive information from [Server]
/// about interactions with the server.
///
/// Clients may mix-in this class, but may not implement it.
mixin ClientListener {
/// Called when the [Client] could not decode a message.
mixin ServerListener {
/// Called when the [Server] could not decode a message.
void badMessage(String trimmedLine, exception) {
log('JSON decode failure', '$exception');
}
/// Called when the [Client] receives a line on stderr.
/// Called when the [Server] receives a line on stderr.
void errorMessage(String line) {
log('ERR:', line);
}
/// Called when the [Client] is terminating the server process
/// Called when the [Server] is terminating the server process
/// rather than requesting that the server stop itself.
void killingServerProcess(String reason) {
log('FORCIBLY TERMINATING SERVER: ', reason);
@@ -26,28 +26,28 @@ mixin ClientListener {
/// Log a message about interaction with the server.
void log(String prefix, String details);
/// Called when the [Client] received a response or notification.
/// Called when the [Server] received a response or notification.
void messageReceived(String json) {
log('<== ', json);
}
/// Called when the [Client] sends a request.
/// Called when the [Server] sends a request.
void requestSent(String json) {
log('==> ', json);
}
/// Called when the [Client] starts the server process.
/// Called when the [Server] starts the server process.
void startingServer(String dartBinary, List<String> arguments) {
log('Starting analysis server:', '$dartBinary ${arguments.join(' ')}');
}
/// Called when the [Client] receives an unexpected message
/// Called when the [Server] receives an unexpected message
/// which is not a notification or response.
void unexpectedMessage(Map<String, dynamic> message) {
log('Unexpected message from server:', '$message');
}
/// Called when the [Client] recieved an unexpected response
/// Called when the [Server] recieved an unexpected response
/// where the [id] does not match the [id] of an outstanding request.
void unexpectedResponse(Map<String, dynamic> message, id) {
log('Unexpected response from server', 'id=$id');
+3 -3
View File
@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
import 'package:analysis_server_client/protocol.dart';
import 'package:path/path.dart';
@@ -20,7 +20,7 @@ typedef void NotificationProcessor(Notification notification);
class Server {
/// If not `null`, [_listener] will be sent information
/// about interactions with the server.
ClientListener _listener;
ServerListener _listener;
/// Server process object, or `null` if server hasn't been started yet
/// or if the server has already been stopped.
@@ -43,7 +43,7 @@ class Server {
/// [listenToOutput] has not been called or [stop] has been called.
StreamSubscription<String> _stdoutSubscription;
Server({ClientListener listener, Process process})
Server({ServerListener listener, Process process})
: this._listener = listener,
this._process = process;
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
import 'package:analysis_server_client/handler/notification_handler.dart';
import 'package:analysis_server_client/handler/connection_handler.dart';
import 'package:analysis_server_client/protocol.dart';
@@ -39,7 +39,7 @@ class TestHandler with NotificationHandler, ConnectionHandler {
TestHandler(this.server);
}
class TestListener with ClientListener {
class TestListener with ServerListener {
@override
void log(String prefix, String details) {
print('$prefix $details');
@@ -4,10 +4,10 @@
import 'dart:async';
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
/// [BadMessageListener] throws an exception if the [Client] receives bad data.
mixin BadMessageListener on ClientListener {
mixin BadMessageListener on ServerListener {
/// True if we've received bad data from the server.
bool _receivedBadDataFromServer = false;
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server_client/server.dart';
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
import 'package:dartfix/listener/bad_message_listener.dart';
import 'package:dartfix/listener/timed_listener.dart';
@@ -11,7 +11,7 @@ import 'package:dartfix/listener/timed_listener.dart';
/// and print them if a problem occurs.
///
/// This is primarily used when testing and debugging the analysis server.
class RecordingListener with ClientListener, BadMessageListener, TimedListener {
class RecordingListener with ServerListener, BadMessageListener, TimedListener {
/// True if we are currently printing out messages exchanged with the server.
bool _echoMessages = false;
+2 -2
View File
@@ -2,11 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
/// [TimedListener] appends a timestamp (seconds since server startup)
/// to each logged interaction with the server.
mixin TimedListener on ClientListener {
mixin TimedListener on ServerListener {
/// Stopwatch that we use to generate timing information for debug output.
Stopwatch _time = new Stopwatch();
+2 -2
View File
@@ -8,7 +8,7 @@ import 'dart:io' show File, Platform;
import 'package:analysis_server_client/server.dart';
import 'package:analysis_server_client/handler/connection_handler.dart';
import 'package:analysis_server_client/handler/notification_handler.dart';
import 'package:analysis_server_client/listener/client_listener.dart';
import 'package:analysis_server_client/listener/server_listener.dart';
import 'package:analysis_server_client/protocol.dart';
import 'package:cli_util/cli_logging.dart';
import 'package:dartfix/handler/analysis_complete_handler.dart';
@@ -185,7 +185,7 @@ class Driver {
}
}
class _Listener with ClientListener, BadMessageListener {
class _Listener with ServerListener, BadMessageListener {
final Logger logger;
final bool verbose;