Skip to content

Commit

Permalink
DAS: Small fixes for LegacyAnalysisServer docs and ctor
Browse files Browse the repository at this point in the history
* Fix two comment references
* Mark AnalysisServer().enableBlazeWatcher as `@visibleForTesting`.
* Use named super parameters where possible.

Change-Id: Ic2561c7dd1a661857fbe2e7577fb29c55a5d57b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402440
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Auto-Submit: Samuel Rawlins <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
  • Loading branch information
srawlins authored and Commit Queue committed Dec 26, 2024
1 parent b12fa8c commit a3ef455
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
3 changes: 2 additions & 1 deletion pkg/analysis_server/lib/src/analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ abstract class AnalysisServer {
ProcessRunner? processRunner,
this.notificationManager, {
this.requestStatistics,
bool enableBlazeWatcher = false,
// Disable to avoid using this in unit tests.
@visibleForTesting bool enableBlazeWatcher = false,
DartFixPromptManager? dartFixPromptManager,
this.providedByteStore,
PluginManager? pluginManager,
Expand Down
41 changes: 14 additions & 27 deletions pkg/analysis_server/lib/src/legacy_analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ import 'package:analysis_server/src/services/completion/completion_state.dart';
import 'package:analysis_server/src/services/execution/execution_context.dart';
import 'package:analysis_server/src/services/flutter/widget_descriptions.dart';
import 'package:analysis_server/src/services/refactoring/legacy/refactoring_manager.dart';
import 'package:analysis_server/src/services/user_prompts/dart_fix_prompt_manager.dart';
import 'package:analysis_server/src/utilities/process.dart';
import 'package:analysis_server/src/utilities/request_statistics.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/ast/ast.dart';
Expand Down Expand Up @@ -167,8 +165,8 @@ class AnalysisServerOptions {
}

/// Instances of the class [LegacyAnalysisServer] implement a server that
/// listens on a [CommunicationChannel] for analysis requests and processes
/// them.
/// listens on a [ServerCommunicationChannel] for analysis requests and
/// processes them.
class LegacyAnalysisServer extends AnalysisServer {
/// A map from the name of a request to a function used to create a request
/// handler.
Expand All @@ -192,19 +190,19 @@ class LegacyAnalysisServer extends AnalysisServer {
ANALYSIS_REQUEST_SET_SUBSCRIPTIONS: AnalysisSetSubscriptionsHandler.new,
ANALYSIS_REQUEST_UPDATE_CONTENT: AnalysisUpdateContentHandler.new,
ANALYSIS_REQUEST_UPDATE_OPTIONS: AnalysisUpdateOptionsHandler.new,
//

ANALYTICS_REQUEST_IS_ENABLED: AnalyticsIsEnabledHandler.new,
ANALYTICS_REQUEST_ENABLE: AnalyticsEnableHandler.new,
ANALYTICS_REQUEST_SEND_EVENT: AnalyticsSendEventHandler.new,
ANALYTICS_REQUEST_SEND_TIMING: AnalyticsSendTimingHandler.new,
//

COMPLETION_REQUEST_GET_SUGGESTION_DETAILS2:
CompletionGetSuggestionDetails2Handler.new,
COMPLETION_REQUEST_GET_SUGGESTIONS2: CompletionGetSuggestions2Handler.new,
//

DIAGNOSTIC_REQUEST_GET_DIAGNOSTICS: DiagnosticGetDiagnosticsHandler.new,
DIAGNOSTIC_REQUEST_GET_SERVER_PORT: DiagnosticGetServerPortHandler.new,
//

EDIT_REQUEST_FORMAT: EditFormatHandler.new,
EDIT_REQUEST_FORMAT_IF_ENABLED: EditFormatIfEnabledHandler.new,
EDIT_REQUEST_GET_ASSISTS: EditGetAssistsHandler.new,
Expand All @@ -223,19 +221,19 @@ class LegacyAnalysisServer extends AnalysisServer {
EDIT_REQUEST_GET_POSTFIX_COMPLETION: EditGetPostfixCompletionHandler.new,
EDIT_REQUEST_LIST_POSTFIX_COMPLETION_TEMPLATES:
EditListPostfixCompletionTemplatesHandler.new,
//

EXECUTION_REQUEST_CREATE_CONTEXT: ExecutionCreateContextHandler.new,
EXECUTION_REQUEST_DELETE_CONTEXT: ExecutionDeleteContextHandler.new,
EXECUTION_REQUEST_GET_SUGGESTIONS: ExecutionGetSuggestionsHandler.new,
EXECUTION_REQUEST_MAP_URI: ExecutionMapUriHandler.new,
EXECUTION_REQUEST_SET_SUBSCRIPTIONS: ExecutionSetSubscriptionsHandler.new,
//

FLUTTER_REQUEST_GET_WIDGET_DESCRIPTION:
FlutterGetWidgetDescriptionHandler.new,
FLUTTER_REQUEST_SET_WIDGET_PROPERTY_VALUE:
FlutterSetWidgetPropertyValueHandler.new,
FLUTTER_REQUEST_SET_SUBSCRIPTIONS: FlutterSetSubscriptionsHandler.new,
//

SEARCH_REQUEST_FIND_ELEMENT_REFERENCES:
SearchFindElementReferencesHandler.new,
SEARCH_REQUEST_FIND_MEMBER_DECLARATIONS:
Expand All @@ -247,15 +245,14 @@ class LegacyAnalysisServer extends AnalysisServer {
SEARCH_REQUEST_GET_ELEMENT_DECLARATIONS:
SearchGetElementDeclarationsHandler.new,
SEARCH_REQUEST_GET_TYPE_HIERARCHY: SearchGetTypeHierarchyHandler.new,
//

SERVER_REQUEST_CANCEL_REQUEST: ServerCancelRequestHandler.new,
SERVER_REQUEST_GET_VERSION: ServerGetVersionHandler.new,
SERVER_REQUEST_SET_CLIENT_CAPABILITIES:
ServerSetClientCapabilitiesHandler.new,
SERVER_REQUEST_SET_SUBSCRIPTIONS: ServerSetSubscriptionsHandler.new,
SERVER_REQUEST_SHUTDOWN: ServerShutdownHandler.new,

//
LSP_REQUEST_HANDLE: LspOverLegacyHandler.new,
};

Expand Down Expand Up @@ -364,11 +361,6 @@ class LegacyAnalysisServer extends AnalysisServer {

/// Initialize a newly created server to receive requests from and send
/// responses to the given [channel].
///
/// If [rethrowExceptions] is true, then any exceptions thrown by analysis are
/// propagated up the call stack. The default is true to allow analysis
/// exceptions to show up in unit tests, but it should be set to false when
/// running a full analysis server.
LegacyAnalysisServer(
this.channel,
ResourceProvider baseResourceProvider,
Expand All @@ -379,15 +371,14 @@ class LegacyAnalysisServer extends AnalysisServer {
InstrumentationService instrumentationService, {
http.Client? httpClient,
ProcessRunner? processRunner,
RequestStatisticsHelper? requestStatistics,
super.requestStatistics,
DiagnosticServer? diagnosticServer,
this.detachableFileSystemManager,
// Disable to avoid using this in unit tests.
bool enableBlazeWatcher = false,
DartFixPromptManager? dartFixPromptManager,
super.enableBlazeWatcher,
super.dartFixPromptManager,
super.providedByteStore,
super.pluginManager,
bool retainDataForTesting = false,
super.retainDataForTesting,
}) : lspClientConfiguration = lsp.LspClientConfiguration(
baseResourceProvider.pathContext,
),
Expand All @@ -402,10 +393,6 @@ class LegacyAnalysisServer extends AnalysisServer {
httpClient,
processRunner,
NotificationManager(channel, baseResourceProvider.pathContext),
requestStatistics: requestStatistics,
enableBlazeWatcher: enableBlazeWatcher,
dartFixPromptManager: dartFixPromptManager,
retainDataForTesting: retainDataForTesting,
) {
var contextManagerCallbacks = ServerContextManagerCallbacks(
this,
Expand Down
11 changes: 3 additions & 8 deletions pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import 'package:analysis_server/src/server/diagnostic_server.dart';
import 'package:analysis_server/src/server/error_notifier.dart';
import 'package:analysis_server/src/server/message_scheduler.dart';
import 'package:analysis_server/src/server/performance.dart';
import 'package:analysis_server/src/services/user_prompts/dart_fix_prompt_manager.dart';
import 'package:analysis_server/src/utilities/process.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
Expand Down Expand Up @@ -160,10 +159,9 @@ class LspAnalysisServer extends AnalysisServer {
ProcessRunner? processRunner,
DiagnosticServer? diagnosticServer,
this.detachableFileSystemManager,
// Disable to avoid using this in unit tests.
bool enableBlazeWatcher = false,
DartFixPromptManager? dartFixPromptManager,
bool retainDataForTesting = false,
super.enableBlazeWatcher,
super.dartFixPromptManager,
super.retainDataForTesting,
}) : lspClientConfiguration = LspClientConfiguration(
baseResourceProvider.pathContext,
),
Expand All @@ -178,9 +176,6 @@ class LspAnalysisServer extends AnalysisServer {
httpClient,
processRunner,
LspNotificationManager(baseResourceProvider.pathContext),
enableBlazeWatcher: enableBlazeWatcher,
dartFixPromptManager: dartFixPromptManager,
retainDataForTesting: retainDataForTesting,
) {
notificationManager.server = this;
messageHandler = UninitializedStateMessageHandler(this);
Expand Down

0 comments on commit a3ef455

Please sign in to comment.