예제 #1
0
        public static CodeNamespaceItem MapNamespace(VisualBasicSyntax.NamespaceBlockSyntax member,
                                                     CodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

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

            item.Kind = CodeItemKindEnum.Namespace;
            foreach (var namespaceMember in member.Members)
            {
                item.Members.Add(SyntaxMapper.MapMember(namespaceMember));
            }
            return(item);
        }
예제 #2
0
        public static CodeNamespaceItem MapNamespace(VisualBasicSyntax.NamespaceBlockSyntax member,
                                                     ICodeViewUserControl control, SemanticModel semanticModel, SyntaxTree tree)
        {
            if (member == null)
            {
                return(null);
            }

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

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

            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 class if they have a region member inside them
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (FindHelper.FindCodeItem(item.Members, region.Id) == null)
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }