示例#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
        public static CodeItem MapMember(VisualBasicSyntax.StatementSyntax member)
        {
            if (member == null)
            {
                return(null);
            }

            switch (member.Kind())
            {
            case VisualBasic.SyntaxKind.FunctionBlock:
            case VisualBasic.SyntaxKind.SubBlock:
                return(MethodMapper.MapMethod(member as VisualBasicSyntax.MethodBlockSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.SubStatement:
                return(MethodMapper.MapMethod(member as VisualBasicSyntax.MethodStatementSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.EnumBlock:
                return(EnumMapper.MapEnum(member as VisualBasicSyntax.EnumBlockSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.EnumMemberDeclaration:
                return(EnumMapper.MapEnumMember(member as VisualBasicSyntax.EnumMemberDeclarationSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.InterfaceBlock:
                return(InterfaceMapper.MapInterface(member as VisualBasicSyntax.InterfaceBlockSyntax, _control, _semanticModel, _tree));

            case VisualBasic.SyntaxKind.FieldDeclaration:
                return(FieldMapper.MapField(member as VisualBasicSyntax.FieldDeclarationSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.PropertyBlock:
                return(PropertyMapper.MapProperty(member as VisualBasicSyntax.PropertyBlockSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.StructureBlock:
                return(StructMapper.MapStruct(member as VisualBasicSyntax.StructureBlockSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.ClassBlock:
            case VisualBasic.SyntaxKind.ModuleBlock:
                return(ClassMapper.MapClass(member as VisualBasicSyntax.TypeBlockSyntax, _control, _semanticModel, _tree));

            case VisualBasic.SyntaxKind.EventBlock:
                return(DelegateEventMapper.MapEvent(member as VisualBasicSyntax.EventBlockSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.DelegateFunctionStatement:
                return(DelegateEventMapper.MapDelegate(member as VisualBasicSyntax.DelegateStatementSyntax, _control, _semanticModel));

            case VisualBasic.SyntaxKind.NamespaceBlock:
                return(NamespaceMapper.MapNamespace(member as VisualBasicSyntax.NamespaceBlockSyntax, _control, _semanticModel, _tree));

            case VisualBasic.SyntaxKind.ConstructorBlock:
                return(MethodMapper.MapConstructor(member as VisualBasicSyntax.ConstructorBlockSyntax, _control, _semanticModel));

            default:
                return(null);
            }
        }
示例#3
0
        public static CodeItem MapMember(MemberDeclarationSyntax member)
        {
            if (member == null)
            {
                return(null);
            }

            switch (member.Kind())
            {
            case SyntaxKind.MethodDeclaration:
                return(MethodMapper.MapMethod(member as MethodDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.EnumDeclaration:
                return(EnumMapper.MapEnum(member as EnumDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.EnumMemberDeclaration:
                return(EnumMapper.MapEnumMember(member as EnumMemberDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.InterfaceDeclaration:
                return(InterfaceMapper.MapInterface(member as InterfaceDeclarationSyntax, _control, _semanticModel, _tree));

            case SyntaxKind.FieldDeclaration:
                return(FieldMapper.MapField(member as FieldDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.PropertyDeclaration:
                return(PropertyMapper.MapProperty(member as PropertyDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.StructDeclaration:
                return(StructMapper.MapStruct(member as StructDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.ClassDeclaration:
                return(ClassMapper.MapClass(member as ClassDeclarationSyntax, _control, _semanticModel, _tree));

            case SyntaxKind.EventFieldDeclaration:
                return(DelegateEventMapper.MapEvent(member as EventFieldDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.DelegateDeclaration:
                return(DelegateEventMapper.MapDelegate(member as DelegateDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.NamespaceDeclaration:
                return(NamespaceMapper.MapNamespace(member as NamespaceDeclarationSyntax, _control, _semanticModel, _tree));

            case SyntaxKind.ConstructorDeclaration:
                return(MethodMapper.MapConstructor(member as ConstructorDeclarationSyntax, _control, _semanticModel));

            case SyntaxKind.IndexerDeclaration:
                return(IndexerMapper.MapIndexer(member as IndexerDeclarationSyntax, _control, _semanticModel));

            default:
                return(null);
            }
        }