Beispiel #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);
        }