Version 2.18.0-60.0.dev

Merge commit '79a78bde6da26c39e0dc3e621fc01b63ba9b395b' into 'dev'
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 1f5bb85..0531d3b 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -15,7 +15,6 @@
 import 'package:analysis_server/src/channel/channel.dart';
 import 'package:analysis_server/src/computer/computer_highlights.dart';
 import 'package:analysis_server/src/context_manager.dart';
-import 'package:analysis_server/src/domain_completion.dart';
 import 'package:analysis_server/src/domain_server.dart';
 import 'package:analysis_server/src/domains/analysis/occurrences.dart';
 import 'package:analysis_server/src/domains/analysis/occurrences_dart.dart';
@@ -36,6 +35,11 @@
 import 'package:analysis_server/src/handler/legacy/analytics_is_enabled.dart';
 import 'package:analysis_server/src/handler/legacy/analytics_send_event.dart';
 import 'package:analysis_server/src/handler/legacy/analytics_send_timing.dart';
+import 'package:analysis_server/src/handler/legacy/completion_get_suggestion_details.dart';
+import 'package:analysis_server/src/handler/legacy/completion_get_suggestion_details2.dart';
+import 'package:analysis_server/src/handler/legacy/completion_get_suggestions.dart';
+import 'package:analysis_server/src/handler/legacy/completion_get_suggestions2.dart';
+import 'package:analysis_server/src/handler/legacy/completion_set_subscriptions.dart';
 import 'package:analysis_server/src/handler/legacy/diagnostic_get_diagnostics.dart';
 import 'package:analysis_server/src/handler/legacy/diagnostic_get_server_port.dart';
 import 'package:analysis_server/src/handler/legacy/edit_bulk_fixes.dart';
@@ -142,6 +146,14 @@
     ANALYTICS_REQUEST_SEND_EVENT: AnalyticsSendEventHandler.new,
     ANALYTICS_REQUEST_SEND_TIMING: AnalyticsSendTimingHandler.new,
     //
+    COMPLETION_REQUEST_GET_SUGGESTION_DETAILS:
+        CompletionGetSuggestionDetailsHandler.new,
+    COMPLETION_REQUEST_GET_SUGGESTION_DETAILS2:
+        CompletionGetSuggestionDetails2Handler.new,
+    COMPLETION_REQUEST_GET_SUGGESTIONS: CompletionGetSuggestionsHandler.new,
+    COMPLETION_REQUEST_GET_SUGGESTIONS2: CompletionGetSuggestions2Handler.new,
+    COMPLETION_REQUEST_SET_SUBSCRIPTIONS: CompletionSetSubscriptionsHandler.new,
+    //
     DIAGNOSTIC_REQUEST_GET_DIAGNOSTICS: DiagnosticGetDiagnosticsHandler.new,
     DIAGNOSTIC_REQUEST_GET_SERVER_PORT: DiagnosticGetServerPortHandler.new,
     //
@@ -354,7 +366,6 @@
         .listen(handleRequest, onDone: done, onError: error);
     handlers = <server.RequestHandler>[
       ServerDomainHandler(this),
-      CompletionDomainHandler(this),
     ];
     refactoringWorkspace = RefactoringWorkspace(driverMap.values, searchEngine);
     _newRefactoringManager();
