Пример #1
0
        public static CodeClassItem MapClass(VisualBasicSyntax.TypeBlockSyntax member,
                                             CodeViewUserControl control, SemanticModel semanticModel, SyntaxTree tree)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeClassItem>(member, member.BlockStatement.Identifier,
                                                          member.BlockStatement.Modifiers, control, semanticModel);

            item.Kind        = CodeItemKindEnum.Class;
            item.Moniker     = IconMapper.MapMoniker(item.Kind, item.Access);
            item.Parameters  = MapInheritance(member);
            item.BorderBrush = ColorHelper.ToBrush(Colors.DarkGray);
            item.Tooltip     = TooltipMapper.Map(item.Access, string.Empty, item.Name, item.Parameters);

            var regions = RegionMapper.MapRegions(tree, member.Span);
            var implementedInterfaces = InterfaceMapper.MapImplementedInterfaces(member, semanticModel);

            foreach (var classMember in member.Members)
            {
                var memberItem = SyntaxMapper.MapMember(classMember);
                if (memberItem != null && !InterfaceMapper.IsPartOfImplementedInterface(implementedInterfaces, memberItem) &&
                    !RegionMapper.AddToRegion(regions, memberItem))
                {
                    item.Members.Add(memberItem);
                }
            }

            // Add implemented interfaces to class or region if they have a interface member inside them
            if (implementedInterfaces.Any())
            {
                foreach (var interfaceItem in implementedInterfaces)
                {
                    if (interfaceItem.Members.Any())
                    {
                        if (!RegionMapper.AddToRegion(regions, interfaceItem))
                        {
                            item.Members.Add(interfaceItem);
                        }
                    }
                }
            }

            // Add regions to class if they have a region member inside them
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (region.Members.Any())
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }
Пример #2
0
        private static CodeClassItem MapClass(ClassDeclarationSyntax member)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeClassItem>(member, member.Identifier, member.Modifiers, _control, _semanticModel);

            item.Kind        = CodeItemKindEnum.Class;
            item.Moniker     = IconMapper.MapMoniker(item.Kind, item.Access);
            item.Parameters  = MapInheritance(member);
            item.BorderBrush = ColorHelper.CreateSolidColorBrush(Colors.DarkGray);
            item.Tooltip     = TooltipMapper.Map(item.Access, string.Empty, item.Name, item.Parameters);

            var regions = RegionMapper.MapRegions(_tree, member.Span);
            var implementedInterfaces = MapImplementedInterfaces(member);

            foreach (var classMember in member.Members)
            {
                var memberItem = MapMember(classMember);
                if (memberItem != null && !IsPartOfImplementedInterface(implementedInterfaces, memberItem) &&
                    !RegionMapper.AddToRegion(regions, memberItem))
                {
                    item.Members.Add(memberItem);
                }
            }

            // Add implemented interfaces to class or region if they have a interface member inside them
            if (implementedInterfaces.Any())
            {
                foreach (var interfaceItem in implementedInterfaces)
                {
                    if (interfaceItem.Members.Any())
                    {
                        if (!RegionMapper.AddToRegion(regions, interfaceItem))
                        {
                            item.Members.Add(interfaceItem);
                        }
                    }
                }
            }

            // Add regions to class if they have a region member inside them
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (region.Members.Any())
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }
Пример #3
0
        public static CodeInterfaceItem MapInterface(VisualBasicSyntax.InterfaceBlockSyntax member,
                                                     ICodeViewUserControl control, SemanticModel semanticModel, SyntaxTree tree)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeInterfaceItem>(member, member.InterfaceStatement.Identifier,
                                                              member.InterfaceStatement.Modifiers, control, semanticModel);

            item.Kind        = CodeItemKindEnum.Interface;
            item.BorderColor = Colors.DarkGray;
            item.Moniker     = IconMapper.MapMoniker(item.Kind, item.Access);

            if (TriviaSummaryMapper.HasSummary(member) && SettingsHelper.UseXMLComments)
            {
                item.Tooltip = TriviaSummaryMapper.Map(member);
            }

            var regions = RegionMapper.MapRegions(tree, member.Span, control);

            foreach (var interfaceMember in member.Members)
            {
                var memberItem = SyntaxMapper.MapMember(interfaceMember);
                if (memberItem != null && !RegionMapper.AddToRegion(regions, memberItem))
                {
                    item.Members.Add(memberItem);
                }
            }

            // Add regions to interface if they have a region member inside them
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (region.Members.Any())
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }
Пример #4
0
        public static CodeNamespaceItem MapNamespace(NamespaceDeclarationSyntax member,
                                                     ICodeViewUserControl control, SemanticModel semanticModel, SyntaxTree tree)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeNamespaceItem>(member, member.Name, control, semanticModel);

            item.Kind             = CodeItemKindEnum.Namespace;
            item.Moniker          = IconMapper.MapMoniker(item.Kind, item.Access);
            item.BorderColor      = Colors.DarkGray;
            item.IgnoreVisibility = VisibilityHelper.GetIgnoreVisibility(item);

            if (TriviaSummaryMapper.HasSummary(member) && SettingsHelper.UseXMLComments)
            {
                item.Tooltip = TriviaSummaryMapper.Map(member);
            }

            var regions = RegionMapper.MapRegions(tree, member.Span, control);

            foreach (var namespaceMember in member.Members)
            {
                var memberItem = SyntaxMapper.MapMember(namespaceMember);
                if (memberItem != null && !RegionMapper.AddToRegion(regions, memberItem))
                {
                    item.Members.Add(memberItem);
                }
            }

            // Add regions to namespace if they are not present in any children of the namespace
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (FindHelper.FindCodeItem(item.Members, region.Id) == null)
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }