Skip to content

Commit 905bd99

Browse files
polina-cCoderDake
authored andcommitted
Add details to diff. (flutter#4549)
1 parent 1861517 commit 905bd99

33 files changed

+1377
-550
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ Podfile.lock
2727
**/build/
2828
packages/devtools_test/lib/src/mocks/generated.mocks.dart
2929
**/*.stager_app.dart
30+
**/test/**/failures/

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,15 @@ class ListValueNotifier<T> extends ChangeNotifier
13191319
_rawList.removeRange(start, end);
13201320
_listChanged();
13211321
}
1322+
1323+
/// Removes the object at position `index` from this list.
1324+
///
1325+
/// https://api.flutter.dev/flutter/dart-core/List/removeAt.html
1326+
void removeAt(int index) {
1327+
_rawList = _rawList.toList();
1328+
_rawList.removeAt(index);
1329+
_listChanged();
1330+
}
13221331
}
13231332

13241333
/// Wrapper for a list that prevents any modification of the list's content.
@@ -1505,3 +1514,24 @@ bool isPrimativeInstanceKind(String? kind) {
15051514
/// Returns the file name from a URI or path string, by splitting the [uri] at
15061515
/// the directory separators '/', and returning the last element.
15071516
String? fileNameFromUri(String? uri) => uri?.split('/').last;
1517+
1518+
/// Calculates subtraction of two maps.
1519+
///
1520+
/// Result map keys is union of the imput maps' keys.
1521+
Map<K, R> subtractMaps<K, F, S, R>({
1522+
required Map<K, S>? substract,
1523+
required Map<K, F>? from,
1524+
required R? Function({required S? subtract, required F? from}) subtractor,
1525+
}) {
1526+
from ??= <K, F>{};
1527+
substract ??= <K, S>{};
1528+
1529+
final result = <K, R>{};
1530+
final unionOfKeys = from.keys.toSet().union(substract.keys.toSet());
1531+
1532+
for (var key in unionOfKeys) {
1533+
final diff = subtractor(from: from[key], subtract: substract[key]);
1534+
if (diff != null) result[key] = diff;
1535+
}
1536+
return result;
1537+
}

packages/devtools_app/lib/src/screens/memory/memory_heap_tree_view.dart

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -440,69 +440,66 @@ class _HeapTreeViewState extends State<HeapTreeView>
440440
snapshotDisplay = null;
441441
}
442442

