Skip to content

Commit

Permalink
Fixed deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
eggnstone committed Jul 18, 2024
1 parent 16dd38b commit 0c71c1d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/src/FormatVisitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ class FormatVisitor extends AstVisitor<void>
=> _objectPatternFormatter.format(node);

@override
// ignore: deprecated_member_use
void visitOnClause(OnClause node)
=> _onClauseFormatter.format(node);

Expand Down
6 changes: 6 additions & 0 deletions lib/src/Formatters/ExtensionDeclarationFormatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ class ExtensionDeclarationFormatter extends IFormatter
formatState.copyEntity(node.extensionKeyword, astVisitor, '$methodName/node.extensionKeyword');
formatState.copyEntity(node.name, astVisitor, '$methodName/node.name');
formatState.copyEntity(node.typeParameters, astVisitor, '$methodName/node.typeParameters');

formatState.copyEntity(node.onClause, astVisitor, '$methodName/node.extendedType');
/*
onClause replaces onKeyword and extendedType
formatState.copyEntity(node.onKeyword, astVisitor, '$methodName/node.onKeyword');
formatState.copyEntity(node.extendedType, astVisitor, '$methodName/node.extendedType');
*/

formatState.copyOpeningBraceAndPushLevel(node.leftBracket, config, '$methodName/node.leftBracket');
formatState.acceptList(node.members, astVisitor, '$methodName/node.members');
formatState.copyClosingBraceAndPopLevel(node.rightBracket, config, '$methodName/node.rightBracket');
Expand Down
1 change: 1 addition & 0 deletions lib/src/Formatters/OnClauseFormatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class OnClauseFormatter extends IFormatter
const String methodName = 'OnClauseFormatter.format';
if (Constants.DEBUG_I_FORMATTER) log('START $methodName(${StringTools.toDisplayString(node, Constants.MAX_DEBUG_LENGTH)})', formatState.logIndent++);

// ignore: deprecated_member_use
if (node is! OnClause)
throw FormatException('Not an OnClause: ${node.runtimeType}');

Expand Down
3 changes: 2 additions & 1 deletion test/Formatters/ExtensionDeclarationFormatter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void main()
name: 'ExtensionDeclaration',
astVisitors: <TestVisitor<void>>[
TestVisitor<TypeParameterList>(11, '<T1,T2>'),
TestVisitor<NamedType>(22, 'C<T1,T2>'),
//TestVisitor<NamedType>(22, 'C<T1,T2>'), onClause replaces onKeyword and extendedType
TestVisitor<ExtensionOnClause>(19, 'on C<T1,T2>'),
TestVisitor<MethodDeclaration>(31, 'void m(){}')
],
testConfigs: <TestConfig>[
Expand Down
3 changes: 2 additions & 1 deletion test/Formatters/MixinDeclarationFormatter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void main()
inputMiddle: 'mixin M on A, B{}',
name: 'MixinDeclaration / mixin M on A, B{}',
astVisitors: <TestVisitor<void>>[
TestVisitor<OnClause>(8, 'on A, B')
//TestVisitor<OnClause>(8, 'on A, B') OnClause => MixinOnClause
TestVisitor<MixinOnClause>(8, 'on A, B')
],
testConfigs: <TestConfig>[
TestConfig.none(),
Expand Down
1 change: 1 addition & 0 deletions test/TestTools/AstCreator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class AstCreator
static NamespaceDirective createNamespaceDirective(String s)
=> createDirective(s) as NamespaceDirective;

// ignore: deprecated_member_use
static OnClause createOnClauseInMixinDeclaration(String s)
=> createMixinDeclaration(s).onClause!;

Expand Down
1 change: 1 addition & 0 deletions test/TestTools/Visitors/SimpleVisitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ abstract class SimpleVisitor extends AstVisitor<void>
=> visit(node);

@override
// ignore: deprecated_member_use
void visitOnClause(OnClause node)
=> visit(node);

Expand Down

0 comments on commit 0c71c1d

Please sign in to comment.