public static string BuildHintForItem(RenamedItem item)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Type: ");
            sb.AppendLine(item.EntityType.ToString());

            if (item.SkipReason != null)
            {
                sb.AppendLine("Name:");
                sb.AppendLine(item.NameOldSimple);
                sb.AppendLine("Skip reason:");
                sb.AppendLine(item.SkipReason);
            }
            else
            {
                sb.AppendLine("Old name:");
                sb.AppendLine(item.NameOldSimple);
                sb.AppendLine("New name:");
                sb.AppendLine(CheckIfUnicode(item.NameNewSimple));
            }
            if (item.Owner.SkipReason == null)
            {
                sb.AppendLine("Owner class:");
                sb.AppendLine(CheckIfUnicode(item.Owner.TransformNameFull));
            }
            return(sb.ToString());
        }
Exemplo n.º 2
0
        public static string BuildHintForItem(RenamedItem item)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Type: ");
            sb.AppendLine(item.EntityType.ToString());
            sb.AppendLine("Old name:");
            sb.AppendLine(item.NameOldSimple);
            sb.AppendLine("New name:");
            sb.AppendLine(CheckIfUnicode(item.NameNewSimple));
            sb.AppendLine("Owner class:");
            sb.AppendLine(CheckIfUnicode(item.Owner.TransformNameFull));
            return(sb.ToString());
        }
Exemplo n.º 3
0
        private IEnumerable <INamedEntity> SearchMethodOriginal(Entity entity)
        {
            foreach (RenamedBase item in SearchItemOriginal(entity.Name))
            {
                if (item.EntityType != EntityType.Method)
                {
                    continue;
                }

                RenamedItem i = (RenamedItem)item;
                if (i.CompareParams(entity.MethodParams))
                {
                    yield return(i);
                }
            }
        }
            public string GetToolTip()
            {
                RenamedItem item = renamed as RenamedItem;

                if (item != null)
                {
                    return(TreeBuilder.BuildHintForItem(item));
                }
                RenamedClass @class = renamed as RenamedClass;

                if (@class != null)
                {
                    return(TreeBuilder.BuildHintForClass(@class));
                }

                return(entity.NameFull);
            }
Exemplo n.º 5
0
        private IEnumerable <INamedEntity> SearchMethod(Entity entity, bool allowSubstitution)
        {
            bool hasAdded = false;

            foreach (RenamedBase item in SearchItem(entity.Name))
            {
                if (item.EntityType != EntityType.Method)
                {
                    continue;
                }

                RenamedItem i = (RenamedItem)item;
                if (i.CompareParams(entity.MethodParams))
                {
                    hasAdded = true;
                    yield return(i);
                }
            }

            if (hasAdded || !allowSubstitution)
            {
                yield break;
            }

            string[] values = entity.Name.Namespace != null?entity.Name.Namespace.Split('.') : emptyArray;

            List <EntityName> methodParams = new List <EntityName>(entity.MethodParams);

            SubstituteParams(methodParams);

            foreach (RenamedClass renamedClass in classes)
            {
                foreach (RenamedBase item in renamedClass.Search(values, 0))
                {
                    yield return(new Entity(entity, item, methodParams));
                }
            }
        }
        private void BuildClassContent(RenamedClass c, PineappleTreeNode classNode)
        {
            classNode.ImageIndex = mainForm.ICON_CLASS;
            classNode.Tag        = c;

            classNode.ToolTipText = BuildHintForClass(c);
            mapping.MapRenamed(c, classNode);

            string subItemText = null;

            if (c.NameNew != null)
            {
                if (c.Name.NameNew.Equals(c.Name.NameOld))
                {
                    classNode.HighlightColorIndex = (int)Highlights.NotRenamed;
                }
                else
                {
                    subItemText = CheckIfUnicode(showModules ? c.NameNewFull : c.NameNew);
                }
            }
            else
            {
                subItemText = "n/a";
                classNode.HighlightColorIndex = (int)Highlights.NoNewName;
            }

            if (subItemText != null)
            {
                if (Configs.Instance.UseColumns)
                {
                    classNode.Subitems.Add(new PineappleTreeSubitem(subItemText));
                }
                else
                {
                    classNode.Text += "\n" + subItemText;
                }
            }

            foreach (RenamedBase renamedItem in c.Items)
            {
                if (renamedItem.EntityType == EntityType.Class)
                {
                    BuildSubclass((RenamedClass)renamedItem, classNode);
                    continue;
                }

                RenamedItem item = (RenamedItem)renamedItem;

                if (item.SkipReason != null && !showSkippedMembers)
                {
                    continue;
                }

                PineappleTreeNode node = new PineappleTreeNode(item.NameOld);
                classNode.Nodes.Add(node);
                node.ImageIndex = GetIconForEntity(item.EntityType, mainForm);
                node.Tag        = item;

                mapping.MapRenamed(item, node);

                node.ToolTipText = BuildHintForItem(item);
                subItemText      = null;

                if (item.NameNew == null)
                {
                    node.HighlightColorIndex = (int)Highlights.NoNewName;
                    subItemText = "n/a";
                }
                else
                {
                    if (item.NameNew.Equals(item.NameOld))
                    {
                        node.HighlightColorIndex = (int)Highlights.NotRenamed;
                    }
                    else
                    {
                        subItemText = CheckIfUnicode(item.NameNew);
                    }
                }

                if (subItemText != null)
                {
                    if (Configs.Instance.UseColumns)
                    {
                        node.Subitems.Add(new PineappleTreeSubitem(subItemText));
                    }
                    else
                    {
                        node.Text += "\n" + subItemText;
                    }
                }
            }
        }
        private void BuildNormalNode(PineappleTreeNode node, INamedEntity entity, string originalLine)
        {
            node.ImageIndex = TreeBuilder.GetIconForEntity(entity.EntityType, mainForm);
            ItemDescriptor descriptor = new ItemDescriptor(entity);
            string         tooltip    = descriptor.GetToolTip();

            node.Tag = descriptor;

            RenamedItem item = entity as RenamedItem;

            if (item != null)
            {
                node.Text += "\nOwner class: " + item.Owner.NameOldFull;
            }

            RenamedBase renamedBase = (RenamedBase)entity;

            if (tbtnShort.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNew;
            }
            if (tbtnSimple.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNewSimple;
            }
            if (tbtnFull.Checked)
            {
                node.Text += "\nNew name: " + renamedBase.NameNewFull;
            }

            if (originalLine != null && Configs.Instance.ShowOriginal)
            {
                node.Text += "\nOriginal line: " + originalLine;
            }

            if (!mainForm.HavePdb)
            {
                tooltip += "Unable to map to source code, no PDB files attached.";
            }
            else
            {
                if (entity.EntityType != EntityType.Method)
                {
                    tooltip += "Mapping to source code works only for methods.";
                }
                else
                {
                    ProcessPdb(descriptor);
                    if (descriptor.Filename != null)
                    {
                        node.Text += "\n" + PathUtils.ShortenPath(descriptor.Filename, 100) + ":" + descriptor.Line;
                        tooltip   += descriptor.Filename + ":" + descriptor.Line;
                    }
                    else
                    {
                        tooltip += "Unable to map to source code.";
                    }
                }
            }

            node.ToolTipText = tooltip;
        }