浏览代码

fix inspector error

/zxw-devTools
guanghuispark 3 年前
当前提交
abd6ab5a
共有 5 个文件被更改,包括 152 次插入118 次删除
  1. 4
      com.unity.uiwidgets.devtools/Editor/v2/main.cs
  2. 30
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs
  3. 10
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen.cs
  4. 208
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_service.cs
  5. 18
      com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs

4
com.unity.uiwidgets.devtools/Editor/v2/main.cs


[MenuItem("UIWidgets/DevTools")]
public static void CountDemo()
{
CreateWindow<EditorWindowDevtools>();
var myWindow = (EditorWindowDevtools) EditorWindow.GetWindow(typeof(EditorWindowDevtools));
myWindow.Show();
// CreateWindow<EditorWindowDevtools>();
}
protected override void onEnable()

30
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/diagnostics_node.cs


return JsonUtils.getStringMember(json, memberName);
}
public bool childrenReady {
get
{
return json.ContainsKey("children") || _children != null || !hasChildren;
}
}
public bool childrenReady => json.ContainsKey("children") || _children != null || !hasChildren;
public Widget icon {
get
{

InspectorSourceLocation _creationLocation;
InspectorSourceLocation creationLocation {
public InspectorSourceLocation creationLocation {
get
{
if (_creationLocation != null) {

}
var style1 = treeStyleUtils.enumEntry(value);
D.assert(style1 != null);
return style ?? defaultValue;
return style1; // ?? defaultValue
}
private EnumUtils<DiagnosticsTreeStyle> _treeStyleUtils;

}
public InspectorInstanceRef dartDiagnosticRef {
get
{
if (json.ContainsKey("objectId"))
{
return new InspectorInstanceRef((string)json["objectId"]);
}
return new InspectorInstanceRef("The key 'objectId' doesn't exist");
}
}
// void _computeChildren() {
// _maybePopulateChildren();
// if (!hasChildren || _children != null) {

}
class InspectorSourceLocation {
public class InspectorSourceLocation {
public InspectorSourceLocation(Dictionary<string, object> json, InspectorSourceLocation parent)
{
this.json = json;

public readonly Dictionary<string, object> json;
public readonly InspectorSourceLocation parent;
string path
public string path
{
get
{

10
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_screen.cs


using System.Collections.Generic;
using Unity.UIWidgets.async;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

void _refreshInspector()
{
inspectorController?.onForceRefresh();
inspectorController?.onForceRefresh().then((v) =>
{
setState(()=>{});
});
public override Widget build(BuildContext context)
{

}),
new SizedBox(height: ThemeUtils.denseRowSpacing),
new Expanded(
child:
new Split(
child: new Split(
axis: splitAxis,
initialFractions: new List<float?> {0.33f, 0.67f},
children: new List<Widget>

208
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_service.cs


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using developer;
namespace Unity.UIWidgets.DevTools.inspector
{

Future<RemoteDiagnosticsNode> invokeServiceMethodReturningNode(string methodName) {
if (disposed) return null;
if (useDaemonApi) {
if (useDaemonApi)
{
return parseDiagnosticsNodeDaemon(invokeServiceMethodDaemon(methodName));
}
// else {

if (methodName == "getRootWidgetSummaryTree")
{
return getRootWidgetSummaryTreeFake();
var result = developer_.callExtension("inspector.getRootWidgetSummaryTree", new Dictionary<string, string> {
{"objectGroup", "root"}
});
return result.then_<object>(o =>
{
if (!o.ContainsKey("result"))
{
return new SynchronousFuture<object>(null);
}
var res = (Dictionary<string, object>) o["result"];
return new SynchronousFuture<object>(res);
});
}
if (methodName == "getRootRenderObject")

// return json["result"];
// });
}
List<RemoteDiagnosticsNode> parseDiagnosticsNodesHelper(
List<object> jsonObject, RemoteDiagnosticsNode parent) {
if (disposed || jsonObject == null) return null;
List<RemoteDiagnosticsNode> nodes = new List<RemoteDiagnosticsNode>();
foreach (Dictionary<string, object> element in jsonObject) {
nodes.Add(new RemoteDiagnosticsNode(element, FutureOr.value(this), false, parent));
}
return nodes;
}
Future<List<RemoteDiagnosticsNode>> parseDiagnosticsNodesDaemon(
Future<object> jsonFuture, RemoteDiagnosticsNode parent) {
if (disposed || jsonFuture == null) return null;
public Future<object> getRootWidgetSummaryTreeFake()
{
Dictionary<string, object> widgetTree = new Dictionary<string, object>();
widgetTree["hasChildren"] = true;
widgetTree["name"] = "inspector";
widgetTree["type"] = "root";
widgetTree["propertyType"] = "IconData";
widgetTree["description"] = "root widget";
widgetTree["widgetRuntimeType"] = "class";
widgetTree["propertyType"] = "Widget";
widgetTree["creationLocation"] = new Dictionary<string, object>()
return jsonFuture.then_<List<RemoteDiagnosticsNode>>((v) =>
{"name", "inspector2"},
{"creationLocation1",new Text("creationLocation1")},
};
widgetTree["parameterLocations"] = new List<object>()
{
new Text("properties_1")
};
widgetTree["children"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
{"name", "inspector3"},
{"type", "class"},
{"widgetRuntimeType", "class"},
{"propertyType", "RenderObject"},
{"description","second level widget"},
{
"text", new List<Dictionary<string,object>>()
{
new Dictionary<string, object>()
{
{"hasChildren", true},
{"name","inspector4"},
{"propertyType", "RenderObject"},
{"description","third level widget"},
{"creationLocation", new Dictionary<string, object>()
{
{"creationLocation1",new Text("creationLocation1")},
}
},
{"parameterLocations", new List<object>()
{
new Text("properties_1")
}
},
{"children", new Dictionary<string, object>()
{
{"te1",new Text("text1a")},
}
}
}
}
},
},
new Dictionary<string, object>()
{
{"name", "inspector5"},
{"type", "class"},
{"propertyType", "RenderObject"},
{"widgetRuntimeType", "class"},
{"description","second level widget"},
{"te1",new Text("text1a")},
{"te2",new Text("text2a")},
{"te3",new Text("text3a")},
{"te4",new Text("text4a")},
{"te5",new Text("text5a")},
}
};
widgetTree["properties"] = new List<Dictionary<string, object>>()
{
new Dictionary<string, object>()
{
{"name","properties1"},
{"type", "property"},
{"propertyType", "RenderObject"},
{"description","this is a description"},
},
new Dictionary<string, object>()
{
{"name","properties2"},
{"type", "property"},
{"propertyType", "RenderObject"},
{"description","this is a description"},
}
};
return new SynchronousFuture<object>(widgetTree);
return new SynchronousFuture<List<RemoteDiagnosticsNode>>(parseDiagnosticsNodesHelper((List<object>)v, parent));
});
}
Future<object> invokeServiceMethodDaemonInspectorRef(
string methodName, InspectorInstanceRef arg) {
return invokeServiceMethodDaemonArg(methodName, arg?.id, groupName);
}
Future<object> invokeServiceMethodDaemonArg(
string methodName, string arg, string objectGroup) {
var args = new Dictionary<string, object>(){{"objectGroup", objectGroup}};
if (arg != null) {
args["arg"] = arg;
}
return invokeServiceMethodDaemonParams(methodName, args);
}
public Future<List<RemoteDiagnosticsNode>> getChildren(
InspectorInstanceRef instanceRef,
bool summaryTree,
RemoteDiagnosticsNode parent
) {
return getListHelper(
instanceRef,
summaryTree ? "getChildrenSummaryTree" : "getChildrenDetailsSubtree",
parent
);
}
Future<List<RemoteDiagnosticsNode>> getListHelper(
InspectorInstanceRef instanceRef,
String methodName,
RemoteDiagnosticsNode parent
) {
if (disposed) return null;
if (useDaemonApi) {
return parseDiagnosticsNodesDaemon(
invokeServiceMethodDaemonInspectorRef(methodName, instanceRef),
parent);
}
// else {
// return parseDiagnosticsNodesObservatory(
// invokeServiceMethodObservatoryInspectorRef(methodName, instanceRef),
// parent);
// }
return null;
}
Future<object> getRootRenderObjectFake()

Future<object> json) {
if (disposed) return null;
return json.then((value) =>
return json.then_<RemoteDiagnosticsNode>((value) =>
var res = FutureOr.value(parseDiagnosticsNodeHelper((Dictionary<string,object>)value));
return res;
}).to<RemoteDiagnosticsNode>();
return FutureOr.value(parseDiagnosticsNodeHelper((Dictionary<string,object>)value));
});
}
RemoteDiagnosticsNode parseDiagnosticsNodeHelper(

//
}
public class InspectorInstanceRef: IEquatable<InspectorInstanceRef> {
public InspectorInstanceRef(string id)
{
this.id = id;
}
public new int hashCode => id.GetHashCode();
public new string toString() => $"instance-{id}";
public readonly string id;
public bool Equals(InspectorInstanceRef other)
{
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return other is InspectorInstanceRef && Equals(id, other.id);
}
}

18
com.unity.uiwidgets.devtools/Editor/v2/src/inspector/inspector_tree.cs


return _root;
}
set {
_root = value;
}
}

D.assert(expandChildren != null);
D.assert(expandProperties != null);
node.diagnostic = diagnosticsNode;
// if (config.onNodeAdded != null) {
// config.onNodeAdded(node, diagnosticsNode);
// }
if (config.onNodeAdded != null) {
config.onNodeAdded(node, diagnosticsNode);
}
if (diagnosticsNode.hasChildren ||
diagnosticsNode.inlineProperties.isNotEmpty()) {

public delegate void TreeEventCallback(InspectorTreeNode node);
public delegate void OnClientActiveChange(bool added);
public delegate void NodeAddedCallback(InspectorTreeNode node, RemoteDiagnosticsNode diagnosticsNode);
// NodeAddedCallback onNodeAdded,
NodeAddedCallback onNodeAdded = null,
OnClientActiveChange onClientActiveChange = null,
VoidCallback onSelectionChange = null,
TreeEventCallback onExpand = null,

this.summaryTree = summaryTree;
this.treeType = treeType;
this.onNodeAdded = onNodeAdded;
this.onSelectionChange = onSelectionChange;
this.onClientActiveChange = onClientActiveChange;
this.onExpand = onExpand;

public readonly bool summaryTree;
public readonly FlutterTreeType treeType;
// public readonly NodeAddedCallback onNodeAdded;
public readonly NodeAddedCallback onNodeAdded;
}

正在加载...
取消
保存