diff --git a/pkg/analysis_server/lib/src/domain_completion.dart b/pkg/analysis_server/lib/src/domain_completion.dart
deleted file mode 100644
index 8c638be..0000000
--- a/pkg/analysis_server/lib/src/domain_completion.dart
+++ /dev/null
@@ -1,71 +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 'dart:async';
-
-import 'package:analysis_server/protocol/protocol.dart';
-import 'package:analysis_server/protocol/protocol_constants.dart';
-import 'package:analysis_server/src/domain_abstract.dart';
-import 'package:analysis_server/src/handler/legacy/completion_get_suggestion_details.dart';
-import 'package:analysis_server/src/handler/legacy/completion_get_suggestion_details2.dart';
-import 'package:analysis_server/src/handler/legacy/completion_get_suggestions.dart';
-import 'package:analysis_server/src/handler/legacy/completion_get_suggestions2.dart';
-import 'package:analysis_server/src/handler/legacy/completion_set_subscriptions.dart';
-import 'package:analyzer/exception/exception.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/utilities/cancellation.dart';
-
-/// Instances of the class [CompletionDomainHandler] implement a
-/// [RequestHandler] that handles requests in the completion domain.
-class CompletionDomainHandler extends AbstractRequestHandler {
-  /// Initialize a new request handler for the given [server].
-  CompletionDomainHandler(super.server);
-
-  @override
-  Response? handleRequest(
-      Request request, CancellationToken cancellationToken) {
-    if (!server.options.featureSet.completion) {
-      return Response.invalidParameter(
-        request,
-        'request',
-        'The completion feature is not enabled',
-      );
-    }
-
-    return runZonedGuarded<Response?>(() {
-      var requestName = request.method;
-
-      if (requestName == COMPLETION_REQUEST_GET_SUGGESTION_DETAILS) {
-        CompletionGetSuggestionDetailsHandler(
-                server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == COMPLETION_REQUEST_GET_SUGGESTION_DETAILS2) {
-        CompletionGetSuggestionDetails2Handler(
-                server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == COMPLETION_REQUEST_GET_SUGGESTIONS) {
-        CompletionGetSuggestionsHandler(server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == COMPLETION_REQUEST_GET_SUGGESTIONS2) {
-        CompletionGetSuggestions2Handler(server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      } else if (requestName == COMPLETION_REQUEST_SET_SUBSCRIPTIONS) {
-        CompletionSetSubscriptionsHandler(server, request, cancellationToken)
-            .handle();
-        return Response.DELAYED_RESPONSE;
-      }
-      return null;
-    }, (exception, stackTrace) {
-      AnalysisEngine.instance.instrumentationService.logException(
-          CaughtException.withMessage(
-              'Failed to handle completion domain request: ${request.method}',
-              exception,
-              stackTrace));
-    });
-  }
-}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details.dart
index aff9a0f..7ae239f 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details.dart
@@ -11,7 +11,7 @@
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
 
 /// The handler for the `completion.getSuggestionDetails` request.
-class CompletionGetSuggestionDetailsHandler extends LegacyHandler {
+class CompletionGetSuggestionDetailsHandler extends CompletionHandler {
   /// The identifiers of the latest `getSuggestionDetails` request.
   /// We use it to abort previous requests.
   int _latestGetSuggestionDetailsId = 0;
@@ -23,6 +23,10 @@
 
   @override
   Future<void> handle() async {
+    if (completionIsDisabled) {
+      return;
+    }
+
     var params = CompletionGetSuggestionDetailsParams.fromRequest(request);
 
     var file = params.file;
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details2.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details2.dart
index 34cdede..fb74cca 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details2.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestion_details2.dart
@@ -12,7 +12,7 @@
 import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
 
 /// The handler for the `completion.getSuggestionDetails2` request.
-class CompletionGetSuggestionDetails2Handler extends LegacyHandler {
+class CompletionGetSuggestionDetails2Handler extends CompletionHandler {
   /// The identifiers of the latest `getSuggestionDetails2` request.
   /// We use it to abort previous requests.
   int _latestGetSuggestionDetailsId = 0;
@@ -24,6 +24,10 @@
 
   @override
   Future<void> handle() async {
+    if (completionIsDisabled) {
+      return;
+    }
+
     var params = CompletionGetSuggestionDetails2Params.fromRequest(request);
 
     var file = params.file;
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
index 459c089..3ce2461 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions.dart
@@ -24,6 +24,10 @@
 
   @override
   Future<void> handle() async {
+    if (completionIsDisabled) {
+      return;
+    }
+
     var budget = CompletionBudget(server.completionState.budgetDuration);
 
     // extract and validate params
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
index 1d17711..5a08236 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart
@@ -27,7 +27,7 @@
 import 'package:collection/collection.dart';
 
 /// The handler for the `completion.getSuggestions2` request.
-class CompletionGetSuggestions2Handler extends LegacyHandler
+class CompletionGetSuggestions2Handler extends CompletionHandler
     with RequestHandlerMixin<AnalysisServer> {
   /// Initialize a newly created handler to be able to service requests for the
   /// [server].
@@ -107,6 +107,10 @@
 
   @override
   Future<void> handle() async {
+    if (completionIsDisabled) {
+      return;
+    }
+
     var params = CompletionGetSuggestions2Params.fromRequest(request);
     var file = params.file;
     var offset = params.offset;
diff --git a/pkg/analysis_server/lib/src/handler/legacy/completion_set_subscriptions.dart b/pkg/analysis_server/lib/src/handler/legacy/completion_set_subscriptions.dart
index 14dbe993..bd516d4 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/completion_set_subscriptions.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/completion_set_subscriptions.dart
@@ -9,7 +9,7 @@
 import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
 
 /// The handler for the `completion.setSubscriptions` request.
-class CompletionSetSubscriptionsHandler extends LegacyHandler {
+class CompletionSetSubscriptionsHandler extends CompletionHandler {
   /// Initialize a newly created handler to be able to service requests for the
   /// [server].
   CompletionSetSubscriptionsHandler(
@@ -17,6 +17,10 @@
 
   @override
   Future<void> handle() async {
+    if (completionIsDisabled) {
+      return;
+    }
+
     var params = CompletionSetSubscriptionsParams.fromRequest(request);
 
     var subscriptions = server.completionState.subscriptions;
diff --git a/pkg/analysis_server/lib/src/handler/legacy/legacy_handler.dart b/pkg/analysis_server/lib/src/handler/legacy/legacy_handler.dart
index aaaefdeb..794ddfe 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/legacy_handler.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/legacy_handler.dart
@@ -13,6 +13,28 @@
 import 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
 import 'package:analyzer/src/utilities/cancellation.dart';
 
+/// A request handler for the completion domain.
+abstract class CompletionHandler extends LegacyHandler {
+  /// Initialize a newly created handler to be able to service requests for the
+  /// [server].
+  CompletionHandler(super.server, super.request, super.cancellationToken);
+
+  /// Return `true` if completion is disabled and the handler should return. If
+  /// `true` is returned then a response will already have been returned, so
+  /// subclasses should not return a second response.
+  bool get completionIsDisabled {
+    if (!server.options.featureSet.completion) {
+      sendResponse(Response.invalidParameter(
+        request,
+        'request',
+        'The completion feature is not enabled',
+      ));
+      return true;
+    }
+    return false;
+  }
+}
+
 /// A request handler for the legacy protocol.
 abstract class LegacyHandler {
   /// The analysis server that is using this handler to process a request.
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index d2bffce..826f5cb 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -10,7 +10,6 @@
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analysis_server/src/analysis_server.dart';
 import 'package:analysis_server/src/analysis_server_abstract.dart';
-import 'package:analysis_server/src/domain_completion.dart';
 import 'package:analysis_server/src/lsp/lsp_analysis_server.dart'
     show LspAnalysisServer;
 import 'package:analysis_server/src/plugin/plugin_manager.dart';
@@ -356,13 +355,8 @@
 
   CompletionPage(super.site, this.server);
 
-  CompletionDomainHandler get completionDomain => server.handlers
-          .firstWhere((handler) => handler is CompletionDomainHandler)
-      as CompletionDomainHandler;
-
   @override
-  path.Context get pathContext =>
-      completionDomain.server.resourceProvider.pathContext;
+  path.Context get pathContext => server.resourceProvider.pathContext;
 
   @override
   List<CompletionPerformance> get performanceItems =>
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index e6f16c0..b7fddeb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -43,11 +43,6 @@
 import 'package:path/path.dart' as package_path;
 import 'package:pub_semver/pub_semver.dart';
 
-var counterFileStateRefresh = 0;
-var counterUnlinkedBytes = 0;
-var counterUnlinkedLinkedBytes = 0;
-var timerFileStateRefresh = Stopwatch();
-
 /// A library from [SummaryDataStore].
 class ExternalLibrary {
   final Uri uri;
@@ -382,13 +377,6 @@
   ///
   /// Return how the file changed since the last refresh.
   FileStateRefreshResult refresh() {
-    counterFileStateRefresh++;
-
-    var timerWasRunning = timerFileStateRefresh.isRunning;
-    if (!timerWasRunning) {
-      timerFileStateRefresh.start();
-    }
-
     _invalidateCurrentUnresolvedData();
 
     final rawFileState = _fsState._fileContentCache.get(path);
@@ -468,10 +456,6 @@
       files.add(this);
     }
 
-    if (!timerWasRunning) {
-      timerFileStateRefresh.stop();
-    }
-
     // Return how the file changed.
     if (apiSignatureChanged) {
       return FileStateRefreshResult.apiChanged;
@@ -528,8 +512,6 @@
       );
       var bytes = driverUnlinkedUnit.toBytes();
       _fsState._byteStore.put(_unlinkedKey!, bytes);
-      counterUnlinkedBytes += bytes.length;
-      counterUnlinkedLinkedBytes += bytes.length;
       return driverUnlinkedUnit;
     });
   }
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index f1ad356..b4ff5c0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -52,13 +52,6 @@
 import 'package:analyzer/src/util/performance/operation_performance.dart';
 import 'package:analyzer/src/util/uri.dart';
 
-var timerLibraryAnalyzer = Stopwatch();
-var timerLibraryAnalyzerConst = Stopwatch();
-var timerLibraryAnalyzerFreshUnit = Stopwatch();
-var timerLibraryAnalyzerResolve = Stopwatch();
-var timerLibraryAnalyzerSplicer = Stopwatch();
-var timerLibraryAnalyzerVerify = Stopwatch();
-
 class AnalysisForCompletionResult {
   final CompilationUnit parsedUnit;
   final List<AstNode> resolvedNodes;
@@ -112,7 +105,6 @@
       errors = _filterIgnoredErrors(file, errors);
       results.add(UnitAnalysisResult(file, unit, errors));
     });
-    timerLibraryAnalyzer.stop();
     return results;
   }
 
@@ -258,7 +250,6 @@
   /// Compute diagnostics in [units], including errors and warnings, hints,
   /// lints, and a few other cases.
   void _computeDiagnostics(Map<FileState, CompilationUnitImpl> units) {
-    timerLibraryAnalyzerVerify.start();
     units.forEach((file, unit) {
       _computeVerifyErrors(file, unit);
     });
@@ -313,7 +304,6 @@
         _analysisOptions.unignorableNames,
       ).reportErrors();
     }
-    timerLibraryAnalyzerVerify.stop();
   }
 
   void _computeHints(
@@ -575,15 +565,12 @@
 
   /// Parse and resolve all files in [_library].
   Map<FileState, CompilationUnitImpl> _parseAndResolve() {
-    timerLibraryAnalyzer.start();
     var units = <FileState, CompilationUnitImpl>{};
 
     // Parse all files.
-    timerLibraryAnalyzerFreshUnit.start();
     for (FileState file in _library.libraryFiles) {
       units[file] = _parse(file);
     }
-    timerLibraryAnalyzerFreshUnit.stop();
 
     // Resolve URIs in directives to corresponding sources.
     FeatureSet featureSet = units[_library]!.featureSet;
@@ -592,18 +579,13 @@
       _resolveUriBasedDirectives(file, unit);
     });
 
-    timerLibraryAnalyzerResolve.start();
     _resolveDirectives(units);
 
     units.forEach((file, unit) {
       _resolveFile(file, unit);
     });
-    timerLibraryAnalyzerResolve.stop();
-
-    timerLibraryAnalyzerConst.start();
 
     _computeConstants(units.values);
-    timerLibraryAnalyzerConst.stop();
 
     return units;
   }
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 3d44aa2..311c3b0 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -28,13 +28,6 @@
 import 'package:analyzer/src/summary2/reference.dart';
 import 'package:path/src/context.dart';
 
-var counterLinkedLibraries = 0;
-var counterLoadedLibraries = 0;
-var timerBundleToBytes = Stopwatch(); // TODO(scheglov) use
-var timerInputLibraries = Stopwatch();
-var timerLinking = Stopwatch();
-var timerLoad = Stopwatch();
-
 /// Context information necessary to analyze one or more libraries within an
 /// [AnalysisDriver].
 ///
@@ -113,7 +106,6 @@
 
   /// Load data required to access elements of the given [targetLibrary].
   Future<void> load(FileState targetLibrary) async {
-    timerLoad.start();
     var librariesTotal = 0;
     var librariesLoaded = 0;
     var librariesLinked = 0;
@@ -170,7 +162,6 @@
           cycle.libraries.map((e) => e.path).toSet(),
         );
 
-        timerInputLibraries.start();
         inputsTimer.start();
         var inputLibraries = <LinkInputLibrary>[];
         for (var libraryFile in cycle.libraries) {
@@ -209,16 +200,12 @@
           );
         }
         inputsTimer.stop();
-        timerInputLibraries.stop();
 
         LinkResult linkResult;
         try {
-          timerLinking.start();
           linkResult = await link(elementFactory, inputLibraries,
               macroExecutor: macroExecutor);
           librariesLinked += cycle.libraries.length;
-          counterLinkedLibraries += inputLibraries.length;
-          timerLinking.stop();
         } catch (exception, stackTrace) {
           _throwLibraryCycleLinkException(cycle, exception, stackTrace);
         }
@@ -226,7 +213,6 @@
         resolutionBytes = linkResult.resolutionBytes;
         byteStore.put(resolutionKey, resolutionBytes);
         bytesPut += resolutionBytes.length;
-        counterUnlinkedLinkedBytes += resolutionBytes.length;
 
         librariesLinkedTimer.stop();
       } else {
@@ -290,8 +276,6 @@
     // already include the [targetLibrary]. When this happens, [loadBundle]
     // exists without doing any work. But the type provider must be created.
     _createElementFactoryTypeProvider();
-
-    timerLoad.stop();
   }
 
   /// Ensure that type provider is created.
diff --git a/pkg/analyzer/lib/src/summary2/link.dart b/pkg/analyzer/lib/src/summary2/link.dart
index 819b202..b68a8cf 100644
--- a/pkg/analyzer/lib/src/summary2/link.dart
+++ b/pkg/analyzer/lib/src/summary2/link.dart
@@ -25,8 +25,6 @@
 import 'package:analyzer/src/summary2/types_builder.dart';
 import 'package:analyzer/src/summary2/variance_builder.dart';
 
-var timerLinkingLinkingBundle = Stopwatch();
-
 /// Note that AST units and tokens of [inputLibraries] will be damaged.
 Future<LinkResult> link(
   LinkedElementFactory elementFactory,
@@ -85,10 +83,7 @@
     }
 
     await _buildOutlines();
-
-    timerLinkingLinkingBundle.start();
     _writeLibraries();
-    timerLinkingLinkingBundle.stop();
   }
 
   void _buildEnumChildren() {
diff --git a/pkg/frontend_server/lib/src/binary_protocol.dart b/pkg/frontend_server/lib/src/binary_protocol.dart
index 25fc45d..714dc05 100644
--- a/pkg/frontend_server/lib/src/binary_protocol.dart
+++ b/pkg/frontend_server/lib/src/binary_protocol.dart
@@ -141,7 +141,7 @@
       filter: (library) {
         return !library.importUri.isScheme('dart');
       },
-      includeSources: false,
+      includeSources: true,
     );
   }
 }
diff --git a/tools/VERSION b/tools/VERSION
index b8f61eb..f81f109 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 18
 PATCH 0
-PRERELEASE 59
+PRERELEASE 60
 PRERELEASE_PATCH 0
\ No newline at end of file