Version 2.17.0-283.0.dev

Merge commit 'ca9ba196c8d56471a3e118806788dfa3d0fc359f' into 'dev'
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index f91ecc5..2eff1ad 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -8,8 +8,7 @@
 import 'dart:math' show max;
 
 import 'package:analysis_server/protocol/protocol.dart';
-import 'package:analysis_server/protocol/protocol_constants.dart'
-    show PROTOCOL_VERSION;
+import 'package:analysis_server/protocol/protocol_constants.dart';
 import 'package:analysis_server/protocol/protocol_generated.dart'
     hide AnalysisOptions;
 import 'package:analysis_server/src/analysis_server_abstract.dart';
@@ -20,7 +19,6 @@
 import 'package:analysis_server/src/domain_analytics.dart';
 import 'package:analysis_server/src/domain_completion.dart';
 import 'package:analysis_server/src/domain_diagnostic.dart';
-import 'package:analysis_server/src/domain_execution.dart';
 import 'package:analysis_server/src/domain_kythe.dart';
 import 'package:analysis_server/src/domain_server.dart';
 import 'package:analysis_server/src/domains/analysis/occurrences.dart';
@@ -28,6 +26,12 @@
 import 'package:analysis_server/src/edit/edit_domain.dart';
 import 'package:analysis_server/src/flutter/flutter_domain.dart';
 import 'package:analysis_server/src/flutter/flutter_notifications.dart';
+import 'package:analysis_server/src/handler/legacy/execution_create_context.dart';
+import 'package:analysis_server/src/handler/legacy/execution_delete_context.dart';
+import 'package:analysis_server/src/handler/legacy/execution_get_suggestions.dart';
+import 'package:analysis_server/src/handler/legacy/execution_map_uri.dart';
+import 'package:analysis_server/src/handler/legacy/execution_set_subscriptions.dart';
+import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
 import 'package:analysis_server/src/operation/operation_analysis.dart';
 import 'package:analysis_server/src/plugin/notification_manager.dart';
 import 'package:analysis_server/src/protocol_server.dart' as server;
@@ -65,11 +69,30 @@
 import 'package:telemetry/telemetry.dart' as telemetry;
 import 'package:watcher/watcher.dart';
 
