Index: pkg/analysis_server/lib/src/domain_diagnostic.dart |
diff --git a/pkg/analysis_server/lib/src/domain_diagnostic.dart b/pkg/analysis_server/lib/src/domain_diagnostic.dart |
index d91aacf886083dab04a6962b2898a0b34d57a185..41056b03ec58157b60f399620fbc88f952eb9d80 100644 |
--- a/pkg/analysis_server/lib/src/domain_diagnostic.dart |
+++ b/pkg/analysis_server/lib/src/domain_diagnostic.dart |
@@ -28,7 +28,8 @@ int _workItemCount(AnalysisContextImpl context) { |
/// [RequestHandler] that handles requests in the `diagnostic` domain. |
class DiagnosticDomainHandler implements RequestHandler { |
/// The name of the request used to get diagnostic information. |
- static const String DIAGNOSTICS = 'diagnostic.getDiagnostics'; |
+ static const String GET_DIAGNOSTICS = 'diagnostic.getDiagnostics'; |
+ static const String GET_SERVER_PORT = 'diagnostic.getServerPort'; |
Brian Wilkerson
2017/02/18 21:41:03
The rest of the constants like this are in the fil
devoncarew
2017/02/19 02:43:05
Good to know; moved these into constants.dart and
|
/// The analysis server that is using this handler to process requests. |
final AnalysisServer server; |
@@ -101,12 +102,29 @@ class DiagnosticDomainHandler implements RequestHandler { |
Response handleRequest(Request request) { |
try { |
String requestName = request.method; |
- if (requestName == DIAGNOSTICS) { |
+ if (requestName == GET_DIAGNOSTICS) { |
return computeDiagnostics(request); |
+ } else if (requestName == GET_SERVER_PORT) { |
+ return getServerPort(request); |
} |
} on RequestFailure catch (exception) { |
return exception.response; |
} |
return null; |
} |
+ |
+ /// Answer the `diagnostic.getServerPort` request. |
+ Response getServerPort(Request request) { |
Brian Wilkerson
2017/02/18 21:41:03
Convert this to use an async body? I find it to be
devoncarew
2017/02/19 02:43:04
Sure, done.
As an aside, I'm wondering if the `Re
|
+ // Open a port (or return the existing one). |
+ server.diagnosticServer.getServerPort().then((int port) { |
+ Response response = |
+ new DiagnosticGetServerPortResult(port).toResponse(request.id); |
+ server.sendResponse(response); |
+ }).catchError((error) { |
+ server.sendResponse(new Response.errorHandlingRequest(request, error)); |
+ }); |
+ |
+ // delay response |
+ return Response.DELAYED_RESPONSE; |
+ } |
} |