From f88ab5580fda238f1f6093a0ada8af73d94d9d6d Mon Sep 17 00:00:00 2001 From: eggnstone Date: Mon, 4 Mar 2024 15:33:31 +0700 Subject: [PATCH] Config class now being generated by freezed. --- GenerateDocumentation.ps1 | 1 + Publish.ps1 => PublishPackageToPubDev.ps1 | 0 example/main.dart | 2 +- lib/src/Data/Config.dart | 137 ++++--- lib/src/Data/Config.freezed.dart | 342 ++++++++++++++++++ lib/src/Data/Config.g.dart | 34 ++ lib/src/Data/ConfigOld.dart | 121 +++++++ lib/src/Handlers/DefaultHandler.dart | 2 +- lib/src/Handlers/PipeHandler.dart | 2 +- lib/src/Handlers/WebServiceHandler.dart | 2 +- test/FormatVisitor/Comments/Class_test.dart | 2 +- test/FormatVisitor/Comments/If_test.dart | 2 +- test/FormatVisitor/Comments/Method_test.dart | 2 +- test/FormatVisitor/Comments/Other2_test.dart | 2 +- test/FormatVisitor/Comments/Other_test.dart | 2 +- test/FormatVisitor/Comments/Return_test.dart | 2 +- .../ClassDeclaration_AddNewLines_test.dart | 2 +- ...structorDeclaration_Indentations_test.dart | 2 +- ...structorDeclaration_Initializers_test.dart | 2 +- .../ConstructorDeclaration_test.dart | 2 +- .../FieldDeclaration_test.dart | 2 +- .../EmptyFunctionBody_test.dart | 2 +- .../ExpressionFunctionBody_test.dart | 2 +- .../MethodDeclaration_Indentations_test.dart | 2 +- .../MethodDeclaration_Simple_test.dart | 2 +- .../MethodDeclaration_test.dart | 2 +- .../BlockFunctionBody/Block/Block_test.dart | 2 +- .../BlockFunctionBody_test.dart | 2 +- .../EmptyStatement/EmptyStatement_test.dart | 2 +- .../ExpressionStatement_test.dart | 2 +- .../ForStatement/ForStatement_test.dart | 2 +- .../IfStatement/IfStatement_test.dart | 2 +- .../ReturnStatement/ReturnStatement_test.dart | 2 +- .../WhileStatement/WhileStatement_test.dart | 2 +- .../FunctionDeclaration_Simple_test.dart | 2 +- .../FunctionDeclaration_test.dart | 2 +- .../VariableDeclarationStatement_test.dart | 2 +- .../ImportDirective/ImportDirective_test.dart | 2 +- .../TopLevelVariableDeclaration_test.dart | 2 +- test/FormatVisitor/Mixed_test.dart | 2 +- test/Formatter/Assertion_test.dart | 2 +- test/Formatter/Comments_test.dart | 4 +- ...FillerBeforeCommaAlreadyConsumed_test.dart | 2 +- .../Format_ExpectException_test.dart | 2 +- test/Formatter/Format_Indentation_test.dart | 2 +- test/TestTools/TestConfig.dart | 4 +- .../AddNewLineAtEndOfText=false_test.dart | 2 +- .../AddNewLineAtEndOfText=true_test.dart | 2 +- ...emoveEmptyLines_MaxEmptyLines=-1_test.dart | 2 +- ...RemoveEmptyLines_MaxEmptyLines=0_test.dart | 2 +- ...RemoveEmptyLines_MaxEmptyLines=1_test.dart | 2 +- ...RemoveEmptyLines_MaxEmptyLines=2_test.dart | 2 +- 52 files changed, 624 insertions(+), 107 deletions(-) create mode 100644 GenerateDocumentation.ps1 rename Publish.ps1 => PublishPackageToPubDev.ps1 (100%) create mode 100644 lib/src/Data/Config.freezed.dart create mode 100644 lib/src/Data/Config.g.dart create mode 100644 lib/src/Data/ConfigOld.dart diff --git a/GenerateDocumentation.ps1 b/GenerateDocumentation.ps1 new file mode 100644 index 0000000..31f74bd --- /dev/null +++ b/GenerateDocumentation.ps1 @@ -0,0 +1 @@ +dart doc diff --git a/Publish.ps1 b/PublishPackageToPubDev.ps1 similarity index 100% rename from Publish.ps1 rename to PublishPackageToPubDev.ps1 diff --git a/example/main.dart b/example/main.dart index bcabff7..eaa7ca5 100644 --- a/example/main.dart +++ b/example/main.dart @@ -8,7 +8,7 @@ void main(List arguments) print('Unformatted text:'); print('$unformattedText\n'); - const Config config = Config.all(); + final Config config = Config.all(); final Formatter formatter = Formatter(config); final String formattedText = formatter.format(unformattedText); print('Formatted text:'); diff --git a/lib/src/Data/Config.dart b/lib/src/Data/Config.dart index 0773595..6502dda 100644 --- a/lib/src/Data/Config.dart +++ b/lib/src/Data/Config.dart @@ -1,11 +1,15 @@ +// ignore_for_file: invalid_annotation_target + import 'dart:convert'; -import '../Tools/JsonTools.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; -// TODO: JSON and freezed +part 'Config.freezed.dart'; +part 'Config.g.dart'; /// Configuration for the formatter. -class Config +@freezed +class Config with _$Config { /// Default value when all options are turned on: Whether to add a new line after a closing brace. static const bool ADD_NEW_LINE_AFTER_CLOSING_BRACE_DEFAULT = true; @@ -52,68 +56,83 @@ class Config /// Default value when all options are turned off: Whether to remove trailing commas. static const bool REMOVE_TRAILING_COMMAS_NONE = false; - /// Whether to add a new line after a closing brace. - final bool addNewLineAfterClosingBrace; - /// Whether to add a new line after an opening brace. - final bool addNewLineAfterOpeningBrace; - /// Whether to add a new line after a semicolon. - final bool addNewLineAfterSemicolon; - /// Whether to add a new line at the end of the text. - final bool addNewLineAtEndOfText; - /// Whether to add a new line before a closing brace. - final bool addNewLineBeforeClosingBrace; - /// Whether to add a new line before an opening brace. - final bool addNewLineBeforeOpeningBrace; - /// The number of spaces to use for indentation. -1 = do not change indentation. - final int indentationSpacesPerLevel; - /// The maximum number of empty lines to allow. -1 = do not change empty lines. - final int maxEmptyLines; - /// Whether to remove trailing commas. - final bool removeTrailingCommas; + // necessary when you want to create additional methods + const Config._(); + + /// Create a new instance of [Config]. + @JsonSerializable(fieldRename: FieldRename.pascal) + const factory Config({ + required bool addNewLineAfterClosingBrace, + required bool addNewLineAfterOpeningBrace, + required bool addNewLineAfterSemicolon, + required bool addNewLineAtEndOfText, + required bool addNewLineBeforeClosingBrace, + required bool addNewLineBeforeOpeningBrace, + required int indentationSpacesPerLevel, + required int maxEmptyLines, + required bool removeTrailingCommas + }) = _Config; /// Create a new instance of [Config] with all options turned on. - const Config.all({ - this.addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_DEFAULT, - this.addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_DEFAULT, - this.addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_DEFAULT, - this.addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_DEFAULT, - this.addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_DEFAULT, - this.addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_DEFAULT, - this.indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_DEFAULT, - this.maxEmptyLines = MAX_EMPTY_LINES_DEFAULT, - this.removeTrailingCommas = REMOVE_TRAILING_COMMAS_DEFAULT - }); + // ignore: prefer_constructors_over_static_methods + static Config all({ + bool addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_DEFAULT, + bool addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_DEFAULT, + bool addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_DEFAULT, + bool addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_DEFAULT, + bool addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_DEFAULT, + bool addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_DEFAULT, + int indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_DEFAULT, + int maxEmptyLines = MAX_EMPTY_LINES_DEFAULT, + bool removeTrailingCommas = REMOVE_TRAILING_COMMAS_DEFAULT + }) + => Config( + addNewLineAfterClosingBrace: addNewLineAfterClosingBrace, + addNewLineAfterOpeningBrace: addNewLineAfterOpeningBrace, + addNewLineAfterSemicolon: addNewLineAfterSemicolon, + addNewLineAtEndOfText: addNewLineAtEndOfText, + addNewLineBeforeClosingBrace: addNewLineBeforeClosingBrace, + addNewLineBeforeOpeningBrace: addNewLineBeforeOpeningBrace, + indentationSpacesPerLevel: indentationSpacesPerLevel, + maxEmptyLines: maxEmptyLines, + removeTrailingCommas: removeTrailingCommas + ); /// Create a new instance of [Config] with all options turned off. - const Config.none({ - this.addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE, - this.addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE, - this.addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_NONE, - this.addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_NONE, - this.addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE, - this.addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE, - this.indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_NONE, - this.maxEmptyLines = MAX_EMPTY_LINES_NONE, - this.removeTrailingCommas = REMOVE_TRAILING_COMMAS_NONE - }); + // ignore: prefer_constructors_over_static_methods + static Config none({ + bool addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE, + bool addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE, + bool addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_NONE, + bool addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_NONE, + bool addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE, + bool addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE, + int indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_NONE, + int maxEmptyLines = MAX_EMPTY_LINES_NONE, + bool removeTrailingCommas = REMOVE_TRAILING_COMMAS_NONE + }) + => Config( + addNewLineAfterClosingBrace: addNewLineAfterClosingBrace, + addNewLineAfterOpeningBrace: addNewLineAfterOpeningBrace, + addNewLineAfterSemicolon: addNewLineAfterSemicolon, + addNewLineAtEndOfText: addNewLineAtEndOfText, + addNewLineBeforeClosingBrace: addNewLineBeforeClosingBrace, + addNewLineBeforeOpeningBrace: addNewLineBeforeOpeningBrace, + indentationSpacesPerLevel: indentationSpacesPerLevel, + maxEmptyLines: maxEmptyLines, + removeTrailingCommas: removeTrailingCommas + ); /// Create a new instance of [Config] from a JSON string. - factory Config.fromJson(String? configText) + factory Config.fromJsonText(String? s) { - if (configText == null) - return const Config.all(); - - final dynamic json = jsonDecode(configText); - return Config.none( - addNewLineAfterClosingBrace: JsonTools.get(json, 'AddNewLineAfterClosingBrace', ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE), - addNewLineAfterOpeningBrace: JsonTools.get(json, 'AddNewLineAfterOpeningBrace', ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE), - addNewLineAfterSemicolon: JsonTools.get(json, 'AddNewLineAfterSemicolon', ADD_NEW_LINE_AFTER_SEMICOLON_NONE), - addNewLineAtEndOfText: JsonTools.get(json, 'AddNewLineAtEndOfText', ADD_NEW_LINE_AT_END_OF_TEXT_NONE), - addNewLineBeforeClosingBrace: JsonTools.get(json, 'AddNewLineBeforeClosingBrace', ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE), - addNewLineBeforeOpeningBrace: JsonTools.get(json, 'AddNewLineBeforeOpeningBrace', ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE), - indentationSpacesPerLevel: JsonTools.get(json, 'IndentationSpacesPerLevel', INDENTATION_SPACES_PER_LEVEL_NONE), - maxEmptyLines: JsonTools.get(json, 'MaxEmptyLines', MAX_EMPTY_LINES_NONE), - removeTrailingCommas: JsonTools.get(json, 'RemoveTrailingCommas', REMOVE_TRAILING_COMMAS_NONE) - ); + if (s == null) + return Config.all(); + + return Config.fromJson(Map.from(jsonDecode(s))); } + + /// Create a new instance of [Config] from a JSON object. + factory Config.fromJson(Map json) + => _$ConfigFromJson(json); } diff --git a/lib/src/Data/Config.freezed.dart b/lib/src/Data/Config.freezed.dart new file mode 100644 index 0000000..01aa4d6 --- /dev/null +++ b/lib/src/Data/Config.freezed.dart @@ -0,0 +1,342 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'Config.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Config _$ConfigFromJson(Map json) { + return _Config.fromJson(json); +} + +/// @nodoc +mixin _$Config { + bool get addNewLineAfterClosingBrace => throw _privateConstructorUsedError; + bool get addNewLineAfterOpeningBrace => throw _privateConstructorUsedError; + bool get addNewLineAfterSemicolon => throw _privateConstructorUsedError; + bool get addNewLineAtEndOfText => throw _privateConstructorUsedError; + bool get addNewLineBeforeClosingBrace => throw _privateConstructorUsedError; + bool get addNewLineBeforeOpeningBrace => throw _privateConstructorUsedError; + int get indentationSpacesPerLevel => throw _privateConstructorUsedError; + int get maxEmptyLines => throw _privateConstructorUsedError; + bool get removeTrailingCommas => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ConfigCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ConfigCopyWith<$Res> { + factory $ConfigCopyWith(Config value, $Res Function(Config) then) = + _$ConfigCopyWithImpl<$Res, Config>; + @useResult + $Res call( + {bool addNewLineAfterClosingBrace, + bool addNewLineAfterOpeningBrace, + bool addNewLineAfterSemicolon, + bool addNewLineAtEndOfText, + bool addNewLineBeforeClosingBrace, + bool addNewLineBeforeOpeningBrace, + int indentationSpacesPerLevel, + int maxEmptyLines, + bool removeTrailingCommas}); +} + +/// @nodoc +class _$ConfigCopyWithImpl<$Res, $Val extends Config> + implements $ConfigCopyWith<$Res> { + _$ConfigCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? addNewLineAfterClosingBrace = null, + Object? addNewLineAfterOpeningBrace = null, + Object? addNewLineAfterSemicolon = null, + Object? addNewLineAtEndOfText = null, + Object? addNewLineBeforeClosingBrace = null, + Object? addNewLineBeforeOpeningBrace = null, + Object? indentationSpacesPerLevel = null, + Object? maxEmptyLines = null, + Object? removeTrailingCommas = null, + }) { + return _then(_value.copyWith( + addNewLineAfterClosingBrace: null == addNewLineAfterClosingBrace + ? _value.addNewLineAfterClosingBrace + : addNewLineAfterClosingBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAfterOpeningBrace: null == addNewLineAfterOpeningBrace + ? _value.addNewLineAfterOpeningBrace + : addNewLineAfterOpeningBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAfterSemicolon: null == addNewLineAfterSemicolon + ? _value.addNewLineAfterSemicolon + : addNewLineAfterSemicolon // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAtEndOfText: null == addNewLineAtEndOfText + ? _value.addNewLineAtEndOfText + : addNewLineAtEndOfText // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineBeforeClosingBrace: null == addNewLineBeforeClosingBrace + ? _value.addNewLineBeforeClosingBrace + : addNewLineBeforeClosingBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineBeforeOpeningBrace: null == addNewLineBeforeOpeningBrace + ? _value.addNewLineBeforeOpeningBrace + : addNewLineBeforeOpeningBrace // ignore: cast_nullable_to_non_nullable + as bool, + indentationSpacesPerLevel: null == indentationSpacesPerLevel + ? _value.indentationSpacesPerLevel + : indentationSpacesPerLevel // ignore: cast_nullable_to_non_nullable + as int, + maxEmptyLines: null == maxEmptyLines + ? _value.maxEmptyLines + : maxEmptyLines // ignore: cast_nullable_to_non_nullable + as int, + removeTrailingCommas: null == removeTrailingCommas + ? _value.removeTrailingCommas + : removeTrailingCommas // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ConfigImplCopyWith<$Res> implements $ConfigCopyWith<$Res> { + factory _$$ConfigImplCopyWith( + _$ConfigImpl value, $Res Function(_$ConfigImpl) then) = + __$$ConfigImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool addNewLineAfterClosingBrace, + bool addNewLineAfterOpeningBrace, + bool addNewLineAfterSemicolon, + bool addNewLineAtEndOfText, + bool addNewLineBeforeClosingBrace, + bool addNewLineBeforeOpeningBrace, + int indentationSpacesPerLevel, + int maxEmptyLines, + bool removeTrailingCommas}); +} + +/// @nodoc +class __$$ConfigImplCopyWithImpl<$Res> + extends _$ConfigCopyWithImpl<$Res, _$ConfigImpl> + implements _$$ConfigImplCopyWith<$Res> { + __$$ConfigImplCopyWithImpl( + _$ConfigImpl _value, $Res Function(_$ConfigImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? addNewLineAfterClosingBrace = null, + Object? addNewLineAfterOpeningBrace = null, + Object? addNewLineAfterSemicolon = null, + Object? addNewLineAtEndOfText = null, + Object? addNewLineBeforeClosingBrace = null, + Object? addNewLineBeforeOpeningBrace = null, + Object? indentationSpacesPerLevel = null, + Object? maxEmptyLines = null, + Object? removeTrailingCommas = null, + }) { + return _then(_$ConfigImpl( + addNewLineAfterClosingBrace: null == addNewLineAfterClosingBrace + ? _value.addNewLineAfterClosingBrace + : addNewLineAfterClosingBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAfterOpeningBrace: null == addNewLineAfterOpeningBrace + ? _value.addNewLineAfterOpeningBrace + : addNewLineAfterOpeningBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAfterSemicolon: null == addNewLineAfterSemicolon + ? _value.addNewLineAfterSemicolon + : addNewLineAfterSemicolon // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineAtEndOfText: null == addNewLineAtEndOfText + ? _value.addNewLineAtEndOfText + : addNewLineAtEndOfText // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineBeforeClosingBrace: null == addNewLineBeforeClosingBrace + ? _value.addNewLineBeforeClosingBrace + : addNewLineBeforeClosingBrace // ignore: cast_nullable_to_non_nullable + as bool, + addNewLineBeforeOpeningBrace: null == addNewLineBeforeOpeningBrace + ? _value.addNewLineBeforeOpeningBrace + : addNewLineBeforeOpeningBrace // ignore: cast_nullable_to_non_nullable + as bool, + indentationSpacesPerLevel: null == indentationSpacesPerLevel + ? _value.indentationSpacesPerLevel + : indentationSpacesPerLevel // ignore: cast_nullable_to_non_nullable + as int, + maxEmptyLines: null == maxEmptyLines + ? _value.maxEmptyLines + : maxEmptyLines // ignore: cast_nullable_to_non_nullable + as int, + removeTrailingCommas: null == removeTrailingCommas + ? _value.removeTrailingCommas + : removeTrailingCommas // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc + +@JsonSerializable(fieldRename: FieldRename.pascal) +class _$ConfigImpl extends _Config { + const _$ConfigImpl( + {required this.addNewLineAfterClosingBrace, + required this.addNewLineAfterOpeningBrace, + required this.addNewLineAfterSemicolon, + required this.addNewLineAtEndOfText, + required this.addNewLineBeforeClosingBrace, + required this.addNewLineBeforeOpeningBrace, + required this.indentationSpacesPerLevel, + required this.maxEmptyLines, + required this.removeTrailingCommas}) + : super._(); + + factory _$ConfigImpl.fromJson(Map json) => + _$$ConfigImplFromJson(json); + + @override + final bool addNewLineAfterClosingBrace; + @override + final bool addNewLineAfterOpeningBrace; + @override + final bool addNewLineAfterSemicolon; + @override + final bool addNewLineAtEndOfText; + @override + final bool addNewLineBeforeClosingBrace; + @override + final bool addNewLineBeforeOpeningBrace; + @override + final int indentationSpacesPerLevel; + @override + final int maxEmptyLines; + @override + final bool removeTrailingCommas; + + @override + String toString() { + return 'Config(addNewLineAfterClosingBrace: $addNewLineAfterClosingBrace, addNewLineAfterOpeningBrace: $addNewLineAfterOpeningBrace, addNewLineAfterSemicolon: $addNewLineAfterSemicolon, addNewLineAtEndOfText: $addNewLineAtEndOfText, addNewLineBeforeClosingBrace: $addNewLineBeforeClosingBrace, addNewLineBeforeOpeningBrace: $addNewLineBeforeOpeningBrace, indentationSpacesPerLevel: $indentationSpacesPerLevel, maxEmptyLines: $maxEmptyLines, removeTrailingCommas: $removeTrailingCommas)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ConfigImpl && + (identical(other.addNewLineAfterClosingBrace, + addNewLineAfterClosingBrace) || + other.addNewLineAfterClosingBrace == + addNewLineAfterClosingBrace) && + (identical(other.addNewLineAfterOpeningBrace, + addNewLineAfterOpeningBrace) || + other.addNewLineAfterOpeningBrace == + addNewLineAfterOpeningBrace) && + (identical( + other.addNewLineAfterSemicolon, addNewLineAfterSemicolon) || + other.addNewLineAfterSemicolon == addNewLineAfterSemicolon) && + (identical(other.addNewLineAtEndOfText, addNewLineAtEndOfText) || + other.addNewLineAtEndOfText == addNewLineAtEndOfText) && + (identical(other.addNewLineBeforeClosingBrace, + addNewLineBeforeClosingBrace) || + other.addNewLineBeforeClosingBrace == + addNewLineBeforeClosingBrace) && + (identical(other.addNewLineBeforeOpeningBrace, + addNewLineBeforeOpeningBrace) || + other.addNewLineBeforeOpeningBrace == + addNewLineBeforeOpeningBrace) && + (identical(other.indentationSpacesPerLevel, indentationSpacesPerLevel) || + other.indentationSpacesPerLevel == indentationSpacesPerLevel) && + (identical(other.maxEmptyLines, maxEmptyLines) || + other.maxEmptyLines == maxEmptyLines) && + (identical(other.removeTrailingCommas, removeTrailingCommas) || + other.removeTrailingCommas == removeTrailingCommas)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + addNewLineAfterClosingBrace, + addNewLineAfterOpeningBrace, + addNewLineAfterSemicolon, + addNewLineAtEndOfText, + addNewLineBeforeClosingBrace, + addNewLineBeforeOpeningBrace, + indentationSpacesPerLevel, + maxEmptyLines, + removeTrailingCommas); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$ConfigImplCopyWith<_$ConfigImpl> get copyWith => + __$$ConfigImplCopyWithImpl<_$ConfigImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ConfigImplToJson( + this, + ); + } +} + +abstract class _Config extends Config { + const factory _Config( + {required final bool addNewLineAfterClosingBrace, + required final bool addNewLineAfterOpeningBrace, + required final bool addNewLineAfterSemicolon, + required final bool addNewLineAtEndOfText, + required final bool addNewLineBeforeClosingBrace, + required final bool addNewLineBeforeOpeningBrace, + required final int indentationSpacesPerLevel, + required final int maxEmptyLines, + required final bool removeTrailingCommas}) = _$ConfigImpl; + const _Config._() : super._(); + + factory _Config.fromJson(Map json) = _$ConfigImpl.fromJson; + + @override + bool get addNewLineAfterClosingBrace; + @override + bool get addNewLineAfterOpeningBrace; + @override + bool get addNewLineAfterSemicolon; + @override + bool get addNewLineAtEndOfText; + @override + bool get addNewLineBeforeClosingBrace; + @override + bool get addNewLineBeforeOpeningBrace; + @override + int get indentationSpacesPerLevel; + @override + int get maxEmptyLines; + @override + bool get removeTrailingCommas; + @override + @JsonKey(ignore: true) + _$$ConfigImplCopyWith<_$ConfigImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/Data/Config.g.dart b/lib/src/Data/Config.g.dart new file mode 100644 index 0000000..0140046 --- /dev/null +++ b/lib/src/Data/Config.g.dart @@ -0,0 +1,34 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'Config.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ConfigImpl _$$ConfigImplFromJson(Map json) => _$ConfigImpl( + addNewLineAfterClosingBrace: json['AddNewLineAfterClosingBrace'] as bool, + addNewLineAfterOpeningBrace: json['AddNewLineAfterOpeningBrace'] as bool, + addNewLineAfterSemicolon: json['AddNewLineAfterSemicolon'] as bool, + addNewLineAtEndOfText: json['AddNewLineAtEndOfText'] as bool, + addNewLineBeforeClosingBrace: + json['AddNewLineBeforeClosingBrace'] as bool, + addNewLineBeforeOpeningBrace: + json['AddNewLineBeforeOpeningBrace'] as bool, + indentationSpacesPerLevel: json['IndentationSpacesPerLevel'] as int, + maxEmptyLines: json['MaxEmptyLines'] as int, + removeTrailingCommas: json['RemoveTrailingCommas'] as bool, + ); + +Map _$$ConfigImplToJson(_$ConfigImpl instance) => + { + 'AddNewLineAfterClosingBrace': instance.addNewLineAfterClosingBrace, + 'AddNewLineAfterOpeningBrace': instance.addNewLineAfterOpeningBrace, + 'AddNewLineAfterSemicolon': instance.addNewLineAfterSemicolon, + 'AddNewLineAtEndOfText': instance.addNewLineAtEndOfText, + 'AddNewLineBeforeClosingBrace': instance.addNewLineBeforeClosingBrace, + 'AddNewLineBeforeOpeningBrace': instance.addNewLineBeforeOpeningBrace, + 'IndentationSpacesPerLevel': instance.indentationSpacesPerLevel, + 'MaxEmptyLines': instance.maxEmptyLines, + 'RemoveTrailingCommas': instance.removeTrailingCommas, + }; diff --git a/lib/src/Data/ConfigOld.dart b/lib/src/Data/ConfigOld.dart new file mode 100644 index 0000000..5479160 --- /dev/null +++ b/lib/src/Data/ConfigOld.dart @@ -0,0 +1,121 @@ +/* +import 'dart:convert'; + +import '../Tools/JsonTools.dart'; + +// TODO: JSON and freezed + +/// Configuration for the formatter. +class ConfigOld +{ + /// Default value when all options are turned on: Whether to add a new line after a closing brace. + static const bool ADD_NEW_LINE_AFTER_CLOSING_BRACE_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line after a closing brace. + static const bool ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE = false; + + /// Default value when all options are turned on: Whether to add a new line after an opening brace. + static const bool ADD_NEW_LINE_AFTER_OPENING_BRACE_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line after an opening brace. + static const bool ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE = false; + + /// Default value when all options are turned on: Whether to add a new line after a semicolon. + static const bool ADD_NEW_LINE_AFTER_SEMICOLON_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line after a semicolon. + static const bool ADD_NEW_LINE_AFTER_SEMICOLON_NONE = false; + + /// Default value when all options are turned on: Whether to add a new line at the end of the text. + static const bool ADD_NEW_LINE_AT_END_OF_TEXT_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line at the end of the text. + static const bool ADD_NEW_LINE_AT_END_OF_TEXT_NONE = false; + + /// Default value when all options are turned on: Whether to add a new line before a closing brace. + static const bool ADD_NEW_LINE_BEFORE_CLOSING_BRACE_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line before a closing brace. + static const bool ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE = false; + + /// Default value when all options are turned on: Whether to add a new line before an opening brace. + static const bool ADD_NEW_LINE_BEFORE_OPENING_BRACE_DEFAULT = true; + /// Default value when all options are turned off: Whether to add a new line before an opening brace. + static const bool ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE = false; + + /// Default value when all options are turned on: The number of spaces to use for indentation. + static const int INDENTATION_SPACES_PER_LEVEL_DEFAULT = 4; + /// Default value when all options are turned off: The number of spaces to use for indentation. + static const int INDENTATION_SPACES_PER_LEVEL_NONE = -1; + + /// Default value when all options are turned on: The maximum number of empty lines to allow. + static const int MAX_EMPTY_LINES_DEFAULT = 1; + /// Default value when all options are turned off: The maximum number of empty lines to allow. + static const int MAX_EMPTY_LINES_NONE = -1; + + /// Default value when all options are turned on: Whether to remove trailing commas. + static const bool REMOVE_TRAILING_COMMAS_DEFAULT = true; + /// Default value when all options are turned off: Whether to remove trailing commas. + static const bool REMOVE_TRAILING_COMMAS_NONE = false; + + /// Whether to add a new line after a closing brace. + final bool addNewLineAfterClosingBrace; + /// Whether to add a new line after an opening brace. + final bool addNewLineAfterOpeningBrace; + /// Whether to add a new line after a semicolon. + final bool addNewLineAfterSemicolon; + /// Whether to add a new line at the end of the text. + final bool addNewLineAtEndOfText; + /// Whether to add a new line before a closing brace. + final bool addNewLineBeforeClosingBrace; + /// Whether to add a new line before an opening brace. + final bool addNewLineBeforeOpeningBrace; + /// The number of spaces to use for indentation. -1 = do not change indentation. + final int indentationSpacesPerLevel; + /// The maximum number of empty lines to allow. -1 = do not change empty lines. + final int maxEmptyLines; + /// Whether to remove trailing commas. + final bool removeTrailingCommas; + + /// Create a new instance of [Config] with all options turned on. + const ConfigOld.all({ + this.addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_DEFAULT, + this.addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_DEFAULT, + this.addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_DEFAULT, + this.addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_DEFAULT, + this.addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_DEFAULT, + this.addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_DEFAULT, + this.indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_DEFAULT, + this.maxEmptyLines = MAX_EMPTY_LINES_DEFAULT, + this.removeTrailingCommas = REMOVE_TRAILING_COMMAS_DEFAULT + }); + + /// Create a new instance of [Config] with all options turned off. + const ConfigOld.none({ + this.addNewLineAfterClosingBrace = ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE, + this.addNewLineAfterOpeningBrace = ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE, + this.addNewLineAfterSemicolon = ADD_NEW_LINE_AFTER_SEMICOLON_NONE, + this.addNewLineAtEndOfText = ADD_NEW_LINE_AT_END_OF_TEXT_NONE, + this.addNewLineBeforeClosingBrace = ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE, + this.addNewLineBeforeOpeningBrace = ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE, + this.indentationSpacesPerLevel = INDENTATION_SPACES_PER_LEVEL_NONE, + this.maxEmptyLines = MAX_EMPTY_LINES_NONE, + this.removeTrailingCommas = REMOVE_TRAILING_COMMAS_NONE + }); + + /// Create a new instance of [Config] from a JSON string. + factory ConfigOld.fromJson(String? configText) + { + if (configText == null) + return const ConfigOld.all(); + + final dynamic json = jsonDecode(configText); + return ConfigOld.none( + addNewLineAfterClosingBrace: JsonTools.get(json, 'AddNewLineAfterClosingBrace', ADD_NEW_LINE_AFTER_CLOSING_BRACE_NONE), + addNewLineAfterOpeningBrace: JsonTools.get(json, 'AddNewLineAfterOpeningBrace', ADD_NEW_LINE_AFTER_OPENING_BRACE_NONE), + addNewLineAfterSemicolon: JsonTools.get(json, 'AddNewLineAfterSemicolon', ADD_NEW_LINE_AFTER_SEMICOLON_NONE), + addNewLineAtEndOfText: JsonTools.get(json, 'AddNewLineAtEndOfText', ADD_NEW_LINE_AT_END_OF_TEXT_NONE), + addNewLineBeforeClosingBrace: JsonTools.get(json, 'AddNewLineBeforeClosingBrace', ADD_NEW_LINE_BEFORE_CLOSING_BRACE_NONE), + addNewLineBeforeOpeningBrace: JsonTools.get(json, 'AddNewLineBeforeOpeningBrace', ADD_NEW_LINE_BEFORE_OPENING_BRACE_NONE), + indentationSpacesPerLevel: JsonTools.get(json, 'IndentationSpacesPerLevel', INDENTATION_SPACES_PER_LEVEL_NONE), + maxEmptyLines: JsonTools.get(json, 'MaxEmptyLines', MAX_EMPTY_LINES_NONE), + removeTrailingCommas: JsonTools.get(json, 'RemoveTrailingCommas', REMOVE_TRAILING_COMMAS_NONE) + ); + } +} +*/ diff --git a/lib/src/Handlers/DefaultHandler.dart b/lib/src/Handlers/DefaultHandler.dart index 648ed9e..1f6c3c7 100644 --- a/lib/src/Handlers/DefaultHandler.dart +++ b/lib/src/Handlers/DefaultHandler.dart @@ -35,7 +35,7 @@ class DefaultHandler final bool isNewerVersionAvailable = await VersionTools(writeToStdOut: true).isNewerVersionAvailable(skipVersionCheck: skipVersionCheck); final int exitCodeForSuccess = isNewerVersionAvailable ? ExitCodes.SUCCESS_AND_NEW_VERSION_AVAILABLE : ExitCodes.SUCCESS; - final Config config = Config.fromJson(configText); + final Config config = Config.fromJsonText(configText); final Formatter formatter = Formatter(config); for (final String fileName in fileNames) { diff --git a/lib/src/Handlers/PipeHandler.dart b/lib/src/Handlers/PipeHandler.dart index 40bfc83..c1b2a45 100644 --- a/lib/src/Handlers/PipeHandler.dart +++ b/lib/src/Handlers/PipeHandler.dart @@ -36,7 +36,7 @@ class PipeHandler try { - final Config config = Config.fromJson(configText); + final Config config = Config.fromJsonText(configText); final Formatter formatter = Formatter(config); final String inputText = _readInput(); final String formattedText = formatter.format(inputText); diff --git a/lib/src/Handlers/WebServiceHandler.dart b/lib/src/Handlers/WebServiceHandler.dart index df1bdce..fc669c8 100644 --- a/lib/src/Handlers/WebServiceHandler.dart +++ b/lib/src/Handlers/WebServiceHandler.dart @@ -305,7 +305,7 @@ class WebServiceHandler //logDebug('configText: ${StringTools.toDisplayString(configText)}'); //logDebug('text: ${StringTools.toDisplayString(text)}'); - final Config config = configText.isEmpty ? const Config.all() : Config.fromJson(configText); + final Config config = configText.isEmpty ? Config.all() : Config.fromJsonText(configText); final Formatter formatter = Formatter(config); final String formattedText = formatter.format(text); if (formattedText.isEmpty) diff --git a/test/FormatVisitor/Comments/Class_test.dart b/test/FormatVisitor/Comments/Class_test.dart index 647a15f..6c1e396 100644 --- a/test/FormatVisitor/Comments/Class_test.dart +++ b/test/FormatVisitor/Comments/Class_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/Comments/If_test.dart b/test/FormatVisitor/Comments/If_test.dart index 5bf00e7..bba7bea 100644 --- a/test/FormatVisitor/Comments/If_test.dart +++ b/test/FormatVisitor/Comments/If_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/Comments/Method_test.dart b/test/FormatVisitor/Comments/Method_test.dart index e14622e..77fd3bf 100644 --- a/test/FormatVisitor/Comments/Method_test.dart +++ b/test/FormatVisitor/Comments/Method_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/Comments/Other2_test.dart b/test/FormatVisitor/Comments/Other2_test.dart index b173f78..e65db95 100644 --- a/test/FormatVisitor/Comments/Other2_test.dart +++ b/test/FormatVisitor/Comments/Other2_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/Comments/Other_test.dart b/test/FormatVisitor/Comments/Other_test.dart index afd1a9a..0fd26a8 100644 --- a/test/FormatVisitor/Comments/Other_test.dart +++ b/test/FormatVisitor/Comments/Other_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/Comments/Return_test.dart b/test/FormatVisitor/Comments/Return_test.dart index 6b2becb..45df64d 100644 --- a/test/FormatVisitor/Comments/Return_test.dart +++ b/test/FormatVisitor/Comments/Return_test.dart @@ -9,7 +9,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); for (final String comment in TestParameters.comments) diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ClassDeclaration_AddNewLines_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ClassDeclaration_AddNewLines_test.dart index e02f6a7..ca4915f 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ClassDeclaration_AddNewLines_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ClassDeclaration_AddNewLines_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Indentations_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Indentations_test.dart index aadcaf5..10b5fd4 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Indentations_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Indentations_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(indentationSpacesPerLevel: 4); + final Config config = Config.none(indentationSpacesPerLevel: 4); final Formatter formatter = Formatter(config); group('ConstructorDeclarations (Indentations)', () diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Initializers_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Initializers_test.dart index a734208..aad6757 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Initializers_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_Initializers_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('ConstructorDeclarations (Initializers)', () diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_test.dart index b29371a..93fb702 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/ConstructorDeclaration/ConstructorDeclaration_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/FieldDeclaration/FieldDeclaration_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/FieldDeclaration/FieldDeclaration_test.dart index 068b98f..85651e1 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/FieldDeclaration/FieldDeclaration_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/FieldDeclaration/FieldDeclaration_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/EmptyFunctionBody/EmptyFunctionBody_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/EmptyFunctionBody/EmptyFunctionBody_test.dart index a4df23b..b1a0529 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/EmptyFunctionBody/EmptyFunctionBody_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/EmptyFunctionBody/EmptyFunctionBody_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/ExpressionFunctionBody/ExpressionFunctionBody_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/ExpressionFunctionBody/ExpressionFunctionBody_test.dart index 5d02f4c..4d18791 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/ExpressionFunctionBody/ExpressionFunctionBody_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/ExpressionFunctionBody/ExpressionFunctionBody_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Indentations_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Indentations_test.dart index d54ecb0..c265013 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Indentations_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Indentations_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(indentationSpacesPerLevel: 4); + final Config config = Config.none(indentationSpacesPerLevel: 4); final Formatter formatter = Formatter(config); group('MethodDeclarations (Indentations)', () diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Simple_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Simple_test.dart index 1b3a48c..f04f0fd 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Simple_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_Simple_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('MethodDeclarations (Simple)', () diff --git a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_test.dart b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_test.dart index a17ee27..2dc5237 100644 --- a/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_test.dart +++ b/test/FormatVisitor/CompilationUnit/ClassDeclaration/MethodDeclaration/MethodDeclaration_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/Block/Block_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/Block/Block_test.dart index 770aeca..c3ce34c 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/Block/Block_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/Block/Block_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/BlockFunctionBody_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/BlockFunctionBody_test.dart index 05f97eb..a8303c1 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/BlockFunctionBody_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/BlockFunctionBody_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('BlockFunctionBodies', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/EmptyStatement/EmptyStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/EmptyStatement/EmptyStatement_test.dart index 26ad2a6..73c4ef5 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/EmptyStatement/EmptyStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/EmptyStatement/EmptyStatement_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('EmptyStatements', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ExpressionStatement/ExpressionStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ExpressionStatement/ExpressionStatement_test.dart index c03898c..7ce5e4d 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ExpressionStatement/ExpressionStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ExpressionStatement/ExpressionStatement_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String afterSemicolonText; diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ForStatement/ForStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ForStatement/ForStatement_test.dart index 21cc486..34b139e 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ForStatement/ForStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ForStatement/ForStatement_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('ForStatements', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/IfStatement/IfStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/IfStatement/IfStatement_test.dart index 4057fb1..a5d156d 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/IfStatement/IfStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/IfStatement/IfStatement_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('IfStatements', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ReturnStatement/ReturnStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ReturnStatement/ReturnStatement_test.dart index 94fb552..1022860 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ReturnStatement/ReturnStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/ReturnStatement/ReturnStatement_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('ReturnStatements', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/WhileStatement/WhileStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/WhileStatement/WhileStatement_test.dart index e59d570..8a220d7 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/WhileStatement/WhileStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/BlockFunctionBody/WhileStatement/WhileStatement_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('WhileStatements', () diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_Simple_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_Simple_test.dart index 11d8c08..01fe140 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_Simple_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_Simple_test.dart @@ -11,7 +11,7 @@ void main() { test('Empty function with space before opening brace', () { - const Config config = Config.none(addNewLineBeforeOpeningBrace: true); + final Config config = Config.none(addNewLineBeforeOpeningBrace: true); final Formatter formatter = Formatter(config); const String inputText = 'void f() {}'; diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_test.dart index 9ac5a72..5c312ca 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/FunctionDeclaration_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String beforeOpeningText; late String afterOpeningText; diff --git a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/VariableDeclarationStatement/VariableDeclarationStatement_test.dart b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/VariableDeclarationStatement/VariableDeclarationStatement_test.dart index 2dd05a2..24922d0 100644 --- a/test/FormatVisitor/CompilationUnit/FunctionDeclaration/VariableDeclarationStatement/VariableDeclarationStatement_test.dart +++ b/test/FormatVisitor/CompilationUnit/FunctionDeclaration/VariableDeclarationStatement/VariableDeclarationStatement_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String afterSemicolonText; diff --git a/test/FormatVisitor/CompilationUnit/ImportDirective/ImportDirective_test.dart b/test/FormatVisitor/CompilationUnit/ImportDirective/ImportDirective_test.dart index 2190543..bd0b3b0 100644 --- a/test/FormatVisitor/CompilationUnit/ImportDirective/ImportDirective_test.dart +++ b/test/FormatVisitor/CompilationUnit/ImportDirective/ImportDirective_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('ImportDirectives', () diff --git a/test/FormatVisitor/CompilationUnit/TopLevelVariableDeclaration/TopLevelVariableDeclaration_test.dart b/test/FormatVisitor/CompilationUnit/TopLevelVariableDeclaration/TopLevelVariableDeclaration_test.dart index 11d87e7..2e05673 100644 --- a/test/FormatVisitor/CompilationUnit/TopLevelVariableDeclaration/TopLevelVariableDeclaration_test.dart +++ b/test/FormatVisitor/CompilationUnit/TopLevelVariableDeclaration/TopLevelVariableDeclaration_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); group('TopLevelVariableDeclaration', () diff --git a/test/FormatVisitor/Mixed_test.dart b/test/FormatVisitor/Mixed_test.dart index d95439c..9fe920e 100644 --- a/test/FormatVisitor/Mixed_test.dart +++ b/test/FormatVisitor/Mixed_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - late Config config = const Config.none(); + late Config config = Config.none(); late Formatter formatter = Formatter(config); late String afterSemicolonText; diff --git a/test/Formatter/Assertion_test.dart b/test/Formatter/Assertion_test.dart index 135f60c..dc0436c 100644 --- a/test/Formatter/Assertion_test.dart +++ b/test/Formatter/Assertion_test.dart @@ -16,7 +16,7 @@ void main() Analyzer().analyze(inputText); - const Config config = Config.all(); + final Config config = Config.all(); final Formatter formatter = Formatter(config); final String actualText = formatter.format(inputText); diff --git a/test/Formatter/Comments_test.dart b/test/Formatter/Comments_test.dart index b57f11d..f918ca4 100644 --- a/test/Formatter/Comments_test.dart +++ b/test/Formatter/Comments_test.dart @@ -29,7 +29,7 @@ void main() Analyzer().analyze(inputText); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); final String actualText = formatter.format(inputText); @@ -48,7 +48,7 @@ void main() Analyzer().analyze(inputText); - const Config config = Config.none(); + final Config config = Config.none(); final Formatter formatter = Formatter(config); final String actualText = formatter.format(inputText); diff --git a/test/Formatter/FillerBeforeCommaAlreadyConsumed_test.dart b/test/Formatter/FillerBeforeCommaAlreadyConsumed_test.dart index b332c96..e318a1e 100644 --- a/test/Formatter/FillerBeforeCommaAlreadyConsumed_test.dart +++ b/test/Formatter/FillerBeforeCommaAlreadyConsumed_test.dart @@ -29,7 +29,7 @@ void main() Analyzer().analyze(inputText); - const Config config = Config.all(); + final Config config = Config.all(); final Formatter formatter = Formatter(config); final String actualText = formatter.format(inputText); diff --git a/test/Formatter/Format_ExpectException_test.dart b/test/Formatter/Format_ExpectException_test.dart index 3c7c470..78e0275 100644 --- a/test/Formatter/Format_ExpectException_test.dart +++ b/test/Formatter/Format_ExpectException_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.none(maxEmptyLines: 0); + final Config config = Config.none(maxEmptyLines: 0); final Formatter formatter = Formatter(config); group('Formatter.format: expecting exception', () diff --git a/test/Formatter/Format_Indentation_test.dart b/test/Formatter/Format_Indentation_test.dart index 2ec9bf0..a1a36e9 100644 --- a/test/Formatter/Format_Indentation_test.dart +++ b/test/Formatter/Format_Indentation_test.dart @@ -7,7 +7,7 @@ void main() { TestTools.init(); - const Config config = Config.all(); + final Config config = Config.all(); final Formatter formatter = Formatter(config); group('Formatter.format: indentation', () diff --git a/test/TestTools/TestConfig.dart b/test/TestTools/TestConfig.dart index e6f1288..74a7aa4 100644 --- a/test/TestTools/TestConfig.dart +++ b/test/TestTools/TestConfig.dart @@ -8,8 +8,8 @@ class TestConfig final String name; TestConfig([this.expectedText, this.restText]) - : config = const Config.all(), name = 'Default'; + : config = Config.all(), name = 'Default'; TestConfig.none([this.expectedText, this.restText]) - : config = const Config.none(), name = 'None'; + : config = Config.none(), name = 'None'; } diff --git a/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=false_test.dart b/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=false_test.dart index a916e5e..0aaa1fd 100644 --- a/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=false_test.dart +++ b/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=false_test.dart @@ -9,7 +9,7 @@ void main() TestTools.init(); // ignore: avoid_redundant_argument_values - const Config config = Config.none(addNewLineAtEndOfText: false); + final Config config = Config.none(addNewLineAtEndOfText: false); final TextTools textTools = TextTools(config); group('AddNewLineAtEndOfText=false tests', () diff --git a/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=true_test.dart b/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=true_test.dart index 3f64d81..72df4d7 100644 --- a/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=true_test.dart +++ b/test/Tools/TextTools/AddNewLineAtEndOfText/AddNewLineAtEndOfText=true_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - const Config config = Config.none(addNewLineAtEndOfText: true); + final Config config = Config.none(addNewLineAtEndOfText: true); final TextTools textTools = TextTools(config); group('AddNewLineAtEndOfText=true tests', () diff --git a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=-1_test.dart b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=-1_test.dart index 208ec81..6e1eafa 100644 --- a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=-1_test.dart +++ b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=-1_test.dart @@ -9,7 +9,7 @@ void main() TestTools.init(); // ignore: avoid_redundant_argument_values - const Config config = Config.none(maxEmptyLines: -1); + final Config config = Config.none(maxEmptyLines: -1); final TextTools textTools = TextTools(config); group('RemoveEmptyLines MaxEmptyLines=-1', () diff --git a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=0_test.dart b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=0_test.dart index 1c4041b..97ee5b9 100644 --- a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=0_test.dart +++ b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=0_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - const Config config = Config.none(maxEmptyLines: 0); + final Config config = Config.none(maxEmptyLines: 0); final TextTools textTools = TextTools(config); group('RemoveEmptyLines MaxEmptyLines=0', () diff --git a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=1_test.dart b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=1_test.dart index 268c147..99cbdde 100644 --- a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=1_test.dart +++ b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=1_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - const Config config = Config.none(maxEmptyLines: 1); + final Config config = Config.none(maxEmptyLines: 1); final TextTools textTools = TextTools(config); group('RemoveEmptyLines MaxEmptyLines=1', () diff --git a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=2_test.dart b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=2_test.dart index 350fd1a..3373235 100644 --- a/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=2_test.dart +++ b/test/Tools/TextTools/RemoveEmptyLines/RemoveEmptyLines_MaxEmptyLines=2_test.dart @@ -8,7 +8,7 @@ void main() { TestTools.init(); - const Config config = Config.none(maxEmptyLines: 2); + final Config config = Config.none(maxEmptyLines: 2); final TextTools textTools = TextTools(config); group('RemoveEmptyLines MaxEmptyLines=2', ()