Skip to content

Commit 38c92e2

Browse files
committed
fix pretty print review comment
1 parent ea85f52 commit 38c92e2

7 files changed

Lines changed: 14 additions & 15 deletions

File tree

packages/devtools_app/benchmark/devtools_benchmarks_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Future<void> _runBenchmarks({bool useWasm = false}) async {
9292

9393
stdout.writeln('Web benchmark tests finished.');
9494

95-
expect(taskResult.toJson().prettyPrint(), isA<String>());
95+
expect(prettyPrintJson(taskResult.toJson()), isA<String>());
9696
expect(taskResult.scores.keys, hasLength(DevToolsBenchmark.values.length));
9797

9898
for (final devToolsBenchmark in DevToolsBenchmark.values) {

packages/devtools_app/benchmark/scripts/compare_benchmarks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ void compareBenchmarks(
6262
stdout.writeln('Baseline comparison finished.');
6363
stdout
6464
..writeln('==== Comparison with baseline $baselineSource ====')
65-
..writeln(delta.toJson().prettyPrint())
65+
..writeln(prettyPrintJson(delta.toJson()))
6666
..writeln('==== End of baseline comparison ====');
6767
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ class Grammar {
6969

7070
@override
7171
String toString() {
72-
return {
72+
return prettyPrintJson({
7373
'name': name,
7474
'scopeName': scopeName,
7575
'topLevelMatcher': topLevelMatcher.toJson(),
7676
'repository': repository.toJson(),
77-
}.prettyPrint();
77+
});
7878
}
7979
}
8080

packages/devtools_app/lib/src/screens/logging/logging_controller.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,7 @@ class LogData with SearchableDataMixin {
10381038
}
10391039

10401040
try {
1041-
return (jsonDecode(details!) as Object?)
1042-
.prettyPrint()
1041+
return prettyPrintJson(jsonDecode(details!) as Object?)
10431042
.replaceAll(r'\n', '\n')
10441043
.trim();
10451044
} catch (_) {

packages/devtools_app/lib/src/shared/config_specific/framework_initialize/_framework_initialize_desktop.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class FlutterDesktopStorage implements Storage {
3737
File(_preferencesFile.path).createSync(recursive: true);
3838
_fileAndDirVerified = true;
3939
}
40-
_preferencesFile.writeAsStringSync('${_values.prettyPrint()}\n');
40+
_preferencesFile.writeAsStringSync('${prettyPrintJson(_values)}\n');
4141
}
4242

4343
Map<String, Object?> _readValues() {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ class JsonUtils {
212212
}
213213
}
214214

215-
/// Add pretty print for a JSON payload.
216-
extension JsonObjectExtension on Object? {
217-
String prettyPrint() => const JsonEncoder.withIndent(' ').convert(this);
218-
}
215+
/// Returns a pretty-printed representation of a JSON payload.
216+
String prettyPrintJson(Object? json) =>
217+
const JsonEncoder.withIndent(' ').convert(json);
219218

220219
typedef RateLimiterCallback = Future<void> Function();
221220

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,13 +1044,14 @@ class _JsonViewerState extends State<JsonViewer> {
10441044
String copyJsonData(DartObjectNode copiedVariable) {
10451045
// Check if service connection is active
10461046
if (serviceConnection.serviceManager.connectedState.value.connected) {
1047-
return serviceConnection.serviceManager.service!.fakeServiceCache
1048-
.instanceToJson(copiedVariable.value as Instance)
1049-
.prettyPrint();
1047+
return prettyPrintJson(
1048+
serviceConnection.serviceManager.service!.fakeServiceCache
1049+
.instanceToJson(copiedVariable.value as Instance),
1050+
);
10501051
}
10511052

10521053
// Directly convert object to JSON if not connected
1053-
return copiedVariable.value.prettyPrint();
1054+
return prettyPrintJson(copiedVariable.value);
10541055
}
10551056
}
10561057

0 commit comments

Comments
 (0)