diff --git a/pkg/analysis_server/analysis_options.yaml b/pkg/analysis_server/analysis_options.yaml index 548d7ea2664..a72e0f79c84 100644 --- a/pkg/analysis_server/analysis_options.yaml +++ b/pkg/analysis_server/analysis_options.yaml @@ -12,7 +12,6 @@ analyzer: # Lints from the recommended set that conflict w/ analyzer style or will # require some work to reach compliance. # See: https://github.com/dart-lang/sdk/issues/48785 - avoid_renaming_method_parameters: ignore camel_case_types: ignore constant_identifier_names: ignore file_names: ignore diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart index 84ccaaca635..b303906f42c 100644 --- a/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart +++ b/pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart @@ -2778,7 +2778,8 @@ class CodeActionKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is CodeActionKind && o._value == _value; + bool operator ==(Object other) => + other is CodeActionKind && other._value == _value; } class CodeActionLiteralSupportCodeActionKind implements ToJsonable { @@ -3354,8 +3355,8 @@ class CodeActionTriggerKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is CodeActionTriggerKind && o._value == _value; + bool operator ==(Object other) => + other is CodeActionTriggerKind && other._value == _value; } /// Structure to capture a description for an error code. @@ -6192,7 +6193,8 @@ class CompletionItemKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is CompletionItemKind && o._value == _value; + bool operator ==(Object other) => + other is CompletionItemKind && other._value == _value; } /// Additional details for a completion item label. @@ -6385,7 +6387,8 @@ class CompletionItemTag implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is CompletionItemTag && o._value == _value; + bool operator ==(Object other) => + other is CompletionItemTag && other._value == _value; } class CompletionItemTagSupport implements ToJsonable { @@ -7563,8 +7566,8 @@ class CompletionTriggerKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is CompletionTriggerKind && o._value == _value; + bool operator ==(Object other) => + other is CompletionTriggerKind && other._value == _value; } class ConfigurationItem implements ToJsonable { @@ -10145,7 +10148,8 @@ class DiagnosticSeverity implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is DiagnosticSeverity && o._value == _value; + bool operator ==(Object other) => + other is DiagnosticSeverity && other._value == _value; } /// The diagnostic tags. @@ -10179,7 +10183,8 @@ class DiagnosticTag implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is DiagnosticTag && o._value == _value; + bool operator ==(Object other) => + other is DiagnosticTag && other._value == _value; } /// Workspace client capabilities specific to diagnostic pull requests. @@ -12065,8 +12070,8 @@ class DocumentDiagnosticReportKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is DocumentDiagnosticReportKind && o._value == _value; + bool operator ==(Object other) => + other is DocumentDiagnosticReportKind && other._value == _value; } /// A partial result for a document diagnostic report. @@ -12726,8 +12731,8 @@ class DocumentHighlightKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is DocumentHighlightKind && o._value == _value; + bool operator ==(Object other) => + other is DocumentHighlightKind && other._value == _value; } class DocumentHighlightOptions implements WorkDoneProgressOptions, ToJsonable { @@ -15514,7 +15519,8 @@ class ErrorCodes implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is ErrorCodes && o._value == _value; + bool operator ==(Object other) => + other is ErrorCodes && other._value == _value; } class ExecuteCommandClientCapabilities implements ToJsonable { @@ -16040,7 +16046,8 @@ class FailureHandlingKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is FailureHandlingKind && o._value == _value; + bool operator ==(Object other) => + other is FailureHandlingKind && other._value == _value; } /// The file event type. @@ -16071,7 +16078,8 @@ class FileChangeType implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is FileChangeType && o._value == _value; + bool operator ==(Object other) => + other is FileChangeType && other._value == _value; } /// Represents information on a file/folder create. @@ -16980,8 +16988,8 @@ class FileOperationPatternKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is FileOperationPatternKind && o._value == _value; + bool operator ==(Object other) => + other is FileOperationPatternKind && other._value == _value; } /// Matching options for the file operation pattern. @@ -17873,7 +17881,8 @@ class FoldingRangeKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is FoldingRangeKind && o._value == _value; + bool operator ==(Object other) => + other is FoldingRangeKind && other._value == _value; } class FoldingRangeOptions implements WorkDoneProgressOptions, ToJsonable { @@ -20823,7 +20832,8 @@ class InlayHintKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is InlayHintKind && o._value == _value; + bool operator ==(Object other) => + other is InlayHintKind && other._value == _value; } /// An inlay hint label part allows for interactive and composite labels of @@ -22529,7 +22539,8 @@ class InsertTextFormat implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is InsertTextFormat && o._value == _value; + bool operator ==(Object other) => + other is InsertTextFormat && other._value == _value; } /// How whitespace and indentation is handled during completion item insertion. @@ -22566,7 +22577,8 @@ class InsertTextMode implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is InsertTextMode && o._value == _value; + bool operator ==(Object other) => + other is InsertTextMode && other._value == _value; } class LinkedEditingRangeClientCapabilities implements ToJsonable { @@ -23780,7 +23792,8 @@ class MarkupKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is MarkupKind && o._value == _value; + bool operator ==(Object other) => + other is MarkupKind && other._value == _value; } class MessageActionItem implements ToJsonable { @@ -23881,7 +23894,8 @@ class MessageType implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is MessageType && o._value == _value; + bool operator ==(Object other) => + other is MessageType && other._value == _value; } /// Valid LSP methods known at the time of code generation from the spec. @@ -24207,7 +24221,7 @@ class Method implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is Method && o._value == _value; + bool operator ==(Object other) => other is Method && other._value == _value; } /// Moniker definition to match LSIF 0.5 moniker definition. @@ -24457,7 +24471,8 @@ class MonikerKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is MonikerKind && o._value == _value; + bool operator ==(Object other) => + other is MonikerKind && other._value == _value; } class MonikerOptions implements WorkDoneProgressOptions, ToJsonable { @@ -25084,7 +25099,8 @@ class NotebookCellKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is NotebookCellKind && o._value == _value; + bool operator ==(Object other) => + other is NotebookCellKind && other._value == _value; } /// A notebook cell text document filter denotes a cell text document by @@ -27720,7 +27736,8 @@ class PositionEncodingKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is PositionEncodingKind && o._value == _value; + bool operator ==(Object other) => + other is PositionEncodingKind && other._value == _value; } class PrepareRenameParams implements TextDocumentPositionParams, ToJsonable { @@ -27846,8 +27863,8 @@ class PrepareSupportDefaultBehavior implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is PrepareSupportDefaultBehavior && o._value == _value; + bool operator ==(Object other) => + other is PrepareSupportDefaultBehavior && other._value == _value; } /// A previous result id in a workspace pull request. @@ -30646,8 +30663,8 @@ class ResourceOperationKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is ResourceOperationKind && o._value == _value; + bool operator ==(Object other) => + other is ResourceOperationKind && other._value == _value; } class SaveOptions implements ToJsonable { @@ -31255,8 +31272,8 @@ class SemanticTokenModifiers implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is SemanticTokenModifiers && o._value == _value; + bool operator ==(Object other) => + other is SemanticTokenModifiers && other._value == _value; } class SemanticTokenTypes implements ToJsonable { @@ -31303,7 +31320,8 @@ class SemanticTokenTypes implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is SemanticTokenTypes && o._value == _value; + bool operator ==(Object other) => + other is SemanticTokenTypes && other._value == _value; } class SemanticTokens implements ToJsonable { @@ -36599,8 +36617,8 @@ class SignatureHelpTriggerKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is SignatureHelpTriggerKind && o._value == _value; + bool operator ==(Object other) => + other is SignatureHelpTriggerKind && other._value == _value; } /// Represents the signature of something callable. A signature can have a @@ -37200,7 +37218,8 @@ class SymbolKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is SymbolKind && o._value == _value; + bool operator ==(Object other) => + other is SymbolKind && other._value == _value; } /// Symbol tags are extra annotations that tweak the rendering of a symbol. @@ -37226,7 +37245,8 @@ class SymbolTag implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is SymbolTag && o._value == _value; + bool operator ==(Object other) => + other is SymbolTag && other._value == _value; } /// Describe options to be used when registering for text document change @@ -39232,8 +39252,8 @@ class TextDocumentSaveReason implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => - o is TextDocumentSaveReason && o._value == _value; + bool operator ==(Object other) => + other is TextDocumentSaveReason && other._value == _value; } class TextDocumentSaveRegistrationOptions @@ -39503,7 +39523,8 @@ class TextDocumentSyncKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is TextDocumentSyncKind && o._value == _value; + bool operator ==(Object other) => + other is TextDocumentSyncKind && other._value == _value; } class TextDocumentSyncOptions implements ToJsonable { @@ -39802,7 +39823,8 @@ class TokenFormat implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is TokenFormat && o._value == _value; + bool operator ==(Object other) => + other is TokenFormat && other._value == _value; } class TypeDefinitionClientCapabilities implements ToJsonable { @@ -41297,7 +41319,8 @@ class UniquenessLevel implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is UniquenessLevel && o._value == _value; + bool operator ==(Object other) => + other is UniquenessLevel && other._value == _value; } /// General parameters to unregister a capability. @@ -41708,7 +41731,8 @@ class WatchKind implements ToJsonable { @override int get hashCode => _value.hashCode; - bool operator ==(Object o) => o is WatchKind && o._value == _value; + bool operator ==(Object other) => + other is WatchKind && other._value == _value; } /// The parameters send in a will save text document notification. diff --git a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart index 57cce1705a2..610813f9cd9 100644 --- a/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart +++ b/pkg/analysis_server/lib/lsp_protocol/protocol_special.dart @@ -70,6 +70,7 @@ class Either2 { const Either2.t1(T1 this._t1) : _t2 = null, _which = 1; + const Either2.t2(T2 this._t2) : _t1 = null, _which = 2; @@ -78,8 +79,10 @@ class Either2 { int get hashCode => map(lspHashCode, lspHashCode); @override - bool operator ==(o) => - o is Either2 && lspEquals(o._t1, _t1) && lspEquals(o._t2, _t2); + bool operator ==(other) => + other is Either2 && + lspEquals(other._t1, _t1) && + lspEquals(other._t2, _t2); T map(T Function(T1) f1, T Function(T2) f2) { return _which == 1 ? f1(_t1 as T1) : f2(_t2 as T2); @@ -104,10 +107,12 @@ class Either3 { : _t2 = null, _t3 = null, _which = 1; + Either3.t2(this._t2) : _t1 = null, _t3 = null, _which = 2; + Either3.t3(this._t3) : _t1 = null, _t2 = null, @@ -117,11 +122,11 @@ class Either3 { int get hashCode => map(lspHashCode, lspHashCode, lspHashCode); @override - bool operator ==(o) => - o is Either3 && - lspEquals(o._t1, _t1) && - lspEquals(o._t2, _t2) && - lspEquals(o._t3, _t3); + bool operator ==(other) => + other is Either3 && + lspEquals(other._t1, _t1) && + lspEquals(other._t2, _t2) && + lspEquals(other._t3, _t3); T map(T Function(T1) f1, T Function(T2) f2, T Function(T3) f3) { switch (_which) { @@ -161,16 +166,19 @@ class Either4 { _t3 = null, _t4 = null, _which = 1; + Either4.t2(this._t2) : _t1 = null, _t3 = null, _t4 = null, _which = 2; + Either4.t3(this._t3) : _t1 = null, _t2 = null, _t4 = null, _which = 3; + Either4.t4(this._t4) : _t1 = null, _t2 = null, @@ -181,12 +189,12 @@ class Either4 { int get hashCode => map(lspHashCode, lspHashCode, lspHashCode, lspHashCode); @override - bool operator ==(o) => - o is Either4 && - lspEquals(o._t1, _t1) && - lspEquals(o._t2, _t2) && - lspEquals(o._t3, _t3) && - lspEquals(o._t4, _t4); + bool operator ==(other) => + other is Either4 && + lspEquals(other._t1, _t1) && + lspEquals(other._t2, _t2) && + lspEquals(other._t3, _t3) && + lspEquals(other._t4, _t4); T map(T Function(T1) f1, T Function(T2) f2, T Function(T3) f3, T Function(T4) f4) { @@ -221,6 +229,7 @@ class Either4 { class ErrorOr extends Either2 { ErrorOr.error(super.error) : super.t1(); + ErrorOr.success(super.result) : super.t2(); /// Returns the error or throws if object is not an error. Check [isError] diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart index 5974884b847..c2fa2c8a745 100644 --- a/pkg/analysis_server/lib/src/analysis_server.dart +++ b/pkg/analysis_server/lib/src/analysis_server.dart @@ -931,26 +931,25 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks { } @override - void listenAnalysisDriver(analysis.AnalysisDriver analysisDriver) { - analysisDriver.results.listen((result) { + void listenAnalysisDriver(analysis.AnalysisDriver driver) { + driver.results.listen((result) { if (result is FileResult) { _handleFileResult(result); } }); - analysisDriver.exceptions.listen(analysisServer.logExceptionResult); - analysisDriver.priorityFiles = analysisServer.priorityFiles.toList(); + driver.exceptions.listen(analysisServer.logExceptionResult); + driver.priorityFiles = analysisServer.priorityFiles.toList(); } @override - void pubspecChanged(String pubspecPath) { - analysisServer.pubPackageService.fetchPackageVersionsViaPubOutdated( - pubspecPath, - pubspecWasModified: true); + void pubspecChanged(String path) { + analysisServer.pubPackageService + .fetchPackageVersionsViaPubOutdated(path, pubspecWasModified: true); } @override - void pubspecRemoved(String pubspecPath) { - analysisServer.pubPackageService.flushPackageCaches(pubspecPath); + void pubspecRemoved(String path) { + analysisServer.pubPackageService.flushPackageCaches(path); } @override diff --git a/pkg/analysis_server/lib/src/channel/channel.dart b/pkg/analysis_server/lib/src/channel/channel.dart index 37a6e861caa..3005cf3673a 100644 --- a/pkg/analysis_server/lib/src/channel/channel.dart +++ b/pkg/analysis_server/lib/src/channel/channel.dart @@ -61,7 +61,7 @@ abstract class ClientCommunicationChannel { /// Instances of the class [JsonStreamDecoder] convert JSON strings to values. class JsonStreamDecoder extends Converter { @override - Object? convert(String text) => json.decode(text); + Object? convert(String input) => json.decode(input); @override ChunkedConversionSink startChunkedConversion(Sink sink) => @@ -73,7 +73,7 @@ class JsonStreamDecoder extends Converter { class NotificationConverter extends Converter, Notification> { @override - Notification convert(Map json) => Notification.fromJson(json); + Notification convert(Map input) => Notification.fromJson(input); @override ChunkedConversionSink> startChunkedConversion( @@ -84,7 +84,7 @@ class NotificationConverter /// Instances of the class [ResponseConverter] convert JSON maps to [Response]s. class ResponseConverter extends Converter, Response?> { @override - Response? convert(Map json) => Response.fromJson(json); + Response? convert(Map input) => Response.fromJson(input); @override ChunkedConversionSink> startChunkedConversion( diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart index c7109519ae9..414d320c572 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart @@ -139,7 +139,7 @@ abstract class AbstractRefactorCommandHandler extends SimpleEditCommandHandler { @override Future> handle(List? arguments, - ProgressReporter reporter, CancellationToken cancellationToken) async { + ProgressReporter progress, CancellationToken cancellationToken) async { if (arguments == null || arguments.length != 6 || arguments[0] is! String || // kind @@ -169,7 +169,7 @@ abstract class AbstractRefactorCommandHandler extends SimpleEditCommandHandler { final options = arguments[5] as Map?; return execute(path, kind, offset, length, options, cancellationToken, - reporter, docVersion); + progress, docVersion); } } diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/fix_all.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/fix_all.dart index c0c9aa7c8f0..6d0bdba0dc4 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/commands/fix_all.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/fix_all.dart @@ -19,7 +19,7 @@ class FixAllCommandHandler extends SimpleEditCommandHandler { @override Future> handle(List? arguments, - ProgressReporter reporter, CancellationToken cancellationToken) async { + ProgressReporter progress, CancellationToken cancellationToken) async { if (arguments == null || arguments.length != 1 || arguments[0] is! String) { return ErrorOr.error(ResponseError( code: ServerErrorCodes.InvalidCommandArguments, diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/organize_imports.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/organize_imports.dart index 5e5bcf9bbe8..e7e89ccbcac 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/commands/organize_imports.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/organize_imports.dart @@ -17,7 +17,7 @@ class OrganizeImportsCommandHandler extends SimpleEditCommandHandler { @override Future> handle(List? arguments, - ProgressReporter reporter, CancellationToken cancellationToken) async { + ProgressReporter progress, CancellationToken cancellationToken) async { if (arguments == null || arguments.length != 1 || arguments[0] is! String) { return ErrorOr.error(ResponseError( code: ServerErrorCodes.InvalidCommandArguments, diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/send_workspace_edit.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/send_workspace_edit.dart index 004349010e3..a430214e85a 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/commands/send_workspace_edit.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/send_workspace_edit.dart @@ -23,7 +23,7 @@ class SendWorkspaceEditCommandHandler extends SimpleEditCommandHandler { @override Future> handle(List? arguments, - ProgressReporter reporter, CancellationToken cancellationToken) async { + ProgressReporter progress, CancellationToken cancellationToken) async { if (arguments == null || arguments.length != 1 || arguments[0] is! Map) { diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart index 7634396bc0a..b008673f00d 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/sort_members.dart @@ -18,7 +18,7 @@ class SortMembersCommandHandler extends SimpleEditCommandHandler { @override Future> handle(List? arguments, - ProgressReporter reporter, CancellationToken cancellationToken) async { + ProgressReporter progress, CancellationToken cancellationToken) async { if (arguments == null || arguments.length != 1 || arguments[0] is! String) { return ErrorOr.error(ResponseError( code: ServerErrorCodes.InvalidCommandArguments, 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 index 067b15e74cf..d29f493f244 100644 --- 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 @@ -9,6 +9,7 @@ import 'package:analysis_server/src/lsp/handlers/handlers.dart'; class DiagnosticServerHandler extends MessageHandler { DiagnosticServerHandler(super.server); + @override Method get handlesMessage => CustomMethods.diagnosticServer; @@ -17,7 +18,7 @@ class DiagnosticServerHandler @override Future> handle( - void _, MessageInfo message, CancellationToken token) async { + void params, MessageInfo message, CancellationToken token) async { final diagnosticServer = server.diagnosticServer; if (diagnosticServer == null) { return error(ServerErrorCodes.FeatureDisabled, diff --git a/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_reanalyze.dart b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_reanalyze.dart index 4dde9915d91..b3355c2d862 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_reanalyze.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_reanalyze.dart @@ -8,6 +8,7 @@ import 'package:analysis_server/src/lsp/handlers/handlers.dart'; class ReanalyzeHandler extends MessageHandler { ReanalyzeHandler(super.server); + @override Method get handlesMessage => CustomMethods.reanalyze; @@ -16,7 +17,7 @@ class ReanalyzeHandler extends MessageHandler { @override Future> handle( - void _, MessageInfo message, CancellationToken token) async { + void params, MessageInfo message, CancellationToken token) async { server.reanalyze(); return success(null); } diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart index 195fe662cc4..772eb6bc52a 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_completion_resolve.dart @@ -33,18 +33,18 @@ class CompletionResolveHandler @override Future> handle( - CompletionItem item, + CompletionItem params, MessageInfo message, CancellationToken token, ) async { - final resolutionInfo = item.data; + final resolutionInfo = params.data; if (resolutionInfo is DartSuggestionSetCompletionItemResolutionInfo) { - return resolveDartSuggestionSetCompletion(item, resolutionInfo, token); + return resolveDartSuggestionSetCompletion(params, resolutionInfo, token); } else if (resolutionInfo is PubPackageCompletionItemResolutionInfo) { - return resolvePubPackageCompletion(item, resolutionInfo, token); + return resolvePubPackageCompletion(params, resolutionInfo, token); } else { - return success(item); + return success(params); } } diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_execute_command.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_execute_command.dart index ebf7cdc4b77..6a2cf7e898c 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_execute_command.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_execute_command.dart @@ -18,6 +18,7 @@ import 'package:analysis_server/src/lsp/progress.dart'; class ExecuteCommandHandler extends MessageHandler { final Map commandHandlers; + ExecuteCommandHandler(super.server) : commandHandlers = { Commands.sortMembers: SortMembersCommandHandler(server), @@ -37,7 +38,7 @@ class ExecuteCommandHandler @override Future> handle(ExecuteCommandParams params, - MessageInfo message, CancellationToken cancellationToken) async { + MessageInfo message, CancellationToken token) async { final handler = commandHandlers[params.command]; if (handler == null) { return error(ServerErrorCodes.UnknownCommand, @@ -50,6 +51,6 @@ class ExecuteCommandHandler : server.clientCapabilities?.workDoneProgress ?? false ? ProgressReporter.serverCreated(server) : ProgressReporter.noop; - return handler.handle(params.arguments, progress, cancellationToken); + return handler.handle(params.arguments, progress, token); } } diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart index e351b483feb..b8b2dbfe6e5 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_exit.dart @@ -23,7 +23,7 @@ class ExitMessageHandler extends MessageHandler { @override Future> handle( - void _, MessageInfo message, CancellationToken token) async { + void params, MessageInfo message, CancellationToken token) async { // Set a flag that the server shutdown is being controlled here to ensure // that the normal code that shuts down the server when the channel closes // does not fire. diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart index 105a9e27adc..14348e89a0f 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_reject.dart @@ -12,6 +12,7 @@ class RejectMessageHandler extends MessageHandler { final Method handlesMessage; final ErrorCodes errorCode; final String errorMessage; + RejectMessageHandler( super.server, this.handlesMessage, this.errorCode, this.errorMessage); @@ -20,7 +21,7 @@ class RejectMessageHandler extends MessageHandler { @override ErrorOr handle( - Object? _, MessageInfo message, CancellationToken token) { + Object? params, MessageInfo message, CancellationToken token) { return error(errorCode, errorMessage, null); } } diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart index 4655b6909aa..49e30bbc2c9 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_shutdown.dart @@ -8,6 +8,7 @@ import 'package:analysis_server/src/lsp/handlers/handlers.dart'; class ShutdownMessageHandler extends MessageHandler { ShutdownMessageHandler(super.server); + @override Method get handlesMessage => Method.shutdown; @@ -15,7 +16,8 @@ class ShutdownMessageHandler extends MessageHandler { LspJsonHandler get jsonHandler => NullJsonHandler; @override - ErrorOr handle(void _, MessageInfo message, CancellationToken token) { + ErrorOr handle( + void params, MessageInfo message, CancellationToken token) { // Move to the Shutting Down state so we won't process any more // requests and the Exit notification will know it was a clean shutdown. server.messageHandler = ShuttingDownStateMessageHandler(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 dbc283220cf..5f2e759cd89 100644 --- a/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart +++ b/pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart @@ -936,34 +936,33 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks { } @override - void listenAnalysisDriver(analysis.AnalysisDriver analysisDriver) { + void listenAnalysisDriver(analysis.AnalysisDriver driver) { // TODO(dantup): Is this required, or covered by // addContextsToDeclarationsTracker? The original server does not appear to // have an equivalent call. - final analysisContext = analysisDriver.analysisContext; + final analysisContext = driver.analysisContext; if (analysisContext != null) { analysisServer.declarationsTracker?.addContext(analysisContext); } - analysisDriver.results.listen((result) { + driver.results.listen((result) { if (result is FileResult) { _handleFileResult(result); } }); - analysisDriver.exceptions.listen(analysisServer.logExceptionResult); - analysisDriver.priorityFiles = analysisServer.priorityFiles.toList(); + driver.exceptions.listen(analysisServer.logExceptionResult); + driver.priorityFiles = analysisServer.priorityFiles.toList(); } @override - void pubspecChanged(String pubspecPath) { - analysisServer.pubPackageService.fetchPackageVersionsViaPubOutdated( - pubspecPath, - pubspecWasModified: true); + void pubspecChanged(String path) { + analysisServer.pubPackageService + .fetchPackageVersionsViaPubOutdated(path, pubspecWasModified: true); } @override - void pubspecRemoved(String pubspecPath) { - analysisServer.pubPackageService.flushPackageCaches(pubspecPath); + void pubspecRemoved(String path) { + analysisServer.pubPackageService.flushPackageCaches(path); } @override diff --git a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart index 4b72c5e1b3e..e64fb09464f 100644 --- a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart +++ b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart @@ -1415,45 +1415,47 @@ class SignatureElementVisitor extends GeneralizingElementVisitor { static SignatureElementVisitor instance = SignatureElementVisitor(); @override - StringBuffer visitCompilationUnitElement(CompilationUnitElement e) { + StringBuffer visitCompilationUnitElement(CompilationUnitElement element) { return StringBuffer(); } @override - StringBuffer visitElement(Element e) { - assert(e is! MultiplyInheritedExecutableElement); - var enclosingElt = e.enclosingElement!; + StringBuffer visitElement(Element element) { + assert(element is! MultiplyInheritedExecutableElement); + var enclosingElt = element.enclosingElement!; var buffer = enclosingElt.accept(this)!; if (buffer.isNotEmpty) { buffer.write('#'); } - if (e is MethodElement && e.name == '-' && e.parameters.length == 1) { + if (element is MethodElement && + element.name == '-' && + element.parameters.length == 1) { buffer.write('unary-'); - } else if (e is ConstructorElement) { - buffer.write(_computeConstructorElementName(e)); + } else if (element is ConstructorElement) { + buffer.write(_computeConstructorElementName(element)); } else { - buffer.write(e.name); + buffer.write(element.name); } if (enclosingElt is ExecutableElement) { buffer ..write('@') - ..write(e.nameOffset - enclosingElt.nameOffset); + ..write(element.nameOffset - enclosingElt.nameOffset); } return buffer; } @override - StringBuffer visitLibraryElement(LibraryElement e) { - return StringBuffer('library:${e.displayName}'); + StringBuffer visitLibraryElement(LibraryElement element) { + return StringBuffer('library:${element.displayName}'); } @override - StringBuffer visitTypeParameterElement(TypeParameterElement e) { + StringBuffer visitTypeParameterElement(TypeParameterElement element) { // It is legal to have a named constructor with the same name as a type // parameter. So we distinguish them by using '.' between the class (or // typedef) name and the type parameter name. - return e.enclosingElement!.accept(this)! + return element.enclosingElement!.accept(this)! ..write('.') - ..write(e.name); + ..write(element.name); } } diff --git a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart index 3ed92285505..91c2d41d792 100644 --- a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart +++ b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart @@ -465,12 +465,13 @@ void _writeEnumClass(IndentableStringBuffer buffer, Namespace namespace) { firstValueType is LiteralType ? firstValueType.type : firstValueType; final typeOfValues = resolveTypeAlias(requiredValueType, resolveEnumClasses: true); + final namespaceName = namespace.name; buffer - ..writeln('class ${namespace.name} implements ToJsonable {') + ..writeln('class $namespaceName implements ToJsonable {') ..indent() - ..writeIndentedln('const ${namespace.name}$constructorName(this._value);') - ..writeIndentedln('const ${namespace.name}.fromJson(this._value);') + ..writeIndentedln('const $namespaceName$constructorName(this._value);') + ..writeIndentedln('const $namespaceName.fromJson(this._value);') ..writeln() ..writeIndentedln('final ${typeOfValues.dartTypeWithTypeArgs} _value;') ..writeln() @@ -506,7 +507,7 @@ void _writeEnumClass(IndentableStringBuffer buffer, Namespace namespace) { } _writeDocCommentsAndAnnotations(buffer, cons); buffer.writeIndentedln( - 'static const ${_makeValidIdentifier(cons.name)} = ${namespace.name}$constructorName(${cons.valueAsLiteral});'); + 'static const ${_makeValidIdentifier(cons.name)} = $namespaceName$constructorName(${cons.valueAsLiteral});'); }); buffer ..writeln() @@ -517,7 +518,7 @@ void _writeEnumClass(IndentableStringBuffer buffer, Namespace namespace) { ..writeIndentedln('@override int get hashCode => _value.hashCode;') ..writeln() ..writeIndentedln( - 'bool operator ==(Object o) => o is ${namespace.name} && o._value == _value;') + 'bool operator ==(Object other) => other is $namespaceName && other._value == _value;') ..outdent() ..writeln('}') ..writeln(); @@ -1012,9 +1013,11 @@ class IndentableStringBuffer extends StringBuffer { final int _indentSpaces = 2; int get totalIndent => _indentLevel * _indentSpaces; + String get _indentString => ' ' * totalIndent; void indent() => _indentLevel++; + void outdent() => _indentLevel--; void writeIndented(Object obj) { diff --git a/pkg/analysis_server/tool/lsp_spec/generate_all.dart b/pkg/analysis_server/tool/lsp_spec/generate_all.dart index 92e5880935e..74f56447043 100644 --- a/pkg/analysis_server/tool/lsp_spec/generate_all.dart +++ b/pkg/analysis_server/tool/lsp_spec/generate_all.dart @@ -417,7 +417,7 @@ Future> getSpecClasses(ArgResults args) async { // Generate an enum for all of the request methods to avoid strings. types.add(extractMethodsEnum(spec)); - // Extract additional inline types that are specificed online in the `results` + // Extract additional inline types that are specified online in the `results` // section of the doc. types.addAll(extractResultsInlineTypes(spec)); return types; @@ -472,7 +472,7 @@ Future _fetchIncludes(String spec, Uri baseUri) async { final fullUri = baseUri.resolve(relativeUri); final response = await http.get(fullUri); if (response.statusCode != 200) { - throw 'Faild to fetch $fullUri (${response.statusCode} ${response.reasonPhrase})'; + throw 'Failed to fetch $fullUri (${response.statusCode} ${response.reasonPhrase})'; } includeStrings[relativeUri] = response.body; }