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
277001d1
Unverified
Commit
277001d1
authored
Nov 28, 2017
by
Jacob Richman
Committed by
GitHub
Nov 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inspector JSON protocol to support Flutter IntelliJ Plugin tree view. (#12932)
parent
792e7ce8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
999 additions
and
43 deletions
+999
-43
diagnostics.dart
packages/flutter/lib/src/foundation/diagnostics.dart
+93
-0
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+14
-0
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+436
-9
diagnostics_test.dart
packages/flutter/test/foundation/diagnostics_test.dart
+213
-33
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+243
-1
No files found.
packages/flutter/lib/src/foundation/diagnostics.dart
View file @
277001d1
...
...
@@ -743,6 +743,33 @@ abstract class DiagnosticsNode {
String
get
_separator
=>
showSeparator
?
':'
:
''
;
/// Serialize the node excluding its descendents to a JSON map.
///
/// Subclasses should override if they have additional properties that are
/// useful for the GUI tools that consume this JSON.
///
/// See also:
///
/// * [WidgetInspectorService], which forms the bridge between JSON returned
/// by this method and interactive tree views in the Flutter IntelliJ
/// plugin.
@mustCallSuper
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
data
=
<
String
,
Object
>{
'name'
:
name
,
'showSeparator'
:
showSeparator
,
'description'
:
toDescription
(),
'level'
:
describeEnum
(
level
),
'showName'
:
showName
,
'emptyBodyDescription'
:
emptyBodyDescription
,
'style'
:
describeEnum
(
style
),
'valueToString'
:
value
.
toString
(),
'type'
:
runtimeType
.
toString
(),
'hasChildren'
:
getChildren
().
isNotEmpty
,
};
return
data
;
}
/// Returns a string representation of this diagnostic that is compatible with
/// the style of the parent if the node is not the root.
///
...
...
@@ -1054,6 +1081,13 @@ class StringProperty extends DiagnosticsProperty<String> {
/// Whether the value is enclosed in double quotes.
final
bool
quoted
;
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
json
[
'quoted'
]
=
quoted
;
return
json
;
}
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
text
=
_description
??
value
;
...
...
@@ -1114,6 +1148,15 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
level:
level
,
);
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
if
(
unit
!=
null
)
json
[
'unit'
]
=
unit
;
json
[
'numberToString'
]
=
numberToString
();
return
json
;
}
/// Optional unit the [value] is measured in.
///
...
...
@@ -1326,6 +1369,17 @@ class FlagProperty extends DiagnosticsProperty<bool> {
level:
level
,
);
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
if
(
ifTrue
!=
null
)
json
[
'ifTrue'
]
=
ifTrue
;
if
(
ifFalse
!=
null
)
json
[
'ifFalse'
]
=
ifFalse
;
return
json
;
}
/// Description to use if the property [value] is true.
///
/// If not specified and [value] equals true the property's priority [level]
...
...
@@ -1443,6 +1497,15 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
return
DiagnosticLevel
.
fine
;
return
super
.
level
;
}
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
if
(
value
!=
null
)
{
json
[
'values'
]
=
value
.
map
<
String
>((
T
value
)
=>
value
.
toString
()).
toList
();
}
return
json
;
}
}
/// An property than displays enum values tersely.
...
...
@@ -1581,6 +1644,14 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
return
super
.
level
;
}
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
if
(
ifPresent
!=
null
)
json
[
'ifPresent'
]
=
ifPresent
;
return
json
;
}
}
/// Signature for computing the value of a property.
...
...
@@ -1683,6 +1754,28 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
final
String
_description
;
@override
Map
<
String
,
Object
>
toJsonMap
()
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
();
if
(
defaultValue
!=
kNoDefaultValue
)
json
[
'defaultValue'
]
=
defaultValue
.
toString
();
if
(
ifEmpty
!=
null
)
json
[
'ifEmpty'
]
=
ifEmpty
;
if
(
ifNull
!=
null
)
json
[
'ifNull'
]
=
ifNull
;
if
(
tooltip
!=
null
)
json
[
'tooltip'
]
=
tooltip
;
json
[
'missingIfNull'
]
=
missingIfNull
;
if
(
exception
!=
null
)
json
[
'exception'
]
=
exception
.
toString
();
json
[
'propertyType'
]
=
propertyType
.
toString
();
json
[
'valueToString'
]
=
valueToString
();
json
[
'defaultLevel'
]
=
describeEnum
(
_defaultLevel
);
if
(
T
is
Diagnosticable
)
json
[
'isDiagnosticableValue'
]
=
true
;
return
json
;
}
/// Returns a string representation of the property value.
///
/// Subclasses should override this method instead of [toDescription] to
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
277001d1
...
...
@@ -3362,6 +3362,20 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
return
chain
.
join
(
'
\
u2190 '
);
}
/// Returns the parent chain from this element back to the root of the tree.
///
/// Useful for debug display of a tree of Elements with only nodes in the path
/// from the root to this Element expanded.
List
<
Element
>
debugGetDiagnosticChain
()
{
final
List
<
Element
>
chain
=
<
Element
>[
this
];
Element
node
=
_parent
;
while
(
node
!=
null
)
{
chain
.
add
(
node
);
node
=
node
.
_parent
;
}
return
chain
;
}
/// A short, textual description of this element.
@override
String
toStringShort
()
{
return
widget
!=
null
?
'
${widget.toStringShort()}
'
:
'[
$runtimeType
]'
;
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
277001d1
This diff is collapsed.
Click to expand it.
packages/flutter/test/foundation/diagnostics_test.dart
View file @
277001d1
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
277001d1
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