+/// A function that can be executed to create a handler for a request.
+typedef HandlerGenerator = LegacyHandler Function(
+    AnalysisServer, Request, CancellationToken);
+
 typedef OptionUpdater = void Function(AnalysisOptionsImpl options);
 
 /// Instances of the class [AnalysisServer] implement a server that listens on a
 /// [CommunicationChannel] for analysis requests and process them.
 class AnalysisServer extends AbstractAnalysisServer {
+  /// A map from the name of a request to a function used to create a request
+  /// handler.
+  static final Map<String, HandlerGenerator> handlerGenerators = {
+    EXECUTION_REQUEST_CREATE_CONTEXT: (server, request, cancellationToken) =>
+        ExecutionCreateContextHandler(server, request, cancellationToken),
+    EXECUTION_REQUEST_DELETE_CONTEXT: (server, request, cancellationToken) =>
+        ExecutionDeleteContextHandler(server, request, cancellationToken),
+    EXECUTION_REQUEST_GET_SUGGESTIONS: (server, request, cancellationToken) =>
+        ExecutionGetSuggestionsHandler(server, request, cancellationToken),
+    EXECUTION_REQUEST_MAP_URI: (server, request, cancellationToken) =>
+        ExecutionMapUriHandler(server, request, cancellationToken),
+    EXECUTION_REQUEST_SET_SUBSCRIPTIONS: (server, request, cancellationToken) =>
+        ExecutionSetSubscriptionsHandler(server, request, cancellationToken),
+  };
+
   /// The channel from which requests are received and to which responses should
   /// be sent.
   final ServerCommunicationChannel channel;
@@ -225,7 +248,6 @@
       EditDomainHandler(this),
       SearchDomainHandler(this),
       CompletionDomainHandler(this),
-      ExecutionDomainHandler(this, executionContext),
       DiagnosticDomainHandler(this),
       AnalyticsDomainHandler(this),
       KytheDomainHandler(this),
@@ -295,33 +317,54 @@
     runZonedGuarded(() {
       var cancellationToken = CancelableToken();
       cancellationTokens[request.id] = cancellationToken;
-      var count = handlers.length;
-      for (var i = 0; i < count; i++) {
+      var generator = handlerGenerators[request.method];
+      if (generator != null) {
         try {
-          var response = handlers[i].handleRequest(request, cancellationToken);
-          if (response == Response.DELAYED_RESPONSE) {
-            return;
-          }
-          if (response != null) {
-            sendResponse(response);
-            return;
-          }
+          var handler = generator(this, request, cancellationToken);
+          handler.handle();
         } on InconsistentAnalysisException {
           sendResponse(Response.contentModified(request));
-          return;
         } on RequestFailure catch (exception) {
           sendResponse(exception.response);
-          return;
         } catch (exception, stackTrace) {
           var error =
               RequestError(RequestErrorCode.SERVER_ERROR, exception.toString());
           error.stackTrace = stackTrace.toString();
           var response = Response(request.id, error: error);
           sendResponse(response);
-          return;
         }
+      } else {
+        // TODO(brianwilkerson) When all the handlers are in [handlerGenerators]
+        //  remove local variable and for loop below.
+        var count = handlers.length;
+        for (var i = 0; i < count; i++) {
+          try {
+            var response =
+                handlers[i].handleRequest(request, cancellationToken);
+            if (response == Response.DELAYED_RESPONSE) {
+              return;
+            }
+            if (response != null) {
+              sendResponse(response);
+              return;
+            }
+          } on InconsistentAnalysisException {
+            sendResponse(Response.contentModified(request));
+            return;
+          } on RequestFailure catch (exception) {
+            sendResponse(exception.response);
+            return;
+          } catch (exception, stackTrace) {
+            var error = RequestError(
+                RequestErrorCode.SERVER_ERROR, exception.toString());
+            error.stackTrace = stackTrace.toString();
+            var response = Response(request.id, error: error);
+            sendResponse(response);
+            return;
+          }
+        }
+        sendResponse(Response.unknownRequest(request));
       }
-      sendResponse(Response.unknownRequest(request));
     }, (exception, stackTrace) {
       instrumentationService.logException(
         FatalException(
diff --git a/pkg/analysis_server/lib/src/domain_execution.dart b/pkg/analysis_server/lib/src/domain_execution.dart
deleted file mode 100644
index cdedc79..0000000
--- a/pkg/analysis_server/lib/src/domain_execution.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2014, 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 'package:analysis_server/protocol/protocol_constants.dart';
-import 'package:analysis_server/src/analysis_server.dart';
-import 'package:analysis_server/src/handler/legacy/execution_create_context.dart';
-import 'package:analysis_server/src/handler/legacy/execution_delete_context.dart';
-import 'package:analysis_server/src/handler/legacy/execution_get_suggestions.dart';
-import 'package:analysis_server/src/handler/legacy/execution_map_uri.dart';
-import 'package:analysis_server/src/handler/legacy/execution_set_subscriptions.dart';
-import 'package:analysis_server/src/protocol_server.dart';
-import 'package:analysis_server/src/services/execution/execution_context.dart';
-import 'package:analyzer/src/utilities/cancellation.dart';
-
-/// Instances of the class [ExecutionDomainHandler] implement a [RequestHandler]
-/// that handles requests in the `execution` domain.
-class ExecutionDomainHandler implements RequestHandler {
-  /// The analysis server that is using this handler to process requests.
-  final AnalysisServer server;
-
-  /// The context used by the execution domain handlers.
-  final ExecutionContext executionContext;
-
-  /// Initialize a newly created handler to handle requests for the given
-  /// [server].
-  ExecutionDomainHandler(this.server, this.executionContext);
-
-  @override
-  Response? handleRequest(
-      Request request, CancellationToken cancellationToken) {
-    try {
-      var requestName = request.method;
-      if (requestName == EXECUTION_REQUEST_CREATE_CONTEXT) {
-        ExecutionCreateContextHandler(
-                server, request, cancellationToken, executionContext)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == EXECUTION_REQUEST_DELETE_CONTEXT) {
-        ExecutionDeleteContextHandler(
-                server, request, cancellationToken, executionContext)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == EXECUTION_REQUEST_GET_SUGGESTIONS) {
-        ExecutionGetSuggestionsHandler(server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == EXECUTION_REQUEST_MAP_URI) {
-        ExecutionMapUriHandler(
-                server, request, cancellationToken, executionContext)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == EXECUTION_REQUEST_SET_SUBSCRIPTIONS) {
-        ExecutionSetSubscriptionsHandler(server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      }
-    } on RequestFailure catch (exception) {
-      return exception.response;
-    }
-    return null;
-  }
-}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/execution_create_context.dart b/pkg/analysis_server/lib/src/handler/legacy/execution_create_context.dart
index 40ca6e1..67bed11 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/execution_create_context.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/execution_create_context.dart
@@ -8,23 +8,20 @@
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/analysis_server.dart';
 import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
-import 'package:analysis_server/src/services/execution/execution_context.dart';
 import 'package:analyzer/src/utilities/cancellation.dart';
 
 /// The handler for the `execution.createContext` request.
 class ExecutionCreateContextHandler extends LegacyHandler {
-  /// The context used by the execution domain handlers.
-  final ExecutionContext executionContext;
-
   /// Initialize a newly created handler to be able to service requests for the
   /// [server].
   ExecutionCreateContextHandler(AnalysisServer server, Request request,
-      CancellationToken cancellationToken, this.executionContext)
+      CancellationToken cancellationToken)
       : super(server, request, cancellationToken);
 
   @override
   Future<void> handle() async {
     var file = ExecutionCreateContextParams.fromRequest(request).contextRoot;
+    var executionContext = server.executionContext;
     var contextId = (executionContext.nextContextId++).toString();
     executionContext.contextMap[contextId] = file;
     sendResult(ExecutionCreateContextResult(contextId));
diff --git a/pkg/analysis_server/lib/src/handler/legacy/execution_delete_context.dart b/pkg/analysis_server/lib/src/handler/legacy/execution_delete_context.dart
index e4b7aae..07b7701 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/execution_delete_context.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/execution_delete_context.dart
@@ -8,24 +8,20 @@
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/analysis_server.dart';
 import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
-import 'package:analysis_server/src/services/execution/execution_context.dart';
 import 'package:analyzer/src/utilities/cancellation.dart';
 
 /// The handler for the `execution.deleteContext` request.
 class ExecutionDeleteContextHandler extends LegacyHandler {
-  /// The context used by the execution domain handlers.
-  final ExecutionContext executionContext;
-
   /// Initialize a newly created handler to be able to service requests for the
   /// [server].
   ExecutionDeleteContextHandler(AnalysisServer server, Request request,
-      CancellationToken cancellationToken, this.executionContext)
+      CancellationToken cancellationToken)
       : super(server, request, cancellationToken);
 
   @override
   Future<void> handle() async {
     var contextId = ExecutionDeleteContextParams.fromRequest(request).id;
-    executionContext.contextMap.remove(contextId);
+    server.executionContext.contextMap.remove(contextId);
     sendResult(ExecutionDeleteContextResult());
   }
 }
diff --git a/pkg/analysis_server/lib/src/handler/legacy/execution_map_uri.dart b/pkg/analysis_server/lib/src/handler/legacy/execution_map_uri.dart
index a33a85a..27c59d0 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/execution_map_uri.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/execution_map_uri.dart
@@ -8,26 +8,22 @@
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/analysis_server.dart';
 import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
-import 'package:analysis_server/src/services/execution/execution_context.dart';
 import 'package:analyzer/file_system/file_system.dart';
 import 'package:analyzer/src/utilities/cancellation.dart';
 
 /// The handler for the `execution.mapUri` request.
 class ExecutionMapUriHandler extends LegacyHandler {
-  /// The context used by the execution domain handlers.
-  final ExecutionContext executionContext;
-
   /// Initialize a newly created handler to be able to service requests for the
   /// [server].
   ExecutionMapUriHandler(AnalysisServer server, Request request,
-      CancellationToken cancellationToken, this.executionContext)
+      CancellationToken cancellationToken)
       : super(server, request, cancellationToken);
 
   @override
   Future<void> handle() async {
     var params = ExecutionMapUriParams.fromRequest(request);
     var contextId = params.id;
-    var path = executionContext.contextMap[contextId];
+    var path = server.executionContext.contextMap[contextId];
     if (path == null) {
       sendResponse(Response.invalidParameter(request, 'id',
           'There is no execution context with an id of $contextId'));
diff --git a/pkg/analysis_server/test/domain_execution_test.dart b/pkg/analysis_server/test/domain_execution_test.dart
index 42550dc..e1ec249 100644
--- a/pkg/analysis_server/test/domain_execution_test.dart
+++ b/pkg/analysis_server/test/domain_execution_test.dart
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analysis_server/src/domain_execution.dart';
 import 'package:analysis_server/src/protocol_server.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -124,7 +123,6 @@
   Future<void> setUp() async {
     super.setUp();
     await createProject();
-    handler = ExecutionDomainHandler(server, server.executionContext);
     await _createExecutionContext(testFile);
   }
 
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index 2322191..1b46725 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -739,8 +739,6 @@
     for (var directive in directivesToResolve) {
       directive.element = _libraryElement;
     }
-
-    // TODO(scheglov) remove DirectiveResolver class
   }
 
   void _resolveFile(FileState file, CompilationUnit unit) {
diff --git a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
index 1510042..84c6754 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_analyzer.dart
@@ -665,8 +665,6 @@
     for (var directive in directivesToResolve) {
       directive.element = _libraryElement;
     }
-
-    // TODO(scheglov) remove DirectiveResolver class
   }
 
   void _resolveFile({
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 29a2a01..0f87a11 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -258,10 +258,7 @@
   /// unit containing the node being visited. The [typeProvider] is the object
   /// used to access the types from the core library. The [errorListener] is the
   /// error listener that will be informed of any errors that are found during
-  /// resolution. The [nameScope] is the scope used to resolve identifiers in
-  /// the node that will first be visited.  If `null` or unspecified, a new
-  /// [LibraryScope] will be created based on [definingLibrary] and
-  /// [typeProvider].
+  /// resolution.
   ///
   /// TODO(paulberry): make [featureSet] a required parameter (this will be a
   /// breaking change).
@@ -2910,7 +2907,7 @@
   /// [definingLibrary] is the element for the library containing the node being
   /// visited.
   /// [source] is the source representing the compilation unit containing the
-  /// node being visited
+  /// node being visited.
   /// [typeProvider] is the object used to access the types from the core
   /// library.
   /// [errorListener] is the error listener that will be informed of any errors
diff --git a/tools/VERSION b/tools/VERSION
index a082332..db9b0e4 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 17
 PATCH 0
-PRERELEASE 282
+PRERELEASE 283
 PRERELEASE_PATCH 0
\ No newline at end of file