Skip to content

Commit dbd787f

Browse files
Fix a TODO to use String utilities and remove stale TODOs (#9695)
1 parent 1fbe576 commit dbd787f

7 files changed

Lines changed: 17 additions & 15 deletions

File tree

packages/devtools_app/lib/src/screens/debugger/codeview_controller.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import '../../shared/framework/routing.dart';
1919
import '../../shared/globals.dart';
2020
import '../../shared/managers/notifications.dart';
2121
import '../../shared/primitives/history_manager.dart';
22+
import '../../shared/primitives/utils.dart';
2223
import '../../shared/ui/search.dart';
2324
import '../../shared/utils/utils.dart';
2425
import '../vm_developer/vm_service_private_extensions.dart';
@@ -419,12 +420,11 @@ class CodeViewController extends DisposableController
419420
return [];
420421
}
421422
final matches = <SourceToken>[];
422-
final caseInsensitiveSearch = search.toLowerCase();
423423

424424
final currentScript = parsedScript.value!;
425425
for (int i = 0; i < currentScript.lines.length; i++) {
426-
final line = currentScript.lines[i].toLowerCase();
427-
final matchesForLine = caseInsensitiveSearch.allMatches(line);
426+
final line = currentScript.lines[i];
427+
final matchesForLine = search.caseInsensitiveAllMatches(line);
428428
if (matchesForLine.isNotEmpty) {
429429
matches.addAll(
430430
matchesForLine.map(

packages/devtools_app/lib/src/screens/memory/panes/tracing/tracing_data.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ class TracedClass with PinnableListEntry, Serializable {
8989
'${clazz.name} instances: $instances trace: $traceAllocations';
9090
}
9191

92-
// TODO(kenz): include the selected class in the toJson and fromJson methods.
9392
@visibleForTesting
94-
enum TracingIsolateStateJson { isolate, classes, profiles }
93+
enum TracingIsolateStateJson { isolate, classes, profiles, selectedClass }
9594

9695
/// Contains allocation tracing state for a single isolate.
9796
///
@@ -107,6 +106,9 @@ class TracingIsolateState with Serializable {
107106
this.classes = classes ?? [];
108107
classesById = {for (final e in this.classes) e.clazz.id!: e};
109108
this.profiles = profiles ?? {};
109+
if (selectedClass != null) {
110+
this.selectedClass.value = classesById[selectedClass];
111+
}
110112
}
111113

112114
TracingIsolateState.empty() : this(isolate: IsolateRef());
@@ -125,6 +127,8 @@ class TracingIsolateState with Serializable {
125127
classes: (json[TracingIsolateStateJson.classes.name] as List)
126128
.map((e) => deserialize<TracedClass>(e, TracedClass.fromJson))
127129
.toList(),
130+
selectedClass:
131+
json[TracingIsolateStateJson.selectedClass.name] as String?,
128132
);
129133
}
130134

@@ -134,6 +138,9 @@ class TracingIsolateState with Serializable {
134138
TracingIsolateStateJson.isolate.name: isolate,
135139
TracingIsolateStateJson.classes.name: classesById.values.toList(),
136140
TracingIsolateStateJson.profiles.name: profiles,
141+
if (selectedClass.value != null)
142+
TracingIsolateStateJson.selectedClass.name:
143+
selectedClass.value!.clazz.id!,
137144
};
138145
}
139146

packages/devtools_app/lib/src/shared/primitives/utils.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,6 @@ extension NullableStringExtension on String? {
945945
}
946946

947947
// TODO(kenz): consider moving other String helpers into this extension.
948-
// TODO(kenz): replace other uses of toLowerCase() for string matching with
949-
// this extension method.
950948
extension StringExtension on String {
951949
bool caseInsensitiveContains(Pattern? pattern) {
952950
if (pattern is RegExp) {

packages/devtools_app/lib/src/shared/ui/search.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,10 +1248,9 @@ class _AutoCompleteSearchFieldState extends State<AutoCompleteSearchField>
12481248
String? foundExact;
12491249

12501250
// What the user has typed in so far.
1251-
final searchToMatch = widget.controller.search.toLowerCase();
12521251
// Find exact match in autocomplete list - use that as our search value.
12531252
for (final autoEntry in widget.controller.searchAutoComplete.value) {
1254-
if (searchToMatch == autoEntry.text.toLowerCase()) {
1253+
if (autoEntry.text.caseInsensitiveEquals(widget.controller.search)) {
12551254
foundExact = autoEntry.text;
12561255
break;
12571256
}

packages/devtools_app/lib/src/shared/ui/vm_flag_widgets.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,13 @@ class _VMFlagsDialogState extends State<VMFlagsDialog> with AutoDisposeMixin {
183183
}
184184

185185
void _refilter() {
186-
final filter = filterController.text.trim().toLowerCase();
186+
final filter = filterController.text.trim();
187187

188188
filteredFlags = filter.isEmpty
189189
? flags
190-
: flags.where((flag) => flag.filterText.contains(filter)).toList();
190+
: flags
191+
.where((flag) => flag.filterText.caseInsensitiveContains(filter))
192+
.toList();
191193
}
192194

193195
@override

packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_environment.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ class _SimulatedApi extends StatelessWidget {
207207
label: 'FORCE RELOAD',
208208
onPressed: simController.forceReload,
209209
),
210-
// TODO(kenz): add buttons for other simulated events as the extension
211-
// API expands.
212210
],
213211
),
214212
const SizedBox(height: defaultSpacing),

packages/devtools_shared/lib/src/server/server_api.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import 'devtools_store.dart';
2626
import 'file_system.dart';
2727
import 'flutter_store.dart';
2828

29-
// TODO(kenz): consider using Dart augmentation libraries instead of part files
30-
// if there is a clear benefit.
3129
part 'handlers/_app_size.dart';
3230
part 'handlers/_deeplink.dart';
3331
part 'handlers/_devtools_extensions.dart';

0 commit comments

Comments
 (0)