Add a custom LSP method dart/diagnosticServer to start server/return port

Change-Id: I9d9be244251099c947b2998f0a45ec29ef29ad83
Reviewed-on: https://dart-review.googlesource.com/c/90012
Commit-Queue: Danny Tuppeny <dantup@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
index b3f4fe6..bf3a063 100644
--- a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
@@ -5360,234 +5360,182 @@
 
 /// Valid LSP methods known at the time of code generation from the spec.
 class Method {
-  const Method._(this._value);
+  const Method(this._value);
   const Method.fromJson(this._value);
 
   final String _value;
 
   static bool canParse(Object obj) {
-    switch (obj) {
-      case r'$/cancelRequest':
-      case r'initialize':
-      case r'initialized':
-      case r'shutdown':
-      case r'exit':
-      case r'window/showMessage':
-      case r'window/showMessageRequest':
-      case r'window/logMessage':
-      case r'telemetry/event':
-      case r'client/registerCapability':
-      case r'client/unregisterCapability':
-      case r'workspace/workspaceFolders':
-      case r'workspace/didChangeWorkspaceFolders':
-      case r'workspace/configuration':
-      case r'workspace/didChangeWatchedFiles':
-      case r'workspace/symbol':
-      case r'workspace/executeCommand':
-      case r'workspace/applyEdit':
-      case r'textDocument/didOpen':
-      case r'textDocument/didChange':
-      case r'textDocument/willSave':
-      case r'textDocument/willSaveWaitUntil':
-      case r'textDocument/didClose':
-      case r'textDocument/publishDiagnostics':
-      case r'textDocument/completion':
-      case r'completionItem/resolve':
-      case r'textDocument/hover':
-      case r'textDocument/signatureHelp':
-      case r'textDocument/declaration':
-      case r'textDocument/definition':
-      case r'textDocument/typeDefinition':
-      case r'textDocument/implementation':
-      case r'textDocument/references':
-      case r'textDocument/documentHighlight':
-      case r'textDocument/documentSymbol':
-      case r'textDocument/codeAction':
-      case r'textDocument/codeLens':
-      case r'codeLens/resolve':
-      case r'textDocument/documentLink':
-      case r'documentLink/resolve':
-      case r'textDocument/documentColor':
-      case r'textDocument/colorPresentation':
-      case r'textDocument/formatting':
-      case r'textDocument/onTypeFormatting':
-      case r'textDocument/rename':
-      case r'textDocument/prepareRename':
-      case r'textDocument/foldingRange':
-        return true;
-    }
-    return false;
+    return obj is String;
   }
 
   /// Constant for the '$/cancelRequest' method.
-  static const cancelRequest = const Method._(r'$/cancelRequest');
+  static const cancelRequest = const Method(r'$/cancelRequest');
 
   /// Constant for the 'initialize' method.
-  static const initialize = const Method._(r'initialize');
+  static const initialize = const Method(r'initialize');
 
   /// Constant for the 'initialized' method.
-  static const initialized = const Method._(r'initialized');
+  static const initialized = const Method(r'initialized');
 
   /// Constant for the 'shutdown' method.
-  static const shutdown = const Method._(r'shutdown');
+  static const shutdown = const Method(r'shutdown');
 
   /// Constant for the 'exit' method.
-  static const exit = const Method._(r'exit');
+  static const exit = const Method(r'exit');
 
   /// Constant for the 'window/showMessage' method.
-  static const window_showMessage = const Method._(r'window/showMessage');
+  static const window_showMessage = const Method(r'window/showMessage');
 
   /// Constant for the 'window/showMessageRequest' method.
   static const window_showMessageRequest =
-      const Method._(r'window/showMessageRequest');
+      const Method(r'window/showMessageRequest');
 
   /// Constant for the 'window/logMessage' method.
-  static const window_logMessage = const Method._(r'window/logMessage');
+  static const window_logMessage = const Method(r'window/logMessage');
 
   /// Constant for the 'telemetry/event' method.
-  static const telemetry_event = const Method._(r'telemetry/event');
+  static const telemetry_event = const Method(r'telemetry/event');
 
   /// Constant for the 'client/registerCapability' method.
   static const client_registerCapability =
-      const Method._(r'client/registerCapability');
+      const Method(r'client/registerCapability');
 
   /// Constant for the 'client/unregisterCapability' method.
   static const client_unregisterCapability =
-      const Method._(r'client/unregisterCapability');
+      const Method(r'client/unregisterCapability');
 
   /// Constant for the 'workspace/workspaceFolders' method.
   static const workspace_workspaceFolders =
-      const Method._(r'workspace/workspaceFolders');
+      const Method(r'workspace/workspaceFolders');
 
   /// Constant for the 'workspace/didChangeWorkspaceFolders' method.
   static const workspace_didChangeWorkspaceFolders =
-      const Method._(r'workspace/didChangeWorkspaceFolders');
+      const Method(r'workspace/didChangeWorkspaceFolders');
 
   /// Constant for the 'workspace/configuration' method.
   static const workspace_configuration =
-      const Method._(r'workspace/configuration');
+      const Method(r'workspace/configuration');
 
   /// Constant for the 'workspace/didChangeWatchedFiles' method.
   static const workspace_didChangeWatchedFiles =
-      const Method._(r'workspace/didChangeWatchedFiles');
+      const Method(r'workspace/didChangeWatchedFiles');
 
   /// Constant for the 'workspace/symbol' method.
-  static const workspace_symbol = const Method._(r'workspace/symbol');
+  static const workspace_symbol = const Method(r'workspace/symbol');
 
   /// Constant for the 'workspace/executeCommand' method.
   static const workspace_executeCommand =
-      const Method._(r'workspace/executeCommand');
+      const Method(r'workspace/executeCommand');
 
   /// Constant for the 'workspace/applyEdit' method.
-  static const workspace_applyEdit = const Method._(r'workspace/applyEdit');
+  static const workspace_applyEdit = const Method(r'workspace/applyEdit');
 
   /// Constant for the 'textDocument/didOpen' method.
-  static const textDocument_didOpen = const Method._(r'textDocument/didOpen');
+  static const textDocument_didOpen = const Method(r'textDocument/didOpen');
 
   /// Constant for the 'textDocument/didChange' method.
-  static const textDocument_didChange =
-      const Method._(r'textDocument/didChange');
+  static const textDocument_didChange = const Method(r'textDocument/didChange');
 
   /// Constant for the 'textDocument/willSave' method.
-  static const textDocument_willSave = const Method._(r'textDocument/willSave');
+  static const textDocument_willSave = const Method(r'textDocument/willSave');
 
   /// Constant for the 'textDocument/willSaveWaitUntil' method.
   static const textDocument_willSaveWaitUntil =
-      const Method._(r'textDocument/willSaveWaitUntil');
+      const Method(r'textDocument/willSaveWaitUntil');
 
   /// Constant for the 'textDocument/didClose' method.
-  static const textDocument_didClose = const Method._(r'textDocument/didClose');
+  static const textDocument_didClose = const Method(r'textDocument/didClose');
 
   /// Constant for the 'textDocument/publishDiagnostics' method.
   static const textDocument_publishDiagnostics =
-      const Method._(r'textDocument/publishDiagnostics');
+      const Method(r'textDocument/publishDiagnostics');
 
   /// Constant for the 'textDocument/completion' method.
   static const textDocument_completion =
-      const Method._(r'textDocument/completion');
+      const Method(r'textDocument/completion');
 
   /// Constant for the 'completionItem/resolve' method.
-  static const completionItem_resolve =
-      const Method._(r'completionItem/resolve');
+  static const completionItem_resolve = const Method(r'completionItem/resolve');
 
   /// Constant for the 'textDocument/hover' method.
-  static const textDocument_hover = const Method._(r'textDocument/hover');
+  static const textDocument_hover = const Method(r'textDocument/hover');
 
   /// Constant for the 'textDocument/signatureHelp' method.
   static const textDocument_signatureHelp =
-      const Method._(r'textDocument/signatureHelp');
+      const Method(r'textDocument/signatureHelp');
 
   /// Constant for the 'textDocument/declaration' method.
   static const textDocument_declaration =
-      const Method._(r'textDocument/declaration');
+      const Method(r'textDocument/declaration');
 
   /// Constant for the 'textDocument/definition' method.
   static const textDocument_definition =
-      const Method._(r'textDocument/definition');
+      const Method(r'textDocument/definition');
 
   /// Constant for the 'textDocument/typeDefinition' method.
   static const textDocument_typeDefinition =
-      const Method._(r'textDocument/typeDefinition');
+      const Method(r'textDocument/typeDefinition');
 
   /// Constant for the 'textDocument/implementation' method.
   static const textDocument_implementation =
-      const Method._(r'textDocument/implementation');
+      const Method(r'textDocument/implementation');
 
   /// Constant for the 'textDocument/references' method.
   static const textDocument_references =
-      const Method._(r'textDocument/references');
+      const Method(r'textDocument/references');
 
   /// Constant for the 'textDocument/documentHighlight' method.
   static const textDocument_documentHighlight =
-      const Method._(r'textDocument/documentHighlight');
+      const Method(r'textDocument/documentHighlight');
 
   /// Constant for the 'textDocument/documentSymbol' method.
   static const textDocument_documentSymbol =
-      const Method._(r'textDocument/documentSymbol');
+      const Method(r'textDocument/documentSymbol');
 
   /// Constant for the 'textDocument/codeAction' method.
   static const textDocument_codeAction =
-      const Method._(r'textDocument/codeAction');
+      const Method(r'textDocument/codeAction');
 
   /// Constant for the 'textDocument/codeLens' method.
-  static const textDocument_codeLens = const Method._(r'textDocument/codeLens');
+  static const textDocument_codeLens = const Method(r'textDocument/codeLens');
 
   /// Constant for the 'codeLens/resolve' method.
-  static const codeLens_resolve = const Method._(r'codeLens/resolve');
+  static const codeLens_resolve = const Method(r'codeLens/resolve');
 
   /// Constant for the 'textDocument/documentLink' method.
   static const textDocument_documentLink =
-      const Method._(r'textDocument/documentLink');
+      const Method(r'textDocument/documentLink');
 
   /// Constant for the 'documentLink/resolve' method.
-  static const documentLink_resolve = const Method._(r'documentLink/resolve');
+  static const documentLink_resolve = const Method(r'documentLink/resolve');
 
   /// Constant for the 'textDocument/documentColor' method.
   static const textDocument_documentColor =
-      const Method._(r'textDocument/documentColor');
+      const Method(r'textDocument/documentColor');
 
   /// Constant for the 'textDocument/colorPresentation' method.
   static const textDocument_colorPresentation =
-      const Method._(r'textDocument/colorPresentation');
+      const Method(r'textDocument/colorPresentation');
 
   /// Constant for the 'textDocument/formatting' method.
   static const textDocument_formatting =
-      const Method._(r'textDocument/formatting');
+      const Method(r'textDocument/formatting');
 
   /// Constant for the 'textDocument/onTypeFormatting' method.
   static const textDocument_onTypeFormatting =
-      const Method._(r'textDocument/onTypeFormatting');
+      const Method(r'textDocument/onTypeFormatting');
 
   /// Constant for the 'textDocument/rename' method.
-  static const textDocument_rename = const Method._(r'textDocument/rename');
+  static const textDocument_rename = const Method(r'textDocument/rename');
 
   /// Constant for the 'textDocument/prepareRename' method.
   static const textDocument_prepareRename =
-      const Method._(r'textDocument/prepareRename');
+      const Method(r'textDocument/prepareRename');
 
   /// Constant for the 'textDocument/foldingRange' method.
   static const textDocument_foldingRange =
-      const Method._(r'textDocument/foldingRange');
+      const Method(r'textDocument/foldingRange');
 
   Object toJson() => _value;
 
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index a917fb1..f876be1 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -155,11 +155,6 @@
   final StreamController _onAnalysisSetChangedController =
       new StreamController.broadcast(sync: true);
 
-  /// The DiagnosticServer for this AnalysisServer. If available, it can be used
-  /// to start an http diagnostics server or return the port for an existing
-  /// server.
-  final DiagnosticServer diagnosticServer;
-
   final DetachableFileSystemManager detachableFileSystemManager;
 
   /// Initialize a newly created server to receive requests from and send
@@ -175,11 +170,11 @@
     AnalysisServerOptions options,
     this.sdkManager,
     this.instrumentationService, {
-    this.diagnosticServer,
+    DiagnosticServer diagnosticServer,
     ResolverProvider fileResolverProvider: null,
     ResolverProvider packageResolverProvider: null,
     this.detachableFileSystemManager: null,
-  }) : super(options, baseResourceProvider) {
+  }) : super(options, diagnosticServer, baseResourceProvider) {
     notificationManager = new NotificationManager(channel, resourceProvider);
 
     pluginManager = new PluginManager(
diff --git a/pkg/analysis_server/lib/src/analysis_server_abstract.dart b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
index 7dd292f..b0b3d34 100644
--- a/pkg/analysis_server/lib/src/analysis_server_abstract.dart
+++ b/pkg/analysis_server/lib/src/analysis_server_abstract.dart
@@ -8,6 +8,7 @@
 import 'package:analysis_server/src/analysis_server.dart';
 import 'package:analysis_server/src/collections.dart';
 import 'package:analysis_server/src/context_manager.dart';
+import 'package:analysis_server/src/server/diagnostic_server.dart';
 import 'package:analysis_server/src/services/correction/namespace.dart';
 import 'package:analysis_server/src/services/search/element_visitors.dart';
 import 'package:analyzer/dart/analysis/results.dart';
@@ -38,6 +39,11 @@
   /// context directories.
   ContextManager contextManager;
 
+  /// The DiagnosticServer for this AnalysisServer. If available, it can be used
+  /// to start an http diagnostics server or return the port for an existing
+  /// server.
+  final DiagnosticServer diagnosticServer;
+
   /// A [RecentBuffer] of the most recent exceptions encountered by the analysis
   /// server.
   final RecentBuffer<ServerException> exceptions = new RecentBuffer(10);
@@ -73,7 +79,8 @@
   /// list is lazily created and should be accessed using [analyzedFilesGlobs].
   List<Glob> _analyzedFilesGlobs = null;
 
-  AbstractAnalysisServer(this.options, ResourceProvider baseResourceProvider)
+  AbstractAnalysisServer(this.options, this.diagnosticServer,
+      ResourceProvider baseResourceProvider)
       : resourceProvider = OverlayResourceProvider(baseResourceProvider) {
     performance = performanceDuringStartup;
   }
diff --git a/pkg/analysis_server/lib/src/lsp/constants.dart b/pkg/analysis_server/lib/src/lsp/constants.dart
index 464ab95..aaf762f 100644
--- a/pkg/analysis_server/lib/src/lsp/constants.dart
+++ b/pkg/analysis_server/lib/src/lsp/constants.dart
@@ -56,3 +56,7 @@
   ///   if it crashes 5 times in the last 180 seconds."
   static const ClientServerInconsistentState = const ErrorCodes(-32010);
 }
+
+abstract class CustomMethods {
+  static const DiagnosticServer = const Method('dart/diagnosticServer');
+}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_diagnostic_server.dart b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_diagnostic_server.dart
new file mode 100644
index 0000000..7a3dec6
--- /dev/null
+++ b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_diagnostic_server.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+// 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 'dart:async';
+
+import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart';
+import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
+import 'package:analysis_server/lsp_protocol/protocol_special.dart';
+import 'package:analysis_server/src/lsp/constants.dart';
+import 'package:analysis_server/src/lsp/handlers/handlers.dart';
+import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
+
+class DiagnosticServerHandler
+    extends MessageHandler<void, DartDiagnosticServer> {
+  DiagnosticServerHandler(LspAnalysisServer server) : super(server);
+  Method get handlesMessage => CustomMethods.DiagnosticServer;
+
+  @override
+  void convertParams(Map<String, dynamic> json) => null;
+
+  @override
+  Future<ErrorOr<DartDiagnosticServer>> handle(void _) async {
+    final port = await server.diagnosticServer.getServerPort();
+    return success(new DartDiagnosticServer(port));
+  }
+}
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart
index ead989c..36eb607 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_states.dart
@@ -7,6 +7,7 @@
 import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
 import 'package:analysis_server/lsp_protocol/protocol_special.dart';
 import 'package:analysis_server/src/lsp/constants.dart';
+import 'package:analysis_server/src/lsp/handlers/custom/handler_diagnostic_server.dart';
 import 'package:analysis_server/src/lsp/handlers/handler_code_actions.dart';
 import 'package:analysis_server/src/lsp/handlers/handler_completion.dart';
 import 'package:analysis_server/src/lsp/handlers/handler_definition.dart';
@@ -66,6 +67,7 @@
     registerHandler(new PrepareRenameHandler(server));
     registerHandler(new RenameHandler(server));
     registerHandler(new FoldingHandler(server));
+    registerHandler(new DiagnosticServerHandler(server));
   }
 }
 
diff --git a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
index 9ae9716..5f99c59 100644
--- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
+++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
@@ -22,6 +22,7 @@
 import 'package:analysis_server/src/lsp/mapping.dart';
 import 'package:analysis_server/src/plugin/notification_manager.dart';
 import 'package:analysis_server/src/protocol_server.dart' as protocol;
+import 'package:analysis_server/src/server/diagnostic_server.dart';
 import 'package:analysis_server/src/services/completion/completion_performance.dart'
     show CompletionPerformance;
 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
@@ -141,8 +142,9 @@
     AnalysisServerOptions options,
     this.sdkManager,
     this.instrumentationService, {
+    DiagnosticServer diagnosticServer,
     ResolverProvider packageResolverProvider: null,
-  }) : super(options, baseResourceProvider) {
+  }) : super(options, diagnosticServer, baseResourceProvider) {
     messageHandler = new UninitializedStateMessageHandler(this);
     defaultContextOptions.generateImplicitErrors = false;
     defaultContextOptions.useFastaParser = options.useFastaParser;
diff --git a/pkg/analysis_server/lib/src/lsp/lsp_socket_server.dart b/pkg/analysis_server/lib/src/lsp/lsp_socket_server.dart
index 25a15e1..aee1dca 100644
--- a/pkg/analysis_server/lib/src/lsp/lsp_socket_server.dart
+++ b/pkg/analysis_server/lib/src/lsp/lsp_socket_server.dart
@@ -8,6 +8,7 @@
 import 'package:analysis_server/src/lsp/channel/lsp_channel.dart';
 import 'package:analysis_server/src/lsp/constants.dart';
 import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
+import 'package:analysis_server/src/server/diagnostic_server.dart';
 import 'package:analysis_server/src/socket_server.dart';
 import 'package:analyzer/file_system/physical_file_system.dart';
 import 'package:analyzer/instrumentation/instrumentation.dart';
@@ -31,11 +32,12 @@
    * The function used to create a new SDK using the default SDK.
    */
   final DartSdkManager sdkManager;
-
+  final DiagnosticServer diagnosticServer;
   final InstrumentationService instrumentationService;
 
   LspSocketServer(
     this.analysisServerOptions,
+    this.diagnosticServer,
     this.sdkManager,
     this.instrumentationService,
   );
@@ -78,6 +80,7 @@
     }
 
     analysisServer = new LspAnalysisServer(serverChannel, resourceProvider,
-        analysisServerOptions, sdkManager, instrumentationService);
+        analysisServerOptions, sdkManager, instrumentationService,
+        diagnosticServer: diagnosticServer);
   }
 }
diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
index 29d59bb..305b455 100644
--- a/pkg/analysis_server/lib/src/server/driver.dart
+++ b/pkg/analysis_server/lib/src/server/driver.dart
@@ -554,6 +554,7 @@
 
     final socketServer = new LspSocketServer(
       analysisServerOptions,
+      diagnosticServer,
       dartSdkManager,
       instrumentationService,
     );
diff --git a/pkg/analysis_server/lib/src/socket_server.dart b/pkg/analysis_server/lib/src/socket_server.dart
index b9cdaf0..80e07cc 100644
--- a/pkg/analysis_server/lib/src/socket_server.dart
+++ b/pkg/analysis_server/lib/src/socket_server.dart
@@ -17,6 +17,7 @@
 abstract class AbstractSocketServer {
   AnalysisServerOptions get analysisServerOptions;
   AbstractAnalysisServer get analysisServer;
+  DiagnosticServer get diagnosticServer;
 }
 
 /**
diff --git a/pkg/analysis_server/test/lsp/server_abstract.dart b/pkg/analysis_server/test/lsp/server_abstract.dart
index d4a1e2f..b4d1f9f 100644
--- a/pkg/analysis_server/test/lsp/server_abstract.dart
+++ b/pkg/analysis_server/test/lsp/server_abstract.dart
@@ -4,9 +4,11 @@
 
 import 'dart:async';
 
+import 'package:analysis_server/lsp_protocol/protocol_custom_generated.dart';
 import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
 import 'package:analysis_server/lsp_protocol/protocol_special.dart';
 import 'package:analysis_server/src/analysis_server.dart';
+import 'package:analysis_server/src/lsp/constants.dart';
 import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
 import 'package:analysis_server/src/lsp/mapping.dart';
 import 'package:analyzer/instrumentation/instrumentation.dart';
@@ -341,6 +343,14 @@
     return expectSuccessfulResponseTo<List<Location>>(request);
   }
 
+  Future<DartDiagnosticServer> getDiagnosticServer() {
+    final request = makeRequest(
+      CustomMethods.DiagnosticServer,
+      null,
+    );
+    return expectSuccessfulResponseTo(request);
+  }
+
   Future<List<DocumentHighlight>> getDocumentHighlights(Uri uri, Position pos) {
     final request = makeRequest(
       Method.textDocument_documentHighlight,
diff --git a/pkg/analysis_server/test/lsp/server_test.dart b/pkg/analysis_server/test/lsp/server_test.dart
index 233b57a..3be7d04 100644
--- a/pkg/analysis_server/test/lsp/server_test.dart
+++ b/pkg/analysis_server/test/lsp/server_test.dart
@@ -2,6 +2,9 @@
 // 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 'dart:convert';
+import 'dart:io';
+
 import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -68,6 +71,31 @@
     );
   }
 
+  @failingTest
+  test_diagnosticServer() async {
+    // TODO(dantup): This test fails because server.diagnosticServer is not
+    // set up in these tests. This needs moving to an integration test (which
+    // we don't yet have for LSP, but the existing server does have that we
+    // can mirror).
+    await initialize();
+
+    // Send the custom request to the LSP server to get the Dart diagnostic
+    // server info.
+    final server = await getDiagnosticServer();
+
+    expect(server.port, isNotNull);
+    expect(server.port, isNonZero);
+    expect(server.port, isPositive);
+
+    // Ensure the server was actually started.
+    final client = new HttpClient();
+    HttpClientRequest request = await client
+        .getUrl(Uri.parse('http://localhost:${server.port}/status'));
+    final response = await request.close();
+    final responseBody = await utf8.decodeStream(response);
+    expect(responseBody, contains('<title>Analysis Server</title>'));
+  }
+
   test_unknownOptionalNotifications_silentlyDropped() async {
     await initialize();
     final notification =
diff --git a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
index 6c87b90..839da75 100644
--- a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
+++ b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
@@ -24,7 +24,7 @@
   // TODO(dantup): This should return true by default, and allow opt-out for
   // those things we know are not supported. This behaviour matches the old
   // code in order to simplify diffs while migrating.
-  return name == 'ErrorCodes' || name == 'CodeActionKind';
+  return name == 'ErrorCodes' || name == 'CodeActionKind' || name == 'Method';
 }
 
 String generateDartForTypes(List<AstNode> types) {