コード例 #1
0
        public static CodeItem MapMethod(MethodDeclarationSyntax member, CodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            CodeItem item;

            var statementsCodeItems = StatementMapper.MapStatement(member.Body, control, semanticModel);

            if (VisibilityHelper.ShouldBeVisible(CodeItemKindEnum.Switch) && statementsCodeItems.Any())
            {
                // Map method as item containing statements
                item = BaseMapper.MapBase <CodeClassItem>(member, member.Identifier, member.Modifiers, control, semanticModel);
                ((CodeClassItem)item).Members.AddRange(statementsCodeItems);
                ((CodeClassItem)item).BorderBrush = ColorHelper.ToBrush(Colors.DarkGray);
            }
            else
            {
                // Map method as single item
                item = BaseMapper.MapBase <CodeFunctionItem>(member, member.Identifier, member.Modifiers, control, semanticModel);
                ((CodeFunctionItem)item).Type       = TypeMapper.Map(member.ReturnType);
                ((CodeFunctionItem)item).Parameters = ParameterMapper.MapParameters(member.ParameterList);
                item.Tooltip = TooltipMapper.Map(item.Access, ((CodeFunctionItem)item).Type, item.Name, member.ParameterList);
            }

            item.Id      = IdMapper.MapId(item.FullName, member.ParameterList);
            item.Kind    = CodeItemKindEnum.Method;
            item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access);

            return(item);
        }
コード例 #2
0
        public static CodeItem MapConstructor(VisualBasicSyntax.ConstructorBlockSyntax member, CodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeFunctionItem>(member, member.SubNewStatement.NewKeyword, member.SubNewStatement.Modifiers, control, semanticModel);

            item.Parameters     = ParameterMapper.MapParameters(member.SubNewStatement.ParameterList, semanticModel);
            item.Tooltip        = TooltipMapper.Map(item.Access, item.Type, item.Name, member.SubNewStatement.ParameterList, semanticModel);
            item.Id             = IdMapper.MapId(member.SubNewStatement.NewKeyword, member.SubNewStatement.ParameterList, semanticModel);
            item.Kind           = CodeItemKindEnum.Constructor;
            item.Moniker        = IconMapper.MapMoniker(item.Kind, item.Access);
            item.OverlayMoniker = KnownMonikers.Add;

            return(item);
        }
コード例 #3
0
        public static CodeItem MapConstructor(ConstructorDeclarationSyntax member, ICodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

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

            item.Parameters     = ParameterMapper.MapParameters(member.ParameterList);
            item.Tooltip        = TooltipMapper.Map(item.Access, item.Type, item.Name, member.ParameterList);
            item.Id             = IdMapper.MapId(member.Identifier, member.ParameterList);
            item.Kind           = CodeItemKindEnum.Constructor;
            item.Moniker        = IconMapper.MapMoniker(item.Kind, item.Access);
            item.OverlayMoniker = KnownMonikers.Add;

            return(item);
        }
コード例 #4
0
        public static CodeItem MapMethod(VisualBasicSyntax.MethodBlockSyntax member, ICodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            CodeItem item;

            var statementsCodeItems = StatementMapper.MapStatement(member.Statements, control, semanticModel);

            if (VisibilityHelper.ShouldBeVisible(CodeItemKindEnum.Switch) && statementsCodeItems.Any())
            {
                // Map method as item containing statements
                item = BaseMapper.MapBase <CodeClassItem>(member, member.SubOrFunctionStatement.Identifier,
                                                          member.SubOrFunctionStatement.Modifiers, control, semanticModel);
                ((CodeClassItem)item).Members.AddRange(statementsCodeItems);
                ((CodeClassItem)item).BorderColor = Colors.DarkGray;
            }
            else
            {
                // Map method as single item
                item = BaseMapper.MapBase <CodeFunctionItem>(member, member.SubOrFunctionStatement.Identifier,
                                                             member.SubOrFunctionStatement.Modifiers, control, semanticModel);

                var symbol = SymbolHelper.GetSymbol <IMethodSymbol>(semanticModel, member);
                ((CodeFunctionItem)item).Type       = TypeMapper.Map(symbol?.ReturnType);
                ((CodeFunctionItem)item).Parameters = ParameterMapper.MapParameters(member.SubOrFunctionStatement.ParameterList, semanticModel);
                item.Tooltip = TooltipMapper.Map(item.Access, ((CodeFunctionItem)item).Type, item.Name,
                                                 member.SubOrFunctionStatement.ParameterList, semanticModel);
            }

            item.Id      = IdMapper.MapId(item.FullName, member.SubOrFunctionStatement.ParameterList, semanticModel);
            item.Kind    = CodeItemKindEnum.Method;
            item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access);

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

            return(item);
        }
コード例 #5
0
        public static CodeItem MapIndexer(IndexerDeclarationSyntax member, ICodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeFunctionItem>(member, member.ThisKeyword, member.Modifiers, control, semanticModel);

            item.Type       = TypeMapper.Map(member.Type);
            item.Parameters = ParameterMapper.MapParameters(member.ParameterList);
            item.Tooltip    = TooltipMapper.Map(item.Access, item.Type, item.Name, item.Parameters);
            item.Kind       = CodeItemKindEnum.Indexer;
            item.Moniker    = IconMapper.MapMoniker(item.Kind, item.Access);

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

            return(item);
        }
コード例 #6
0
 public static string MapId(string name, VisualBasicSyntax.ParameterListSyntax parameters, SemanticModel semanticModel)
 {
     return(name + ParameterMapper.MapParameters(parameters, semanticModel, true, false));
 }
コード例 #7
0
 public static string MapId(string name, ParameterListSyntax parameters)
 {
     return(name + ParameterMapper.MapParameters(parameters, true, false));
 }
コード例 #8
0
ファイル: TooltipMapper.cs プロジェクト: sunthx/CodeNav
 public static string Map(CodeItemAccessEnum access, string type, string name, ParameterListSyntax parameters)
 {
     return(Map(access, type, name, ParameterMapper.MapParameters(parameters, true)));
 }
コード例 #9
0
ファイル: TooltipMapper.cs プロジェクト: zhihuiweilai/CodeNav
 public static string Map(CodeItemAccessEnum access, string type, string name,
                          VisualBasicSyntax.ParameterListSyntax parameters, SemanticModel semanticModel)
 {
     return(Map(access, type, name, ParameterMapper.MapParameters(parameters, semanticModel, true)));
 }