Skip to content

Commit

Permalink
Enable prefer_generic_function_type_aliases in most of the packages
Browse files Browse the repository at this point in the history
Change-Id: I1338e731aa3f42f67fec605b20455a83fd5fce43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
bwilkerson authored and commit-bot@chromium.org committed Dec 27, 2019
1 parent 93c9eba commit c547f5d
Show file tree
Hide file tree
Showing 29 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pkg/analysis_server/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ linter:
#- prefer_conditional_assignment # 191
#- prefer_final_fields # 35
- prefer_for_elements_to_map_fromIterable
#- prefer_generic_function_type_aliases # 18
- prefer_generic_function_type_aliases
#- prefer_if_null_operators # 22
#- prefer_single_quotes # 6653
#- prefer_spread_collections # 3
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import 'package:telemetry/crash_reporting.dart';
import 'package:telemetry/telemetry.dart' as telemetry;
import 'package:watcher/watcher.dart';

typedef void OptionUpdater(AnalysisOptionsImpl options);
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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/lib/src/plugin/result_collector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* A function used to determine whether results should be collected for the
* file with the given [path].
*/
typedef bool ShouldCollectPredicate(String path);
typedef ShouldCollectPredicate = bool Function(String path);

/**
* An object used to collect partial results (of type [E]) where the partial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder,
* string describing the part of the JSON object being decoded, and [value] is
* the part to decode.
*/
typedef E JsonDecoderCallback<E>(String jsonPath, Object value);
typedef JsonDecoderCallback<E> = E Function(String jsonPath, Object value);

/**
* Instances of the class [HasToJson] implement [toJson] method that returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import 'package:analyzer_plugin/utilities/range_factory.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' hide context;

typedef _SimpleIdentifierVisitor(SimpleIdentifier node);
typedef _SimpleIdentifierVisitor = void Function(SimpleIdentifier node);

/**
* The computer for Dart assists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import 'package:path/path.dart';
/**
* A predicate is a one-argument function that returns a boolean value.
*/
typedef bool ElementPredicate(Element argument);
typedef ElementPredicate = bool Function(Element argument);

/**
* A fix contributor that provides the default set of fixes for Dart files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ void visitLibraryTopLevelElements(
* An [Element] processor function type.
* If `true` is returned, children of [element] will be visited.
*/
typedef bool BoolElementProcessor(Element element);
typedef BoolElementProcessor = bool Function(Element element);

/**
* An [Element] processor function type.
*/
typedef void VoidElementProcessor(Element element);
typedef VoidElementProcessor = void Function(Element element);

/**
* A visitor that finds the deep-most [Element] that contains the [nameOffset].
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/test/abstract_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Element findChildElement(Element root, String name, [ElementKind kind]) {
/**
* A function to be called for every [Element].
*/
typedef void _ElementVisitorFunction(Element element);
typedef _ElementVisitorFunction = void Function(Element element);

