コード例 #1
0
 private static SignatureHelpSymbolParameter InlineDelegateAnonymousTypes(
     SignatureHelpSymbolParameter parameter,
     SemanticModel semanticModel,
     int position,
     IStructuralTypeDisplayService structuralTypeDisplayService)
 {
     return(new SignatureHelpSymbolParameter(
                parameter.Name,
                parameter.IsOptional,
                parameter.DocumentationFactory,
                structuralTypeDisplayService.InlineDelegateAnonymousTypes(parameter.DisplayParts, semanticModel, position),
                structuralTypeDisplayService.InlineDelegateAnonymousTypes(parameter.PrefixDisplayParts, semanticModel, position),
                structuralTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SuffixDisplayParts, semanticModel, position),
                structuralTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SelectedDisplayParts, semanticModel, position)));
 }
コード例 #2
0
        protected static SignatureHelpItem CreateItemImpl(
            ISymbol orderSymbol,
            SemanticModel semanticModel,
            int position,
            IStructuralTypeDisplayService structuralTypeDisplayService,
            bool isVariadic,
            Func <CancellationToken, IEnumerable <TaggedText> >?documentationFactory,
            IList <SymbolDisplayPart> prefixParts,
            IList <SymbolDisplayPart> separatorParts,
            IList <SymbolDisplayPart> suffixParts,
            IList <SignatureHelpSymbolParameter> parameters,
            IList <SymbolDisplayPart>?descriptionParts)
        {
            prefixParts      = structuralTypeDisplayService.InlineDelegateAnonymousTypes(prefixParts, semanticModel, position);
            separatorParts   = structuralTypeDisplayService.InlineDelegateAnonymousTypes(separatorParts, semanticModel, position);
            suffixParts      = structuralTypeDisplayService.InlineDelegateAnonymousTypes(suffixParts, semanticModel, position);
            parameters       = parameters.Select(p => InlineDelegateAnonymousTypes(p, semanticModel, position, structuralTypeDisplayService)).ToList();
            descriptionParts = descriptionParts == null
                ? SpecializedCollections.EmptyList <SymbolDisplayPart>()
                : descriptionParts;

            var allParts = prefixParts.Concat(separatorParts)
                           .Concat(suffixParts)
                           .Concat(parameters.SelectMany(p => p.GetAllParts()))
                           .Concat(descriptionParts);

            var structuralTypes =
                from part in allParts
                where part.Symbol.IsNormalAnonymousType() || part.Symbol.IsTupleType()
                select(INamedTypeSymbol) part.Symbol !;

            var info = structuralTypeDisplayService.GetTypeDisplayInfo(
                orderSymbol, structuralTypes.ToImmutableArray(), semanticModel, position);

            if (info.TypesParts.Count > 0)
            {
                var anonymousTypeParts = new List <SymbolDisplayPart>
                {
                    new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, "\r\n\r\n")
                };

                anonymousTypeParts.AddRange(info.TypesParts);

                return(new SymbolKeySignatureHelpItem(
                           orderSymbol,
                           isVariadic,
                           documentationFactory,
                           info.ReplaceStructuralTypes(prefixParts, semanticModel, position).ToTaggedText(),
                           info.ReplaceStructuralTypes(separatorParts, semanticModel, position).ToTaggedText(),
                           info.ReplaceStructuralTypes(suffixParts, semanticModel, position).ToTaggedText(),
                           parameters.Select(p => ReplaceStructuralTypes(p, info, semanticModel, position)).Select(p => (SignatureHelpParameter)p),
                           anonymousTypeParts.ToTaggedText()));
            }

            return(new SymbolKeySignatureHelpItem(
                       orderSymbol,
                       isVariadic,
                       documentationFactory,
                       prefixParts.ToTaggedText(),
                       separatorParts.ToTaggedText(),
                       suffixParts.ToTaggedText(),
                       parameters.Select(p => (SignatureHelpParameter)p),
                       descriptionParts.ToTaggedText()));
        }