Skip to content

implemented search with specific 'type' and 'label' #7

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Editor/Scripts/AbstractTreeView.cs
Original file line number Diff line number Diff line change
@@ -243,7 +243,12 @@ protected override bool DoesItemMatchSearch(TreeViewItem item, string search)
if (i != null)
{
int searchCount;
i.GetItemSearchString(m_SearchCache, out searchCount);
string type;
string label;
i.GetItemSearchString(m_SearchCache, out searchCount, out type, out label);

if (!m_Search.IsTypeMatch(type) || !m_Search.IsLabelMatch(label))
return false;

m_SearchBuilder.Length = 0;
for (var n=0; n < searchCount; ++n)
@@ -253,10 +258,7 @@ protected override bool DoesItemMatchSearch(TreeViewItem item, string search)
}
m_SearchBuilder.Append("\0");

if (m_Search.IsNameMatch(m_SearchBuilder.ToString()))
return true;

return false;
return m_Search.IsNameMatch(m_SearchBuilder.ToString());
}

return base.DoesItemMatchSearch(item, search);
@@ -388,9 +390,11 @@ public abstract class AbstractTreeViewItem : TreeViewItem
public bool enabled = true;
public bool isExpanded;

public virtual void GetItemSearchString(string[] target, out int count)
public virtual void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
type = null;
label = null;
}

public abstract void OnGUI(Rect position, int column);
Original file line number Diff line number Diff line change
@@ -322,10 +322,12 @@ public void Swap()
count[1] = c;
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
target[count++] = displayName ?? k_UnknownTypeString;
base.GetItemSearchString(target, out count, out type, out label);

type = displayName ?? k_UnknownTypeString;
target[count++] = type;
}

public override void OnGUI(Rect position, int column)
6 changes: 4 additions & 2 deletions Editor/Scripts/ConnectionsView/ConnectionsControl.cs
Original file line number Diff line number Diff line change
@@ -305,9 +305,11 @@ class Item : AbstractTreeViewItem
protected string m_Value = "";
protected string m_Tooltip = "";

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = displayName;
target[count++] = displayName;
target[count++] = m_Value;
target[count++] = string.Format(StringFormat.Address, address);
6 changes: 4 additions & 2 deletions Editor/Scripts/GCHandlesView/GCHandlesControl.cs
Original file line number Diff line number Diff line change
@@ -261,9 +261,11 @@ public void Initialize(GCHandlesControl owner, PackedMemorySnapshot snapshot, in
m_GCHandle = new RichGCHandle(snapshot, gcHandlesArrayIndex);
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = typeName;
target[count++] = typeName;
target[count++] = string.Format(StringFormat.Address, address);
}
Original file line number Diff line number Diff line change
@@ -148,9 +148,10 @@ class AbstractItem : AbstractTreeViewItem
#endif
protected ManagedHeapSectionsControl m_Owner;

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

target[count++] = displayName;
target[count++] = string.Format(StringFormat.Address, address);
}
7 changes: 5 additions & 2 deletions Editor/Scripts/ManagedObjectsView/ManagedObjectsControl.cs
Original file line number Diff line number Diff line change
@@ -347,13 +347,16 @@ public void Initialize(AbstractManagedObjectsControl owner, PackedMemorySnapshot
m_Object = new RichManagedObject(snapshot, managedObject.managedObjectsArrayIndex);
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = typeName;
target[count++] = typeName;
target[count++] = string.Format(StringFormat.Address, m_Object.address);
target[count++] = cppName;
target[count++] = assembly;

}

public override void OnGUI(Rect position, int column)
6 changes: 4 additions & 2 deletions Editor/Scripts/ManagedTypesView/ManagedTypesControl.cs
Original file line number Diff line number Diff line change
@@ -235,9 +235,11 @@ public void Initialize(ManagedTypesControl owner, PackedMemorySnapshot snapshot,
m_Type = new RichManagedType(snapshot, arrayIndex);
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = typeName;
target[count++] = typeName;
}

6 changes: 4 additions & 2 deletions Editor/Scripts/NativeObjectsView/NativeObjectsControl.cs
Original file line number Diff line number Diff line change
@@ -537,9 +537,11 @@ public void Initialize(NativeObjectsControl owner, PackedNativeUnityEngineObject
#endif
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = m_Object.type.name;
target[count++] = m_Object.name;
target[count++] = m_Object.type.name;
target[count++] = string.Format(StringFormat.Address, address);
6 changes: 4 additions & 2 deletions Editor/Scripts/RootPathView/RootPathControl.cs
Original file line number Diff line number Diff line change
@@ -607,9 +607,11 @@ class Item : AbstractTreeViewItem
protected string m_Value;
protected System.UInt64 m_Address;

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = displayName;
target[count++] = displayName;
target[count++] = m_Value;
target[count++] = string.Format(StringFormat.Address, m_Address);
22 changes: 22 additions & 0 deletions Editor/Scripts/SearchTextParser.cs
Original file line number Diff line number Diff line change
@@ -35,6 +35,28 @@ public class Result
public List<string> types = new List<string>();
public List<string> labels = new List<string>();

public bool IsTypeMatch(string type)
{
if (types.Count == 0)
return true; // no type filter, always pass

if (string.IsNullOrWhiteSpace(type))
return false;

return types.Contains(type);
}

public bool IsLabelMatch(string label)
{
if (labels.Count == 0)
return true; // no label filter, always pass

if (string.IsNullOrWhiteSpace(label))
return false;

return labels.Contains(label);
}

public bool IsNameMatch(string text)
{
if (m_NamesExpr.Count == 0)
6 changes: 4 additions & 2 deletions Editor/Scripts/StaticFieldsView/StaticFieldsControl.cs
Original file line number Diff line number Diff line change
@@ -211,9 +211,11 @@ public void Initialize(StaticFieldsControl owner, PackedMemorySnapshot snapshot,
m_TypeDescription = typeDescription;
}

public override void GetItemSearchString(string[] target, out int count)
public override void GetItemSearchString(string[] target, out int count, out string type, out string label)
{
count = 0;
base.GetItemSearchString(target, out count, out type, out label);

type = typeName;
target[count++] = typeName;
target[count++] = assemblyName;
}