当前位置: 首页>>代码示例>>C#>>正文


C# ISymbol.GetArity方法代码示例

本文整理汇总了C#中ISymbol.GetArity方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.GetArity方法的具体用法?C# ISymbol.GetArity怎么用?C# ISymbol.GetArity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISymbol的用法示例。


在下文中一共展示了ISymbol.GetArity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDisplayAndInsertionText

        protected override ValueTuple<string, string> GetDisplayAndInsertionText(ISymbol symbol, AbstractSyntaxContext context)
        {
            var insertionText = ItemRules.GetInsertionText(symbol, context);
            var displayText = symbol.GetArity() == 0 ? insertionText : string.Format("{0}<>", insertionText);

            return ValueTuple.Create(displayText, insertionText);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:SymbolCompletionProvider.cs

示例2: IsGenericTypeOrMethod

 private static bool IsGenericTypeOrMethod(ISymbol symbol)
 {
     return symbol.GetArity() > 0;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:4,代码来源:LessAndGreaterThanCompletionSession.cs

示例3: CreateItemAsync

        private async Task<CompletionItem> CreateItemAsync(
            Workspace workspace, SemanticModel semanticModel, int textChangeSpanPosition, ISymbol symbol, SyntaxToken token, CancellationToken cancellationToken)
        {
            int tokenPosition = token.SpanStart;
            string symbolText = string.Empty;

            if (symbol is INamespaceOrTypeSymbol && token.IsKind(SyntaxKind.DotToken))
            {
                symbolText = symbol.Name.EscapeIdentifier();

                if (symbol.GetArity() > 0)
                {
                    symbolText += "{";
                    symbolText += string.Join(", ", ((INamedTypeSymbol)symbol).TypeParameters);
                    symbolText += "}";
                }
            }
            else
            {
                symbolText = symbol.ToMinimalDisplayString(semanticModel, tokenPosition, CrefFormat);
                var parameters = symbol.GetParameters().Select(p =>
                    {
                        var displayName = p.Type.ToMinimalDisplayString(semanticModel, tokenPosition);

                        if (p.RefKind == RefKind.Out)
                        {
                            return "out " + displayName;
                        }

                        if (p.RefKind == RefKind.Ref)
                        {
                            return "ref " + displayName;
                        }

                        return displayName;
                    });

                var parameterList = !symbol.IsIndexer() ? string.Format("({0})", string.Join(", ", parameters))
                                                        : string.Format("[{0}]", string.Join(", ", parameters));
                symbolText += parameterList;
            }

            var insertionText = symbolText
                .Replace('<', '{')
                .Replace('>', '}')
                .Replace("()", "");

            var text = await semanticModel.SyntaxTree.GetTextAsync(cancellationToken).ConfigureAwait(false);
            return new CrefCompletionItem(
                workspace,
                completionProvider: this,
                displayText: insertionText,
                insertionText: insertionText,
                textSpan: GetTextChangeSpan(text, textChangeSpanPosition),
                descriptionFactory: CommonCompletionUtilities.CreateDescriptionFactory(workspace, semanticModel, tokenPosition, symbol),
                glyph: symbol.GetGlyph(),
                sortText: symbolText);
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:58,代码来源:CrefCompletionProvider.cs

示例4: GetIdForMemberAsync

        public static async Task<GraphNodeId> GetIdForMemberAsync(ISymbol member, Solution solution, CancellationToken cancellationToken)
        {
            var partials = new List<GraphNodeId>();

            partials.AddRange(await GetPartialsForNamespaceAndTypeAsync(member.ContainingType, true, solution, cancellationToken).ConfigureAwait(false));

            var parameters = member.GetParameters();
            if (parameters.Any() || member.GetArity() > 0)
            {
                var memberPartials = new List<GraphNodeId>();

                memberPartials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Name, member.MetadataName));

                if (member.GetArity() > 0)
                {
                    memberPartials.Add(GraphNodeId.GetPartial(CodeGraphNodeIdName.GenericParameterCountIdentifier, member.GetArity().ToString()));
                }

                if (parameters.Any())
                {
                    var parameterTypeIds = new List<GraphNodeId>();
                    foreach (var p in parameters)
                    {
                        var parameterIds = await GetPartialsForNamespaceAndTypeAsync(p.Type, true, solution, cancellationToken).ConfigureAwait(false);
                        var nodes = parameterIds.ToList();
                        if (p.IsRefOrOut())
                        {
                            nodes.Add(GraphNodeId.GetPartial(CodeGraphNodeIdName.ParamKind, ParamKind.Ref));
                        }

                        parameterTypeIds.Add(GraphNodeId.GetNested(nodes.ToArray()));
                    }

                    IMethodSymbol methodSymbol = member as IMethodSymbol;
                    if (methodSymbol != null && methodSymbol.MethodKind == MethodKind.Conversion)
                    {
                        // For explicit/implicit conversion operators, we need to include the return type in the method Id,
                        // because there can be several conversion operators with same parameters and only differ by return type.
                        // For example,
                        // 
                        //     public class Class1
                        //     {
                        //         public static explicit (explicit) operator int(Class1 c) { ... }
                        //         public static explicit (explicit) operator double(Class1 c) { ... }
                        //     }

                        var nodes = await GetPartialsForNamespaceAndTypeAsync(methodSymbol.ReturnType, true, solution, cancellationToken).ConfigureAwait(false);
                        List<GraphNodeId> returnTypePartial = nodes.ToList();
                        returnTypePartial.Add(GraphNodeId.GetPartial(CodeGraphNodeIdName.ParamKind, Microsoft.VisualStudio.GraphModel.CodeSchema.ParamKind.Return));

                        GraphNodeId returnCollection = GraphNodeId.GetNested(returnTypePartial.ToArray());
                        parameterTypeIds.Add(returnCollection);
                    }

                    memberPartials.Add(GraphNodeId.GetArray(
                                       CodeGraphNodeIdName.OverloadingParameters,
                                       parameterTypeIds.ToArray()));
                }

                partials.Add(GraphNodeId.GetPartial(
                            CodeGraphNodeIdName.Member,
                            MakeCollectionIfNecessary(false, memberPartials.ToArray())));
            }
            else
            {
                partials.Add(GraphNodeId.GetPartial(CodeGraphNodeIdName.Member, member.MetadataName));
            }

            return GraphNodeId.GetNested(partials.ToArray());
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:70,代码来源:GraphNodeIdCreation.cs

示例5: override

        protected override (string displayText, string insertionText) GetDisplayAndInsertionText(ISymbol symbol, SyntaxContext context)
        {
            var insertionText = GetInsertionText(symbol, context);
            var displayText = symbol.GetArity() == 0 ? insertionText : string.Format("{0}<>", insertionText);

            return (displayText, insertionText);
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:7,代码来源:SymbolCompletionProvider.cs


注:本文中的ISymbol.GetArity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。