Skip to content

Commit 8a8972c

Browse files
authored
Migrate warnings.dart (#2787)
1 parent 1abe7fd commit 8a8972c

File tree

3 files changed

+158
-123
lines changed

3 files changed

+158
-123
lines changed

lib/src/dartdoc_options.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ abstract class DartdocOption<T> {
450450

451451
/// To avoid accessing early, call [add] on the option's parent before
452452
/// looking up unless this is a [DartdocRootOption].
453-
late final DartdocOption parent;
453+
late final DartdocOption<dynamic> parent;
454454

455455
/// The [DartdocOptionRoot] containing this object.
456456
DartdocOptionRoot get root {
@@ -516,10 +516,13 @@ abstract class DartdocOption<T> {
516516
void addAll(Iterable<DartdocOption> options) => options.forEach(add);
517517

518518
/// Get the immediate child of this node named [name].
519-
DartdocOption<dynamic> operator [](String name) {
519+
DartdocOption operator [](String name) {
520520
return _children[name]!;
521521
}
522522

523+
/// Get the immediate child of this node named [name] as a [DartdocOption<U>].
524+
DartdocOption<U> getAs<U>(String name) => _children[name] as DartdocOption<U>;
525+
523526
/// Apply the function [visit] to [this] and all children.
524527
void traverse(void Function(DartdocOption option) visit) {
525528
visit(this);

lib/src/model/accessor.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ class Accessor extends ModelElement implements EnclosedElement {
100100
}
101101

102102
@override
103-
void warn(PackageWarning kind,
104-
{String message,
105-
Iterable<Locatable> referredFrom,
106-
Iterable<String> extendedDebug}) {
103+
void warn(
104+
PackageWarning kind, {
105+
String message,
106+
Iterable<Locatable> referredFrom = const [],
107+
Iterable<String> extendedDebug = const [],
108+
}) {
107109
enclosingCombo.warn(kind,
108110
message: message,
109111
referredFrom: referredFrom,

0 commit comments

Comments
 (0)