diff --git a/test/comment_referable/comment_referable_test.dart b/test/comment_referable/comment_referable_test.dart
index 74afa135ee..37ec1d857e 100644
--- a/test/comment_referable/comment_referable_test.dart
+++ b/test/comment_referable/comment_referable_test.dart
@@ -2,10 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// @dart=2.9
-
library dartdoc.comment_reference_test;
+import 'package:collection/collection.dart';
import 'package:dartdoc/src/model/comment_referable.dart';
import 'package:dartdoc/src/model/model_object_builder.dart';
import 'package:dartdoc/src/model/nameable.dart';
@@ -20,21 +19,22 @@ abstract class Base extends Nameable with CommentReferable {
List get children;
- Base parent;
+ Base? parent;
/// Utility function to quickly build structures similar to [ModelElement]
/// hierarchies in dartdoc in tests.
/// Returns the added (or already existing) [Base].
Base add(String newName);
- T lookup(String value,
- {bool Function(CommentReferable) allowTree,
- bool Function(CommentReferable) filter}) =>
- referenceBy(value.split(_separator),
- allowTree: allowTree ?? (_) => true, filter: filter ?? (_) => true);
+ CommentReferable? lookup(String value,
+ {bool Function(CommentReferable?)? allowTree,
+ bool Function(CommentReferable?)? filter}) {
+ return referenceBy(value.split(_separator),
+ allowTree: allowTree ?? (_) => true, filter: filter ?? (_) => true);
+ }
@override
- Iterable get referenceGrandparentOverrides => null;
+ Iterable? get referenceGrandparentOverrides => null;
}
class Top extends Base {
@@ -49,13 +49,13 @@ class Top extends Base {
Base add(String newName) {
Base retval;
var newNameSplit = newName.split(_separator).toList();
- var parent = children.firstWhere((c) => c.name == newNameSplit.first,
- orElse: () => null);
+ var parent = children.firstWhereOrNull((c) => c.name == newNameSplit.first);
if (parent == null) {
parent = TopChild(newNameSplit.last, [], this);
children.add(parent);
retval = parent;
}
+ retval = parent;
if (newNameSplit.length > 1) {
retval = parent.add(newNameSplit.sublist(1).join(_separator));
}
@@ -78,13 +78,13 @@ abstract class Child extends Base {
Base add(String newName) {
Base retval;
var newNameSplit = newName.split(_separator).toList();
- var child = children.firstWhere((c) => c.name == newNameSplit.first,
- orElse: () => null);
+ var child = children.firstWhereOrNull((c) => c.name == newNameSplit.first);
if (child == null) {
child = GenericChild(newNameSplit.last, [], this);
children.add(child);
- retval = child;
}
+
+ retval = child;
if (newNameSplit.length > 1) {
retval = child.add(newNameSplit.sublist(1).join(_separator));
}
@@ -141,7 +141,7 @@ class GrandparentOverrider extends GenericChild {
void main() {
group('Basic comment reference lookups', () {
- Top referable;
+ late Top referable;
setUp(() {
referable = Top('top', []);
@@ -157,10 +157,10 @@ void main() {
});
test('Check that basic lookups work', () {
- expect(referable.lookup('lib1').name, equals('lib1'));
- expect(referable.lookup('lib2').name, equals('lib2'));
- expect(referable.lookup('lib1.class2.member1').name, equals('member1'));
- expect(referable.lookup('lib2.class3').name, equals('class3'));
+ expect(referable.lookup('lib1')?.name, equals('lib1'));
+ expect(referable.lookup('lib2')?.name, equals('lib2'));
+ expect(referable.lookup('lib1.class2.member1')?.name, equals('member1'));
+ expect(referable.lookup('lib2.class3')?.name, equals('class3'));
});
test('Check that filters work', () {
diff --git a/test/comment_referable/parser_test.dart b/test/comment_referable/parser_test.dart
index 8f900d7e51..4eae8647dd 100644
--- a/test/comment_referable/parser_test.dart
+++ b/test/comment_referable/parser_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// @dart=2.9
-
import 'package:dartdoc/src/comment_references/parser.dart';
import 'package:test/test.dart';