Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5b12b746
Unverified
Commit
5b12b746
authored
Jul 04, 2023
by
Polina Cherkasova
Committed by
GitHub
Jul 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: stop accepting DiagnosticsNode as input from DevTools. (#129302)
parent
590ef2d4
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
302 deletions
+60
-302
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+27
-40
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+33
-262
No files found.
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
5b12b746
...
...
@@ -1722,8 +1722,8 @@ mixin WidgetInspectorService {
return
_safeJsonEncode
(
_getProperties
(
diagnosticsNodeId
,
groupName
));
}
List
<
Object
>
_getProperties
(
String
?
diagnostic
sOrDiagnostic
ableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnostic
sOrDiagnostic
ableId
);
List
<
Object
>
_getProperties
(
String
?
diagnosticableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnosticableId
);
if
(
node
==
null
)
{
return
const
<
Object
>[];
}
...
...
@@ -1760,28 +1760,22 @@ mixin WidgetInspectorService {
return
_safeJsonEncode
(
_getChildrenSummaryTree
(
diagnosticsNodeId
,
groupName
));
}
DiagnosticsNode
?
_idToDiagnosticsNode
(
String
?
diagnosticsOrDiagnosticableId
)
{
// TODO(polina-c): start always assuming Diagnosticable, when DevTools stops sending DiagnosticsNode to
// APIs that invoke this method.
// https://github.com/flutter/devtools/issues/3951
final
Object
?
object
=
toObject
(
diagnosticsOrDiagnosticableId
);
DiagnosticsNode
?
_idToDiagnosticsNode
(
String
?
diagnosticableId
)
{
final
Object
?
object
=
toObject
(
diagnosticableId
);
return
objectToDiagnosticsNode
(
object
);
}
/// If pos
i
ible, returns [DiagnosticsNode] for the object.
/// If pos
s
ible, returns [DiagnosticsNode] for the object.
@visibleForTesting
static
DiagnosticsNode
?
objectToDiagnosticsNode
(
Object
?
object
)
{
if
(
object
is
DiagnosticsNode
)
{
return
object
;
}
if
(
object
is
Diagnosticable
)
{
return
object
.
toDiagnosticsNode
();
}
return
null
;
}
List
<
Object
>
_getChildrenSummaryTree
(
String
?
diagnostic
sOrDiagnostic
ableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnostic
sOrDiagnostic
ableId
);
List
<
Object
>
_getChildrenSummaryTree
(
String
?
diagnosticableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnosticableId
);
if
(
node
==
null
)
{
return
<
Object
>[];
}
...
...
@@ -1791,17 +1785,17 @@ mixin WidgetInspectorService {
}
/// Returns a JSON representation of the children of the [DiagnosticsNode]
/// object that [diagnostic
sOrDiagnostic
ableId] references providing information needed
/// object that [diagnosticableId] references providing information needed
/// for the details subtree view.
///
/// The details subtree shows properties inline and includes all children
/// rather than a filtered set of important children.
String
getChildrenDetailsSubtree
(
String
diagnostic
sOrDiagnostic
ableId
,
String
groupName
)
{
return
_safeJsonEncode
(
_getChildrenDetailsSubtree
(
diagnostic
sOrDiagnostic
ableId
,
groupName
));
String
getChildrenDetailsSubtree
(
String
diagnosticableId
,
String
groupName
)
{
return
_safeJsonEncode
(
_getChildrenDetailsSubtree
(
diagnosticableId
,
groupName
));
}
List
<
Object
>
_getChildrenDetailsSubtree
(
String
?
diagnostic
sOrDiagnostic
ableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnostic
sOrDiagnostic
ableId
);
List
<
Object
>
_getChildrenDetailsSubtree
(
String
?
diagnosticableId
,
String
groupName
)
{
final
DiagnosticsNode
?
node
=
_idToDiagnosticsNode
(
diagnosticableId
);
// With this value of minDepth we only expand one extra level of important nodes.
final
InspectorSerializationDelegate
delegate
=
InspectorSerializationDelegate
(
groupName:
groupName
,
includeProperties:
true
,
service:
this
);
return
_nodesToJson
(
node
==
null
?
const
<
DiagnosticsNode
>[]
:
_getChildrenFiltered
(
node
,
delegate
),
delegate
,
parent:
node
);
...
...
@@ -1913,19 +1907,19 @@ mixin WidgetInspectorService {
/// * [getChildrenDetailsSubtree], a method to get children of a node
/// in the details subtree.
String
getDetailsSubtree
(
String
diagnostic
sOrDiagnostic
ableId
,
String
diagnosticableId
,
String
groupName
,
{
int
subtreeDepth
=
2
,
})
{
return
_safeJsonEncode
(
_getDetailsSubtree
(
diagnostic
sOrDiagnostic
ableId
,
groupName
,
subtreeDepth
));
return
_safeJsonEncode
(
_getDetailsSubtree
(
diagnosticableId
,
groupName
,
subtreeDepth
));
}
Map
<
String
,
Object
?>?
_getDetailsSubtree
(
String
?
diagnostic
sOrDiagnostic
ableId
,
String
?
diagnosticableId
,
String
?
groupName
,
int
subtreeDepth
,
)
{
final
DiagnosticsNode
?
root
=
_idToDiagnosticsNode
(
diagnostic
sOrDiagnostic
ableId
);
final
DiagnosticsNode
?
root
=
_idToDiagnosticsNode
(
diagnosticableId
);
if
(
root
==
null
)
{
return
null
;
}
...
...
@@ -1941,15 +1935,12 @@ mixin WidgetInspectorService {
}
/// Returns a [DiagnosticsNode] representing the currently selected [Element].
///
/// If the currently selected [Element] is identical to the [Element]
/// referenced by `previousSelectionId` then the previous [DiagnosticsNode] is
/// reused.
// TODO(polina-c): delete [previousSelectionId] when it is not used in DevTools
// https://github.com/flutter/devtools/issues/3951
@protected
String
getSelectedWidget
(
String
?
previousSelectionId
,
String
groupName
)
{
return
_safeJsonEncode
(
_getSelectedWidget
(
previousSelectionId
,
groupName
));
if
(
previousSelectionId
!=
null
)
{
debugPrint
(
'previousSelectionId is deprecated in API'
);
}
return
_safeJsonEncode
(
_getSelectedWidget
(
null
,
groupName
));
}
/// Captures an image of the current state of an [object] that is a
...
...
@@ -2025,11 +2016,11 @@ mixin WidgetInspectorService {
Future
<
Map
<
String
,
Object
?>>
_getLayoutExplorerNode
(
Map
<
String
,
String
>
parameters
,
)
{
final
String
?
diagnostic
sOrDiagnostic
ableId
=
parameters
[
'id'
];
final
String
?
diagnosticableId
=
parameters
[
'id'
];
final
int
subtreeDepth
=
int
.
parse
(
parameters
[
'subtreeDepth'
]!);
final
String
?
groupName
=
parameters
[
'groupName'
];
Map
<
String
,
dynamic
>?
result
=
<
String
,
dynamic
>{};
final
DiagnosticsNode
?
root
=
_idToDiagnosticsNode
(
diagnostic
sOrDiagnostic
ableId
);
final
DiagnosticsNode
?
root
=
_idToDiagnosticsNode
(
diagnosticableId
);
if
(
root
==
null
)
{
return
Future
<
Map
<
String
,
dynamic
>>.
value
(<
String
,
dynamic
>{
'result'
:
result
,
...
...
@@ -2233,14 +2224,11 @@ mixin WidgetInspectorService {
/// if the selected [Element] should be shown in the summary tree otherwise
/// returns the first ancestor of the selected [Element] shown in the summary
/// tree.
///
/// If the currently selected [Element] is identical to the [Element]
/// referenced by `previousSelectionId` then the previous [DiagnosticsNode] is
/// reused.
// TODO(polina-c): delete paramater [previousSelectionId] when it is not used in DevTools
// https://github.com/flutter/devtools/issues/3951
String
getSelectedSummaryWidget
(
String
previousSelectionId
,
String
groupName
)
{
return
_safeJsonEncode
(
_getSelectedSummaryWidget
(
previousSelectionId
,
groupName
));
String
getSelectedSummaryWidget
(
String
?
previousSelectionId
,
String
groupName
)
{
if
(
previousSelectionId
!=
null
)
{
debugPrint
(
'previousSelectionId is deprecated in API'
);
}
return
_safeJsonEncode
(
_getSelectedSummaryWidget
(
null
,
groupName
));
}
_Location
?
_getSelectedSummaryWidgetLocation
(
String
?
previousSelectionId
)
{
...
...
@@ -3609,7 +3597,6 @@ class InspectorSerializationDelegate implements DiagnosticsSerializationDelegate
final
Map
<
String
,
Object
?>
result
=
<
String
,
Object
?>{};
final
Object
?
value
=
node
.
value
;
if
(
_interactive
)
{
result
[
'objectId'
]
=
service
.
toId
(
node
,
groupName
!);
result
[
'valueId'
]
=
service
.
toId
(
value
,
groupName
!);
}
if
(
summaryTree
)
{
...
...
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
5b12b746
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment