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 {
properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0));
properties.add(DoubleProperty('thickness', thickness, defaultValue: 0.0));
final List<String> actionSummary = <String>[
// ignore: deprecated_member_use
for (final SemanticsAction action in SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList)
for (final SemanticsAction action in SemanticsAction.values)
if ((actions & action.index) != 0)
describeEnum(action),
action.name,
];
final List<String?> customSemanticsActionSummary = customSemanticsActionIds!
.map<String?>((int actionId) => CustomSemanticsAction.getAction(actionId)!.label)
......@@ -684,10 +683,9 @@ class SemanticsData with Diagnosticable {
properties.add(IterableProperty<String?>('customActions', customSemanticsActionSummary, ifEmpty: null));
final List<String> flagSummary = <String>[
// ignore: deprecated_member_use
for (final SemanticsFlag flag in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList)
for (final SemanticsFlag flag in SemanticsFlag.values)
if ((flags & flag.index) != 0)
describeEnum(flag),
flag.name,
];
properties.add(IterableProperty<String>('flags', flagSummary, ifEmpty: null));
properties.add(AttributedStringProperty('label', attributedLabel));
......@@ -2785,14 +2783,13 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
properties.add(DiagnosticsProperty<Rect>('rect', rect, description: description, showName: false));
}
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
.map<String?>((CustomSemanticsAction action) => action.label)
.toList();
properties.add(IterableProperty<String>('actions', actions, ifEmpty: null));
properties.add(IterableProperty<String?>('customActions', customSemanticsActions, ifEmpty: null));
// ignore: deprecated_member_use
final List<String> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList();
final List<String> flags = SemanticsFlag.values.where((SemanticsFlag flag) => hasFlag(flag)).map((SemanticsFlag flag) => flag.name).toList();
properties.add(IterableProperty<String>('flags', flags, ifEmpty: null));
properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible'));
properties.add(FlagProperty('isHidden', value: hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN'));
......
......@@ -346,8 +346,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
final Set<SemanticsAction> allActions = SemanticsAction.values.toSet()
..remove(SemanticsAction.customAction) // customAction is not user-exposed.
..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed
......@@ -445,8 +444,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
List<SemanticsFlag> flags = SemanticsFlag.values.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed.
flags
......@@ -500,8 +498,7 @@ void _defineTests() {
),
),
));
// ignore: deprecated_member_use
flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
flags = SemanticsFlag.values.toList();
// [SemanticsFlag.hasImplicitScrolling] isn't part of [SemanticsProperties]
// therefore it has to be removed.
flags
......
......@@ -519,8 +519,7 @@ void main() {
),
);
// ignore: deprecated_member_use
final Set<SemanticsAction> allActions = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList.toSet()
final Set<SemanticsAction> allActions = SemanticsAction.values.toSet()
..remove(SemanticsAction.moveCursorForwardByWord)
..remove(SemanticsAction.moveCursorBackwardByWord)
..remove(SemanticsAction.customAction) // customAction is not user-exposed.
......@@ -612,8 +611,7 @@ void main() {
liveRegion: true,
),
);
// ignore: deprecated_member_use
final List<SemanticsFlag> flags = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList.toList();
final List<SemanticsFlag> flags = SemanticsFlag.values.toList();
flags
..remove(SemanticsFlag.hasToggledState)
..remove(SemanticsFlag.isToggled)
......
......@@ -633,8 +633,7 @@ class SemanticsTester {
static String _flagsToSemanticsFlagExpression(dynamic flags) {
Iterable<SemanticsFlag> list;
if (flags is int) {
// ignore: deprecated_member_use
list = SemanticsFlag.doNotUseWillBeDeletedWithoutWarningValuesAsList
list = SemanticsFlag.values
.where((SemanticsFlag flag) => (flag.index & flags) != 0);
} else {
list = flags as List<SemanticsFlag>;
......@@ -649,8 +648,7 @@ class SemanticsTester {
static String _actionsToSemanticsActionExpression(dynamic actions) {
Iterable<SemanticsAction> list;
if (actions is int) {
// ignore: deprecated_member_use
list = SemanticsAction.doNotUseWillBeDeletedWithoutWarningValuesAsList
list = SemanticsAction.values
.where((SemanticsAction action) => (action.index & actions) != 0);
} else {
list = actions as List<SemanticsAction>;
......
......@@ -2533,7 +2533,11 @@ class _MatchesSemanticsData extends Matcher {
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.');
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() {
int actions = 0;
int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
// ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
actions |= index;
for (final SemanticsAction action in SemanticsAction.values) {
actions |= action.index;
}
// ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
flags |= index;
for (final SemanticsFlag flag in SemanticsFlag.values) {
flags |= flag.index;
}
final SemanticsData data = SemanticsData(
flags: flags,
......@@ -897,13 +895,11 @@ void main() {
int actions = 0;
int flags = 0;
const CustomSemanticsAction action = CustomSemanticsAction(label: 'test');
// ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
actions |= index;
for (final SemanticsAction action in SemanticsAction.values) {
actions |= action.index;
}
// ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
flags |= index;
for (final SemanticsFlag flag in SemanticsFlag.values) {
flags |= flag.index;
}
final SemanticsData data = SemanticsData(
flags: flags,
......@@ -1085,13 +1081,11 @@ void main() {
testWidgets('only matches given flags and actions', (WidgetTester tester) async {
int allActions = 0;
int allFlags = 0;
// ignore: deprecated_member_use
for (final int index in SemanticsAction.doNotUseWillBeDeletedWithoutWarningKeys) {
allActions |= index;
for (final SemanticsAction action in SemanticsAction.values) {
allActions |= action.index;
}
// ignore: deprecated_member_use
for (final int index in SemanticsFlag.doNotUseWillBeDeletedWithoutWarningKeys) {
allFlags |= index;
for (final SemanticsFlag flag in SemanticsFlag.values) {
allFlags |= flag.index;
}
final SemanticsData emptyData = SemanticsData(
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