class AbstractContextTest with ResourceProviderMixin {
OverlayResourceProvider overlayResourceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,18 @@ String _defaultFailFormatter(
/**
* Type of closures used by LazyMatcher.
*/
typedef Matcher MatcherCreator();
typedef MatcherCreator = Matcher Function();

/**
* Type of closures used by MatchesJsonObject to record field mismatches.
*/
typedef Description MismatchDescriber(Description mismatchDescription);
typedef MismatchDescriber = Description Function(
Description mismatchDescription);

/**
* Type of callbacks used to process notifications.
*/
typedef void NotificationProcessor(String event, params);
typedef NotificationProcessor = void Function(String event, Map params);

/**
* Base class for analysis server integration tests.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server/tool/instrumentation/log/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:path/path.dart' as path;
/**
* A boolean-valued function of one argument.
*/
typedef bool Predicate<T>(T value);
typedef Predicate<T> = bool Function(T value);

/**
* A description of a group of log entries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:convert';
import '../log/log.dart';
import '../server.dart';

typedef void Writer(StringSink sink);
typedef Writer = void Function(StringSink sink);

/**
* A class used to write an HTML page.
Expand Down
6 changes: 3 additions & 3 deletions pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ GeneratedFile serverTarget(bool responseRequiresRequestTime) {
/**
* Callback type used to represent arbitrary code generation.
*/
typedef void CodegenCallback();
typedef CodegenCallback = void Function();

typedef String FromJsonSnippetCallback(String jsonPath, String json);
typedef FromJsonSnippetCallback = String Function(String jsonPath, String json);

typedef String ToJsonSnippetCallback(String value);
typedef ToJsonSnippetCallback = String Function(String value);

/**
* Visitor which produces Dart code representing the API.
Expand Down
4 changes: 2 additions & 2 deletions pkg/analysis_server/tool/spec/from_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Api readApi(String pkgPath) {
return reader.readApi();
}

typedef void ElementProcessor(dom.Element element);
typedef ElementProcessor = void Function(dom.Element element);

typedef void TextProcessor(dom.Text text);
typedef TextProcessor = void Function(dom.Text text);

class ApiReader {
static const List<String> specialElements = [
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server_client/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ linter:
#- prefer_equal_for_default_values # 9
#- prefer_final_fields # 2
- prefer_for_elements_to_map_fromIterable
#- prefer_generic_function_type_aliases # 2
- prefer_generic_function_type_aliases
- prefer_if_null_operators
- prefer_is_empty
- prefer_is_not_empty
Expand Down
2 changes: 1 addition & 1 deletion pkg/analysis_server_client/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:analysis_server_client/protocol.dart';
import 'package:path/path.dart';

/// Type of callbacks used to process notifications.
typedef void NotificationProcessor(Notification notification);
typedef NotificationProcessor = void Function(Notification notification);

/// Instances of the class [Server] manage a server process,
/// and facilitate communication to and from the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder,
* string describing the part of the JSON object being decoded, and [value] is
* the part to decode.
*/
typedef E JsonDecoderCallback<E>(String jsonPath, Object value);
typedef JsonDecoderCallback<E> = E Function(String jsonPath, Object value);

/**
* Instances of the class [HasToJson] implement [toJson] method that returns
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_cli/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ linter:
#- prefer_equal_for_default_values # 9
- prefer_final_fields
- prefer_for_elements_to_map_fromIterable
#- prefer_generic_function_type_aliases # 4
- prefer_generic_function_type_aliases
#- prefer_if_null_operators # 1
- prefer_is_empty
- prefer_is_not_empty
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_cli/lib/src/batch_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:io' show exitCode, stdin;

import 'package:analyzer/error/error.dart';

typedef Future<ErrorSeverity> BatchRunnerHandler(List<String> args);
typedef BatchRunnerHandler = Future<ErrorSeverity> Function(List<String> args);

/// Provides a framework to read command line options from stdin and feed them
/// to a callback.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_cli/lib/src/error_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ErrorSeverity _severityIdentity(AnalysisError error) =>

/// Returns desired severity for the given [error] (or `null` if it's to be
/// suppressed).
typedef ErrorSeverity SeverityProcessor(AnalysisError error);
typedef SeverityProcessor = ErrorSeverity Function(AnalysisError error);

/// Analysis statistics counter.
class AnalysisStats {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_cli/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void printAndFail(String message, {int exitCode: 15}) {
/// Exit handler.
///
/// *Visible for testing.*
typedef void ExitHandler(int code);
typedef ExitHandler = void Function(int code);

/// Analyzer commandline configuration options.
class CommandLineOptions {
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_cli/test/build_mode_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ main() {
defineReflectiveTests(WorkerLoopTest);
}

typedef void _TestWorkerLoopAnalyze(CommandLineOptions options);
typedef _TestWorkerLoopAnalyze = void Function(CommandLineOptions options);

/**
* [AnalyzerWorkerLoop] for testing.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_plugin/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ linter:
#- prefer_equal_for_default_values # 177
#- prefer_final_fields # 5
- prefer_for_elements_to_map_fromIterable
#- prefer_generic_function_type_aliases # 12
- prefer_generic_function_type_aliases
#- prefer_if_null_operators # 12
- prefer_is_empty
- prefer_is_not_empty
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_plugin/lib/src/channel/isolate_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:analyzer_plugin/protocol/protocol_generated.dart';
/**
* The type of the function used to run a built-in plugin in an isolate.
*/
typedef void EntryPoint(SendPort sendPort);
typedef EntryPoint = void Function(SendPort sendPort);

/**
* A communication channel appropriate for built-in plugins.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ RefactoringOptions refactoringOptionsFromJson(JsonDecoder jsonDecoder,
* string describing the part of the JSON object being decoded, and [value] is
* the part to decode.
*/
typedef E JsonDecoderCallback<E>(String jsonPath, dynamic value);
typedef JsonDecoderCallback<E> = E Function(String jsonPath, dynamic value);

/**
* Instances of the class [HasToJson] implement [toJson] method that returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart';
import 'package:analyzer_plugin/utilities/completion/relevance.dart';

typedef int SuggestionsFilter(DartType dartType, int relevance);
typedef SuggestionsFilter = int Function(DartType dartType, int relevance);

/**
* An [AstVisitor] for determining whether top level suggestions or invocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ String _defaultFailFormatter(
/**
* Type of closures used by LazyMatcher.
*/
typedef Matcher MatcherCreator();
typedef MatcherCreator = Matcher Function();

/**
* Type of closures used by MatchesJsonObject to record field mismatches.
*/
typedef Description MismatchDescriber(Description mismatchDescription);
typedef MismatchDescriber = Description Function(
Description mismatchDescription);

/**
* Type of callbacks used to process notifications.
*/
typedef void NotificationProcessor(String event, params);
typedef NotificationProcessor = void Function(String event, Map params);

/**
* Base class for analysis server integration tests.
Expand Down Expand Up @@ -573,7 +574,7 @@ class Server {
outOfTestExpect(messageAsMap, contains('event'));
outOfTestExpect(messageAsMap['event'], isString);
notificationProcessor(
messageAsMap['event'] as String, messageAsMap['params']);
messageAsMap['event'] as String, messageAsMap['params'] as Map);
// Check that the message is well-formed. We do this after calling
// notificationController.add() so that we don't stall the test in the
// event of an error.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer_plugin/test/support/abstract_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Element findChildElement(Element root, String name, [ElementKind kind]) {
/**
* A function to be called for every [Element].
*/
typedef void _ElementVisitorFunction(Element element);
typedef _ElementVisitorFunction = void Function(Element element);

class AbstractContextTest with ResourceProviderMixin {
AnalysisDriver _driver;
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ GeneratedFile target(bool responseRequiresRequestTime) {
/**
* Callback type used to represent arbitrary code generation.
*/
typedef void CodegenCallback();
typedef CodegenCallback = void Function();

typedef String FromJsonSnippetCallback(String jsonPath, String json);
typedef FromJsonSnippetCallback = String Function(String jsonPath, String json);

typedef String ToJsonSnippetCallback(String value);
typedef ToJsonSnippetCallback = String Function(String value);

/**
* Visitor which produces Dart code representing the API.
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer_plugin/tool/spec/from_html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Api readApi(String pkgPath) {
return reader.readApi();
}

typedef void ElementProcessor(dom.Element element);
typedef ElementProcessor = void Function(dom.Element element);

typedef void TextProcessor(dom.Text text);
typedef TextProcessor = void Function(dom.Text text);

class ApiReader {
static const List<String> specialElements = [
Expand Down

0 comments on commit c547f5d

Please sign in to comment.