protected override void ContextClicked()
        {
            if (SelectionContainsRuleContainer)
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent("Run Analyze Rule"), false, RunAllSelectedRules);
                menu.AddItem(new GUIContent("Clear Analyze Results"), false, ClearAllSelectedRules);

                if (SelectionContainsFixableRule && SelectionContainsErrors)
                {
                    menu.AddItem(new GUIContent("Fix Analyze Rule"), false, FixAllSelectedRules);
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent("Fix Analyze Rule"));
                }

                IList <int> selectedIds = GetSelection();
                if (selectedIds.Count == 1)
                {
                    AnalyzeRuleContainerTreeViewItem analyzeRuleContainer = FindItem(selectedIds[0], rootItem) as AnalyzeRuleContainerTreeViewItem;
                    if (analyzeRuleContainer != null)
                    {
                        foreach (var customMenuItem in analyzeRuleContainer.analyzeRule.GetCustomContextMenuItems())
                        {
                            if (customMenuItem.MenuEnabled)
                            {
                                menu.AddItem(new GUIContent(customMenuItem.MenuName), customMenuItem.ToggledOn, () => customMenuItem.MenuAction());
                            }
                            else
                            {
                                menu.AddDisabledItem(new GUIContent(customMenuItem.MenuName));
                            }
                        }
                    }
                }

                menu.ShowAsContext();
                Repaint();
            }
            else
            {
                var selectedIds = this.GetSelection();
                List <AnalyzeResultsTreeViewItem> items = new List <AnalyzeResultsTreeViewItem>();
                foreach (int id in selectedIds)
                {
                    var item = FindItem(id, rootItem) as AnalyzeResultsTreeViewItem;
                    if (item != null)
                    {
                        items.Add(item);
                    }
                }

                if (items.Count > 0)
                {
                    AnalyzeResultsTreeViewItem.ContextClicked(items);
                }
            }
        }
        void BuildResults(TreeViewItem root, List <AnalyzeRule.AnalyzeResult> ruleResults)
        {
            hashToAnalyzeResults.Clear();
            int updateFrequency = Mathf.Max(ruleResults.Count / 10, 1);

            for (int index = 0; index < ruleResults.Count; ++index)
            {
                var result = ruleResults[index];
                if (index == 0 || index % updateFrequency == 0)
                {
                    EditorUtility.DisplayProgressBar("Building Results Tree...", result.resultName, (float)index / hashToAnalyzeResults.Keys.Count);
                }

                var          resPath = result.resultName.Split(AnalyzeRule.kDelimiter);
                string       name    = string.Empty;
                TreeViewItem parent  = root;

                for (int i = 0; i < resPath.Length; i++)
                {
                    name += resPath[i];
                    int hash = name.GetHashCode();

                    if (!hashToAnalyzeResults.ContainsKey(hash))
                    {
                        AnalyzeResultsTreeViewItem item = new AnalyzeResultsTreeViewItem(hash, i + m_CurrentDepth, resPath[i], result.severity, result);
                        hashToAnalyzeResults.Add(item.id, item);
                        parent.AddChild(item);
                        parent = item;
                    }
                    else
                    {
                        var targetItem = hashToAnalyzeResults[hash];
                        targetItem.results.Add(result);
                        parent = targetItem;
                    }
                }
            }

            EditorUtility.ClearProgressBar();

            List <TreeViewItem> allTreeViewItems = new List <TreeViewItem>();

            allTreeViewItems.Add(root);
            allTreeViewItems.AddRange(root.children);

            foreach (var node in allTreeViewItems)
            {
                (node as AnalyzeTreeViewItemBase)?.AddIssueCountToName();
            }

            AnalyzeSystem.SerializeData();
        }
        void BuildResults(TreeViewItem root, List <AnalyzeRule.AnalyzeResult> ruleResults)
        {
            hashToTreeViewItems.Clear();
            LinkedList <TreeViewItem> treeViewItems = new LinkedList <TreeViewItem>();

            hashToTreeViewItems.Add(root.id, root);
            float index = 0;


            //preprocess nodes
            foreach (var result in ruleResults)
            {
                var    resPath = result.resultName.Split(AnalyzeRule.kDelimiter);
                string name    = string.Empty;

                for (int i = 0; i < resPath.Length; i++)
                {
                    int parentHash = name.GetHashCode();
                    if (string.IsNullOrEmpty(name))
                    {
                        parentHash = root.id;
                    }
                    name += resPath[i];
                    int hash = name.GetHashCode();

                    if (hash == root.id)
                    {
                        treeViewItems.AddLast(root);
                    }
                    else
                    {
                        AnalyzeResultsTreeViewItem item = new AnalyzeResultsTreeViewItem(hash, i + m_CurrentDepth, resPath[i], parentHash, result.severity);
                        item.children = new List <TreeViewItem>();
                        treeViewItems.AddLast(item);
                    }
                }

                index++;
            }

            //create dictionary
            foreach (var item in treeViewItems)
            {
                if (item != null)
                {
                    if (!hashToTreeViewItems.ContainsKey(item.id))
                    {
                        hashToTreeViewItems.Add(item.id, item);
                    }
                }
            }

            //Build results tree
            index = 0;
            foreach (var hash in hashToTreeViewItems.Keys)
            {
                EditorUtility.DisplayProgressBar("Building Results Tree.", hashToTreeViewItems[hash].displayName, (index / hashToTreeViewItems.Keys.Count) % 100);

                TreeViewItem item;
                if (hashToTreeViewItems.TryGetValue(hash, out item))
                {
                    if ((item as AnalyzeResultsTreeViewItem) != null && hashToTreeViewItems.ContainsKey((item as AnalyzeResultsTreeViewItem).parentHash))
                    {
                        var parent = hashToTreeViewItems[(item as AnalyzeResultsTreeViewItem).parentHash];

                        if (parent.id != item.id)
                        {
                            parent.AddChild(item);
                        }
                    }
                }

                index++;
            }

            EditorUtility.ClearProgressBar();

            List <TreeViewItem> allTreeViewItems = new List <TreeViewItem>();

            allTreeViewItems.Add(root);
            allTreeViewItems.AddRange(root.children);

            foreach (var node in allTreeViewItems)
            {
                (node as AnalyzeTreeViewItemBase)?.AddIssueCountToName();
            }

            EditorUtility.SetDirty(m_AnalyzeSetting.AnalyzeData);
        }