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


C# ISymbol.ToDisplayParts方法代码示例

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


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

示例1: ChangeSignatureDialogViewModel

        internal ChangeSignatureDialogViewModel(INotificationService notificationService, ParameterConfiguration parameters, ISymbol symbol, ClassificationTypeMap classificationTypeMap)
        {
            _originalParameterConfiguration = parameters;
            _notificationService = notificationService;
            _classificationTypeMap = classificationTypeMap;

            int startingSelectedIndex = 0;

            if (parameters.ThisParameter != null)
            {
                startingSelectedIndex++;

                _thisParameter = new ParameterViewModel(this, parameters.ThisParameter);
                _disabledParameters.Add(parameters.ThisParameter);
            }

            if (parameters.ParamsParameter != null)
            {
                _paramsParameter = new ParameterViewModel(this, parameters.ParamsParameter);
            }

            _symbol = symbol;
            _declarationParts = symbol.ToDisplayParts(s_symbolDeclarationDisplayFormat);

            _parameterGroup1 = parameters.ParametersWithoutDefaultValues.Select(p => new ParameterViewModel(this, p)).ToList();
            _parameterGroup2 = parameters.RemainingEditableParameters.Select(p => new ParameterViewModel(this, p)).ToList();
            this.SelectedIndex = startingSelectedIndex;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:28,代码来源:ChangeSignatureDialogViewModel.cs

示例2: ChangeSignatureDialogViewModel

        internal ChangeSignatureDialogViewModel(ParameterConfiguration parameters, ISymbol symbol)
        {
            _originalParameterConfiguration = parameters;

            int startingSelectedIndex = 0;

            if (parameters.ThisParameter != null)
            {
                startingSelectedIndex++;

                _thisParameter = new ParameterViewModel(this, parameters.ThisParameter);
                _disabledParameters.Add(parameters.ThisParameter);
            }

            if (parameters.ParamsParameter != null)
            {
                _paramsParameter = new ParameterViewModel(this, parameters.ParamsParameter);
            }

            _declarationParts = symbol.ToDisplayParts(_symbolDeclarationDisplayFormat);

            _parameterGroup1 = parameters.ParametersWithoutDefaultValues.Select(p => new ParameterViewModel(this, p)).ToList();
            _parameterGroup2 = parameters.RemainingEditableParameters.Select(p => new ParameterViewModel(this, p)).ToList();
            SelectedIndex = startingSelectedIndex;
        }
开发者ID:mjheitland,项目名称:TableTweaker,代码行数:25,代码来源:ChangeSignatureDialogViewModel.cs

示例3: Generate

        public string Generate(ISymbol symbol)
        {
            _sb = new StringBuilder();
            _format = SymbolDisplayFormat.MinimallyQualifiedFormat;
            _format = _format.WithMemberOptions(_format.MemberOptions
                                                ^ SymbolDisplayMemberOptions.IncludeContainingType
                                                ^ SymbolDisplayMemberOptions.IncludeType);

            if (IsConstructor(symbol))
            {
                // only the containing type contains the type parameters
                var parts = symbol.ContainingType.ToDisplayParts(_format);
                RenderDisplayParts(symbol, parts);
                parts = symbol.ToDisplayParts(_format);
                RenderParameters(symbol as IMethodSymbol);
            }
            else
            {
                var symbolKind = symbol.Kind;
                if (symbol.Kind == SymbolKind.Method)
                {
                    RenderMethodSymbol(symbol as IMethodSymbol);
                }
                else if (symbol.Kind == SymbolKind.Event ||
                         symbol.Kind == SymbolKind.Local ||
                         symbol.Kind == SymbolKind.Parameter)
                {
                    _sb.Append(symbol.Name);
                }
                else
                {
                    var parts = symbol.ToDisplayParts(_format);
                    RenderDisplayParts(symbol, parts);
                }
            }

            if (IncludeMarkers)
            {
                _sb.Append("$0");
            }

            return _sb.ToString();
        }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:43,代码来源:SnippetGenerator.cs

示例4: TryAppendSymbol

            public bool TryAppendSymbol(ISymbol symbol)
            {
                if (symbol == null)
                {
                    return false;
                }

                var format = Format;
                if (symbol.IsConstructor())
                {
                    format = format.WithMemberOptions(SymbolDisplayMemberOptions.IncludeParameters | SymbolDisplayMemberOptions.IncludeExplicitInterface);
                }

                var parts = SemanticModel != null
                    ? symbol.ToMinimalDisplayParts(SemanticModel, Position, format)
                    : symbol.ToDisplayParts(format);

                AppendParts(parts);

                return true;
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:21,代码来源:AbstractDocumentationCommentFormattingService.cs

示例5: FullyQualifyIdentifierName

            private ExpressionSyntax FullyQualifyIdentifierName(
                ISymbol symbol,
                ExpressionSyntax rewrittenNode,
                ExpressionSyntax originalNode,
                bool replaceNode,
                bool isInsideCref,
                bool omitLeftHandSide)
            {
                Debug.Assert(!replaceNode || rewrittenNode.Kind() == SyntaxKind.IdentifierName);

                //// TODO: use and expand Generate*Syntax(isymbol) to not depend on symbol display any more.
                //// See GenerateExpressionSyntax();

                var result = rewrittenNode;

                // only if this symbol has a containing type or namespace there is work for us to do.
                if (replaceNode || symbol.ContainingType != null || symbol.ContainingNamespace != null)
                {
                    ImmutableArray<SymbolDisplayPart> displayParts;

                    ExpressionSyntax left = null;

                    // we either need to create an AliasQualifiedName if the symbol is directly contained in the global namespace,
                    // otherwise it a QualifiedName.
                    if (!replaceNode && symbol.ContainingType == null && symbol.ContainingNamespace.IsGlobalNamespace)
                    {
                        return rewrittenNode.CopyAnnotationsTo(
                            SyntaxFactory.AliasQualifiedName(
                                SyntaxFactory.IdentifierName(SyntaxFactory.Token(SyntaxKind.GlobalKeyword)),
                                (SimpleNameSyntax)rewrittenNode.WithLeadingTrivia(null))
                                    .WithLeadingTrivia(rewrittenNode.GetLeadingTrivia()));
                    }

                    displayParts = replaceNode
                        ? symbol.ToDisplayParts(s_typeNameFormatWithGenerics)
                        : (symbol.ContainingType ?? (ISymbol)symbol.ContainingNamespace).ToDisplayParts(s_typeNameFormatWithGenerics);

                    rewrittenNode = TryAddTypeArgumentToIdentifierName(rewrittenNode, symbol);

                    // Replaces the '<' token with the '{' token since we are inside crefs
                    rewrittenNode = TryReplaceAngleBracesWithCurlyBraces(rewrittenNode, isInsideCref);
                    result = rewrittenNode;

                    if (!omitLeftHandSide)
                    {
                        left = SyntaxFactory.ParseTypeName(displayParts.ToDisplayString());

                        // Replaces the '<' token with the '{' token since we are inside crefs
                        left = TryReplaceAngleBracesWithCurlyBraces(left, isInsideCref);

                        if (replaceNode)
                        {
                            return left
                                .WithLeadingTrivia(rewrittenNode.GetLeadingTrivia())
                                .WithTrailingTrivia(rewrittenNode.GetTrailingTrivia());
                        }

                        // now create syntax for the combination of left and right syntax, or a simple replacement in case of an identifier
                        var parent = originalNode.Parent;
                        var leadingTrivia = rewrittenNode.GetLeadingTrivia();
                        rewrittenNode = rewrittenNode.WithLeadingTrivia(null);

                        switch (parent.Kind())
                        {
                            case SyntaxKind.QualifiedName:
                                var qualifiedParent = (QualifiedNameSyntax)parent;

                                result = rewrittenNode.CopyAnnotationsTo(
                                    SyntaxFactory.QualifiedName(
                                        (NameSyntax)left,
                                        (SimpleNameSyntax)rewrittenNode));

                                break;

                            case SyntaxKind.SimpleMemberAccessExpression:
                                var memberAccessParent = (MemberAccessExpressionSyntax)parent;

                                result = rewrittenNode.CopyAnnotationsTo(
                                    SyntaxFactory.MemberAccessExpression(
                                        SyntaxKind.SimpleMemberAccessExpression,
                                        left,
                                        (SimpleNameSyntax)rewrittenNode));

                                break;

                            default:
                                Debug.Assert(rewrittenNode is SimpleNameSyntax);

                                if (SyntaxFacts.IsInNamespaceOrTypeContext(originalNode))
                                {
                                    var right = (SimpleNameSyntax)rewrittenNode;
                                    result = rewrittenNode.CopyAnnotationsTo(SyntaxFactory.QualifiedName((NameSyntax)left, right.WithAdditionalAnnotations(Simplifier.SpecialTypeAnnotation)));
                                }
                                else if (originalNode.Parent is CrefSyntax)
                                {
                                    var right = (SimpleNameSyntax)rewrittenNode;
                                    result = rewrittenNode.CopyAnnotationsTo(SyntaxFactory.QualifiedName((NameSyntax)left, right));
                                }
                                else
                                {
//.........这里部分代码省略.........
开发者ID:RoryVL,项目名称:roslyn,代码行数:101,代码来源:CSharpSimplificationService.Expander.cs

示例6: GetString

 private static string GetString(ISymbol symbol)
 {
     if (symbol.IsAnonymousType())
     {
         return symbol.ToDisplayParts(s_metadataSymbolDisplayFormat)
             .WhereAsArray(p => p.Kind != SymbolDisplayPartKind.PropertyName && p.Kind != SymbolDisplayPartKind.FieldName)
             .ToDisplayString();
     }
     else
     {
         return symbol.ToDisplayString(s_metadataSymbolDisplayFormat);
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:13,代码来源:ConflictResolver.cs

示例7: VisitSymbol

            void VisitSymbol(SyntaxToken token, ISymbol symbol)
            {
                JObject data = new JObject(
                    new JProperty("data-symbol", new JValue(LocStr(token.GetLocation())))
                );

                var parts = symbol.ToDisplayParts(new SymbolDisplayFormat());
                var part = parts.SingleOrDefault(p => p.Symbol == symbol);
                if (part.Symbol != null)
                {
                    string className = part.Kind.ToString();
                    className = capital.Replace(className, "$1-$2").ToLower();

                    Mark(token, className, data);
                }

                //SymbolDisplayPartKind kind = SymbolDisplayPartKind.Text;
                //if (symbol is IAssemblySymbol)
                //    kind = SymbolDisplayPartKind.AssemblyName;
                //else if (symbol is IModuleSymbol)
                //    kind = SymbolDisplayPartKind.ModuleName;
                //else if (symbol is INamespaceSymbol)
                //    kind = ((INamespaceSymbol)symbol).IsGlobalNamespace ? SymbolDisplayPartKind.Keyword : SymbolDisplayPartKind.NamespaceName;
                //else if (symbol is ILocalSymbol)
                //    kind = SymbolDisplayPartKind.LocalName;
                //else if (symbol is IRangeVariableSymbol)
                //    kind = SymbolDisplayPartKind.RangeVariableName;
                //else if (symbol is ILabelSymbol)
                //    kind = SymbolDisplayPartKind.LabelName;
                //else if (symbol is IAliasSymbol)
                //    kind = SymbolDisplayPartKind.AliasName;
                //else if (symbol is INamedTypeSymbol)
                //    kind = SymbolDisplayPartKind.ClassName;
            }
开发者ID:Runt-Editor,项目名称:Runt,代码行数:34,代码来源:Highlighter.cs


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