443-
return Padding(
444-
padding: const EdgeInsets.only(top: denseRowSpacing),
445-
child: Column(
446-
children: [
447-
const SizedBox(height: defaultSpacing),
448-
ValueListenableBuilder<int>(
449-
valueListenable: _currentTab,
450-
builder: (context, index, _) => Row(
451-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
452-
children: [
453-
TabBar(
454-
labelColor: themeData.textTheme.bodyLarge!.color,
455-
isScrollable: true,
456-
controller: _tabController,
457-
tabs: _tabs,
458-
),
459-
if (_searchableTabs.contains(_tabs[index].key))
460-
_buildSearchFilterControls(),
461-
],
462-
),
443+
return Column(
444+
children: [
445+
const SizedBox(height: defaultSpacing),
446+
ValueListenableBuilder<int>(
447+
valueListenable: _currentTab,
448+
builder: (context, index, _) => Row(
449+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
450+
children: [
451+
TabBar(
452+
labelColor: themeData.textTheme.bodyLarge!.color,
453+
isScrollable: true,
454+
controller: _tabController,
455+
tabs: _tabs,
456+
),
457+
if (_searchableTabs.contains(_tabs[index].key))
458+
_buildSearchFilterControls(),
459+
],
463460
),
464-
const Divider(),
465-
Expanded(
466-
child: TabBarView(
467-
physics: defaultTabBarViewPhysics,
468-
controller: _tabController,
469-
children: [
470-
// Profile Tab
471-
KeepAliveWrapper(
472-
child: AllocationProfileTableView(
473-
controller: controller.allocationProfileController,
474-
),
461+
),
462+
const Divider(),
463+
Expanded(
464+
child: TabBarView(
465+
physics: defaultTabBarViewPhysics,
466+
controller: _tabController,
467+
children: [
468+
// Profile Tab
469+
KeepAliveWrapper(
470+
child: AllocationProfileTableView(
471+
controller: controller.allocationProfileController,
475472
),
476-
const KeepAliveWrapper(
477-
child: AllocationProfileTracingView(),
473+
),
474+
const KeepAliveWrapper(
475+
child: AllocationProfileTracingView(),
476+
),
477+
// Analysis Tab
478+
KeepAliveWrapper(
479+
child: Column(
480+
children: [
481+
_buildSnapshotControls(themeData.textTheme),
482+
const SizedBox(height: denseRowSpacing),
483+
Expanded(
484+
child: buildSnapshotTables(snapshotDisplay),
485+
),
486+
],
478487
),
479-
// Analysis Tab
488+
),
489+
// Diff tab.
490+
if (FeatureFlags.memoryDiffing)
480491
KeepAliveWrapper(
481-
child: Column(
482-
children: [
483-
_buildSnapshotControls(themeData.textTheme),
484-
const SizedBox(height: denseRowSpacing),
485-
Expanded(
486-
child: buildSnapshotTables(snapshotDisplay),
487-
),
488-
],
492+
child: DiffPane(
493+
diffController: controller.diffPaneController,
489494
),
490495
),
491-
// Diff tab.
492-
if (FeatureFlags.memoryDiffing)
493-
KeepAliveWrapper(
494-
child: DiffPane(
495-
controller: controller.diffPaneController,
496-
),
497-
),
498-
// Leaks tab.
499-
if (controller.shouldShowLeaksTab.value)
500-
const KeepAliveWrapper(child: LeaksPane()),
501-
],
502-
),
496+
// Leaks tab.
497+
if (controller.shouldShowLeaksTab.value)
498+
const KeepAliveWrapper(child: LeaksPane()),
499+
],
503500
),
504-
],
505-
),
501+
),
502+
],
506503
);
507504
}
508505

packages/devtools_app/lib/src/screens/memory/panes/allocation_profile/allocation_profile_table_view.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,8 @@ class _ExportAllocationProfileButton extends StatelessWidget {
369369
return ValueListenableBuilder<AllocationProfile?>(
370370
valueListenable: allocationProfileController.currentAllocationProfile,
371371
builder: (context, currentAllocationProfile, _) {
372-
return IconLabelButton(
373-
label: 'CSV',
374-
icon: Icons.file_download,
372+
return ToCsvButton(
373+
minScreenWidthForTextBeforeScaling: primaryControlsMinVerboseWidth,
375374
tooltip: 'Download allocation profile data in CSV format',
376375
onPressed: currentAllocationProfile == null
377376
? null
@@ -380,7 +379,6 @@ class _ExportAllocationProfileButton extends StatelessWidget {
380379
.downloadMemoryTableCsv(currentAllocationProfile);
381380
notificationService.push(successfulExportMessage(file));
382381
},
383-
minScreenWidthForTextBeforeScaling: primaryControlsMinVerboseWidth,
384382
);
385383
},
386384
);

packages/devtools_app/lib/src/screens/memory/panes/allocation_tracing/allocation_profile_tracing_view_controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class AllocationProfileTracingIsolateState {
126126

127127
void updateClassFilter(String value, {bool force = false}) {
128128
if (value.isEmpty && _currentFilter.isEmpty && !force) return;
129-
final updatedFilter = (value.contains(_currentFilter) && !force
129+
final updatedFilteredClassList = (value.contains(_currentFilter) && !force
130130
? _filteredClassList.value
131131
: unfilteredClassList)
132132
.where(
@@ -135,7 +135,7 @@ class AllocationProfileTracingIsolateState {
135135
.map((e) => tracedClasses[e.cls.id!]!)
136136
.toList();
137137

138-
_filteredClassList.replaceAll(updatedFilter);
138+
_filteredClassList.replaceAll(updatedFilteredClassList);
139139
_currentFilter = value;
140140
}
141141

0 commit comments

Comments
 (0)