Unverified Commit 2e4d976b authored by Bernardo Ferrari's avatar Bernardo Ferrari Committed by GitHub

`SemanticsFlag`/`SemanticsAction` cleanup (part 4) (#123329)

`SemanticsFlag`/`SemanticsAction` cleanup (part 4)
parent b1f8d5df
...@@ -672,10 +672,9 @@ class SemanticsData with Diagnosticable { ...@@ -672,10 +672,9 @@ class SemanticsData with Diagnosticable {
properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0)); properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0));
properties.add(DoubleProperty('thickness', thickness, defaultValue: 0.0)); properties.add(DoubleProperty('thickness', thickness, defaultValue: 0.0));
final List<String> actionSummary = <String>[ final List<String> actionSummary = <String>[
// ignore: deprecated_member_use for (final SemanticsAction action in SemanticsAction.values)
for (final SemanticsAction action in SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList)
if ((actions & action.index) != 0) if ((actions & action.index) != 0)
describeEnum(action), action.name,
]; ];
final List<String?> customSemanticsActionSummary = customSemanticsActionIds! final List<String?> customSemanticsActionSummary = customSemanticsActionIds!
.map<String?>((int actionId) => CustomSemanticsAction.getAction(actionId)!.label) .map<String?>((int actionId) => CustomSemanticsAction.getAction(actionId)!.label)
...@@ -684,10 +683,9 @@ class SemanticsData with Diagnosticable { ...@@ -684,10 +683,9 @@ class SemanticsData with Diagnosticable {
properties.add(IterableProperty<String?>('customActions', customSemanticsActionSummary, ifEmpty: null)); properties.add(IterableProperty<String?>('customActions', customSemanticsActionSummary, ifEmpty: null));
final List<String> flagSummary = <String>[ final List<String> flagSummary = <String>[
// ignore: deprecated_member_use for (final SemanticsFlag flag in SemanticsFlag.values)
for (final SemanticsFlag flag in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList)
if ((flags & flag.index) != 0) if ((flags & flag.index) != 0)
describeEnum(flag), flag.name,
]; ];
properties.add(IterableProperty<String>('flags', flagSummary, ifEmpty: null)); properties.add(IterableProperty<String>('flags', flagSummary, ifEmpty: null));
properties.add(AttributedStringProperty('label', attributedLabel)); properties.add(AttributedStringProperty('label', attributedLabel));
...@@ -2785,14 +2783,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { ...@@ -2785,14 +2783,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
properties.add(DiagnosticsProperty<Rect>('rect', rect, description: description, showName: false)); properties.add(DiagnosticsProperty<Rect>('rect', rect, description: description, showName: false));
} }
properties.add(IterableProperty<String>('tags', tags?.map((SemanticsTag tag) => tag.name), defaultValue: null)); properties.add(IterableProperty<String>('tags', tags?.map((SemanticsTag tag) => tag.name), defaultValue: null));
final List<String> actions = _actions.keys.map<String>((SemanticsAction action) => '${describeEnum(action)}${_debugIsActionBlocked(action) ? '🚫️' : ''}').toList()..sort(); final List<String> actions = _actions.keys.map<String>((SemanticsAction action) => '${action.name}${_debugIsActionBlocked(action) ? '🚫️' : ''}').toList()..sort();
final List<String?> customSemanticsActions = _customSemanticsActions.keys final List<String?> customSemanticsActions = _customSemanticsActions.keys
.map<String?>((CustomSemanticsAction action) => action.label) .map<String?>((CustomSemanticsAction action) => action.label)
.toList(); .toList();
properties.add(IterableProperty<String>('actions', actions, ifEmpty: null)); properties.add(IterableProperty<String>('actions', actions, ifEmpty: null));
properties.add(IterableProperty<String?>('customActions', customSemanticsActions, ifEmpty: null)); properties.add(IterableProperty<String?>('customActions', customSemanticsActions, ifEmpty: null));
// ignore: deprecated_member_use final List<String> flags = SemanticsFlag.values.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.name).toList();
final List<String> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList();
properties.add(IterableProperty<String>('flags', flags, ifEmpty: null)); properties.add(IterableProperty<String>('flags', flags, ifEmpty: null));
properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible')); properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible'));
properties.add(FlagProperty('isHidden', value: hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN')); properties.add(FlagProperty('isHidden', value: hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN'));
......
...@@ -346,8 +346,7 @@ void _defineTests() { ...@@ -346,8 +346,7 @@ void _defineTests() {
), ),
), ),
)); ));
// ignore: deprecated_member_use final Set<SemanticsAction> allActions = SemanticsAction.values.toSet()
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
..remove(SemanticsAction.customAction) // customAction is not user-exposed. ..remove(SemanticsAction.customAction) // customAction is not user-exposed.
..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed ..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed
...@@ -445,8 +444,7 @@ void _defineTests() { ...@@ -445,8 +444,7 @@ void _defineTests() {
), ),
), ),
)); ));
// ignore: deprecated_member_use List<SemanticsFlag> flags = SemanticsFlag.values.toList();
List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties] // [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed. // therefore it has to be removed.
flags flags
...@@ -500,8 +498,7 @@ void _defineTests() { ...@@ -500,8 +498,7 @@ void _defineTests() {
), ),
), ),
)); ));
// ignore: deprecated_member_use flags = SemanticsFlag.values.toList();
flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties] // [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed. // therefore it has to be removed.
flags flags
......
...@@ -519,8 +519,7 @@ void main() { ...@@ -519,8 +519,7 @@ void main() {
), ),
); );
// ignore: deprecated_member_use final Set<SemanticsAction> allActions = SemanticsAction.values.toSet()
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
..remove(SemanticsAction.moveCursorForwardByWord) ..remove(SemanticsAction.moveCursorForwardByWord)
..remove(SemanticsAction.moveCursorBackwardByWord) ..remove(SemanticsAction.moveCursorBackwardByWord)
..remove(SemanticsAction.customAction) // customAction is not user-exposed. ..remove(SemanticsAction.customAction) // customAction is not user-exposed.
...@@ -612,8 +611,7 @@ void main() { ...@@ -612,8 +611,7 @@ void main() {
liveRegion: true, liveRegion: true,
), ),
); );
// ignore: deprecated_member_use final List<SemanticsFlag> flags = SemanticsFlag.values.toList();
final List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
flags flags
..remove(SemanticsFlag.hasToggledState) ..remove(SemanticsFlag.hasToggledState)
..remove(SemanticsFlag.isToggled) ..remove(SemanticsFlag.isToggled)
......
...@@ -633,8 +633,7 @@ class SemanticsTester { ...@@ -633,8 +633,7 @@ class SemanticsTester {
static String _flagsToSemanticsFlagExpression(dynamic flags) { static String _flagsToSemanticsFlagExpression(dynamic flags) {
Iterable<SemanticsFlag> list; Iterable<SemanticsFlag> list;
if (flags is int) { if (flags is int) {
// ignore: deprecated_member_use list = SemanticsFlag.values
list = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList
.where((SemanticsFlag flag) => (flag.index & flags) != 0); .where((SemanticsFlag flag) => (flag.index & flags) != 0);
} else { } else {
list = flags as List<SemanticsFlag>; list = flags as List<SemanticsFlag>;
...@@ -649,8 +648,7 @@ class SemanticsTester { ...@@ -649,8 +648,7 @@ class SemanticsTester {
static String _actionsToSemanticsActionExpression(dynamic actions) { static String _actionsToSemanticsActionExpression(dynamic actions) {
Iterable<SemanticsAction> list; Iterable<SemanticsAction> list;
if (actions is int) { if (actions is int) {
// ignore: deprecated_member_use list = SemanticsAction.values
list = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList
.where((SemanticsAction action) => (action.index & actions) != 0); .where((SemanticsAction action) => (action.index & actions) != 0);
} else { } else {
list = actions as List<SemanticsAction>; list = actions as List<SemanticsAction>;
......
...@@ -2533,7 +2533,11 @@ class _MatchesSemanticsData extends Matcher { ...@@ -2533,7 +2533,11 @@ class _MatchesSemanticsData extends Matcher {
static String _createEnumsSummary<T extends Object>(List<T> enums) { static String _createEnumsSummary<T extends Object>(List<T> enums) {
assert(T == SemanticsAction || T == SemanticsFlag, 'This method is only intended for lists of SemanticsActions or SemanticsFlags.'); assert(T == SemanticsAction || T == SemanticsFlag, 'This method is only intended for lists of SemanticsActions or SemanticsFlags.');
return '[${enums.map(describeEnum).join(', ')}]'; if (T == SemanticsAction) {
return '[${(enums as List<SemanticsAction>).map((SemanticsAction d) => d.name).join(', ')}]';
} else {
return '[${(enums as List<SemanticsFlag>).map((SemanticsFlag d) => d.name).join(', ')}]';
}
} }
} }
......
...@@ -613,13 +613,11 @@ void main() { ...@@ -613,13 +613,11 @@ void main() {
int actions = 0; int actions = 0;
int flags = 0; int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test'); const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
// ignore: deprecated_member_use for (final SemanticsAction action in SemanticsAction.values) {
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) { actions |= action.index;
actions |= index;
} }
// ignore: deprecated_member_use for (final SemanticsFlag flag in SemanticsFlag.values) {
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) { flags |= flag.index;
flags |= index;
} }
final SemanticsData data = SemanticsData( final SemanticsData data = SemanticsData(
flags: flags, flags: flags,
...@@ -897,13 +895,11 @@ void main() { ...@@ -897,13 +895,11 @@ void main() {
int actions = 0; int actions = 0;
int flags = 0; int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test'); const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
// ignore: deprecated_member_use for (final SemanticsAction action in SemanticsAction.values) {
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) { actions |= action.index;
actions |= index;
} }
// ignore: deprecated_member_use for (final SemanticsFlag flag in SemanticsFlag.values) {
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) { flags |= flag.index;
flags |= index;
} }
final SemanticsData data = SemanticsData( final SemanticsData data = SemanticsData(
flags: flags, flags: flags,
...@@ -1085,13 +1081,11 @@ void main() { ...@@ -1085,13 +1081,11 @@ void main() {
testWidgets('only matches given flags and actions', (WidgetTester tester) async { testWidgets('only matches given flags and actions', (WidgetTester tester) async {
int allActions = 0; int allActions = 0;
int allFlags = 0; int allFlags = 0;
// ignore: deprecated_member_use for (final SemanticsAction action in SemanticsAction.values) {
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) { allActions |= action.index;
allActions |= index;
} }
// ignore: deprecated_member_use for (final SemanticsFlag flag in SemanticsFlag.values) {
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) { allFlags |= flag.index;
allFlags |= index;
} }
final SemanticsData emptyData = SemanticsData( final SemanticsData emptyData = SemanticsData(
flags: 0, flags: 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment