Skip to content

Commit

Permalink
Adding "fix spaces".
Browse files Browse the repository at this point in the history
  • Loading branch information
eggnstone committed Sep 14, 2024
1 parent 1abc98d commit 59b8994
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/Formatters/SuperFormalParameterFormatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class SuperFormalParameterFormatter extends IFormatter
if (node is! SuperFormalParameter)
throw FormatException('Not a SuperFormalParameter: ${node.runtimeType}');

formatState.acceptList(node.sortedCommentAndAnnotations, astVisitor, '$methodName/node.sortedCommentAndAnnotations');
formatState.copyEntity(node.requiredKeyword, astVisitor, '$methodName/node.requiredKeyword');

if (node.type != null)
Expand Down
39 changes: 39 additions & 0 deletions test/Formatters/SuperFormalParameterFormatter_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:dart_format/src/Formatters/SuperFormalParameterFormatter.dart';

import '../TestTools/AstCreator.dart';
import '../TestTools/TestGroupConfig.dart';
import '../TestTools/TestTools.dart';
import '../TestTools/Visitors/TestVisitor.dart';

void main()
{
TestTools.init();

final List<TestGroupConfig> testGroupConfigs = <TestGroupConfig>[
TestGroupConfig(
inputNodeCreator: AstCreator.createFormalParameterInFunction,
inputLeading: 'void f(',
inputMiddle: '@a int super.s',
inputTrailing: '){}',
name: 'SuperFormalParameter',
astVisitors: <TestVisitor<void>>[
TestVisitor<Annotation>(7, '@a'),
TestVisitor<NamedType>(10, 'int')
]
),
TestGroupConfig(
inputNodeCreator: AstCreator.createFormalParameterInDefaultFormalParameterInFunction,
inputLeading: 'void f({',
inputMiddle: '@a required int super.s',
inputTrailing: '}){}',
name: 'SuperFormalParameter with named',
astVisitors: <TestVisitor<void>>[
TestVisitor<Annotation>(8, '@a'),
TestVisitor<NamedType>(20, 'int')
]
)
];

TestTools.runTestGroupsForFormatter(testGroupConfigs, 'SuperFormalParameterFormatter', SuperFormalParameterFormatter.new, StackTrace.current);
}
6 changes: 6 additions & 0 deletions test/TestTools/AstCreator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class AstCreator
static FormalParameter createFormalParameterInFunction(String s)
=> createFormalParameterListInFunction(s).parameters[0];

static DefaultFormalParameter createDefaultFormalParameterInFunction(String s)
=> createFormalParameterInFunction(s) as DefaultFormalParameter;

static FormalParameter createFormalParameterInDefaultFormalParameterInFunction(String s)
=> createDefaultFormalParameterInFunction(s).parameter;

static FormalParameterList createFormalParameterListInFunction(String s)
=> createFunctionExpression(s).parameters!;

Expand Down

0 comments on commit 59b8994

Please sign in to comment.