From 0daa5464e9495793b659073638a0a4b03cf8c1f9 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 20 May 2020 23:48:39 -0700 Subject: [PATCH] null-annotate semantics.dart Covers the remaining API surface of the semantics library. --- lib/ui/semantics.dart | 14 ++++++++------ lib/web_ui/lib/src/ui/semantics.dart | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/ui/semantics.dart b/lib/ui/semantics.dart index c0b32450fbd58..542aba9fd862f 100644 --- a/lib/ui/semantics.dart +++ b/lib/ui/semantics.dart @@ -12,7 +12,7 @@ part of dart.ui; // `lib/ui/semantics/semantics_node.h` and in each of the embedders *must* be // updated. class SemanticsAction { - const SemanticsAction._(this.index); + const SemanticsAction._(this.index) : assert(index != null); static const int _kTapIndex = 1 << 0; static const int _kLongPressIndex = 1 << 1; @@ -42,7 +42,7 @@ class SemanticsAction { /// The numerical value for this action. /// /// Each action has one bit set in this bit field. - final int index; + final int/*!*/ index; /// The equivalent of a user briefly tapping the screen with the finger /// without moving it. @@ -263,7 +263,8 @@ class SemanticsAction { case _kMoveCursorBackwardByWordIndex: return 'SemanticsAction.moveCursorBackwardByWord'; } - return null; + assert(false, 'Unhandled index: $index'); + return ''; } } @@ -299,12 +300,12 @@ class SemanticsFlag { // READ THIS: if you add a flag here, you MUST update the numSemanticsFlags // value in testing/dart/semantics_test.dart, or tests will fail. - const SemanticsFlag._(this.index); + const SemanticsFlag._(this.index) : assert(index != null); /// The numerical value for this flag. /// /// Each flag has one bit set in this bit field. - final int index; + final int/*!*/ index; /// The semantics node has the quality of either being "checked" or "unchecked". /// @@ -596,7 +597,8 @@ class SemanticsFlag { case _kIsLinkIndex: return 'SemanticsFlag.isLink'; } - return null; + assert(false, 'Unhandled index: $index'); + return ''; } } diff --git a/lib/web_ui/lib/src/ui/semantics.dart b/lib/web_ui/lib/src/ui/semantics.dart index a2a02b4387f71..2fafa93b9c0ca 100644 --- a/lib/web_ui/lib/src/ui/semantics.dart +++ b/lib/web_ui/lib/src/ui/semantics.dart @@ -8,7 +8,7 @@ part of ui; /// The possible actions that can be conveyed from the operating system /// accessibility APIs to a semantics node. class SemanticsAction { - const SemanticsAction._(this.index); + const SemanticsAction._(this.index) : assert(index != null); static const int _kTapIndex = 1 << 0; static const int _kLongPressIndex = 1 << 1; @@ -35,7 +35,7 @@ class SemanticsAction { /// The numerical value for this action. /// /// Each action has one bit set in this bit field. - final int index; + final int/*!*/ index; /// The equivalent of a user briefly tapping the screen with the finger /// without moving it. @@ -267,7 +267,8 @@ class SemanticsAction { case _kMoveCursorBackwardByWordIndex: return 'SemanticsAction.moveCursorBackwardByWord'; } - return null; + assert(false, 'Unhandled index: $index'); + return ''; } } @@ -297,12 +298,12 @@ class SemanticsFlag { static const int _kIsFocusableIndex = 1 << 21; static const int _kIsLinkIndex = 1 << 22; - const SemanticsFlag._(this.index); + const SemanticsFlag._(this.index) : assert(index != null); /// The numerical value for this flag. /// /// Each flag has one bit set in this bit field. - final int index; + final int/*!*/ index; /// The semantics node has the quality of either being "checked" or "unchecked". /// @@ -601,7 +602,8 @@ class SemanticsFlag { case _kIsReadOnlyIndex: return 'SemanticsFlag.isReadOnly'; } - return null; + assert(false, 'Unhandled index: $index'); + return ''; } }