Example #1
0
        private void AddParameterSignatureHelp(int index, SignatureHelpParameter param, Panel headerPanel, Panel contentPanel)
        {
            var isSelected = _signatureHelp.ArgumentIndex == index;

            headerPanel.Children.Add(ToTextBlock(param.DisplayParts, bold: isSelected));
            if (index != _item.Parameters.Length - 1)
            {
                headerPanel.Children.Add(ToTextBlock(_item.SeparatorDisplayParts));
            }
            if (isSelected)
            {
                var textBlock = param.DocumentationFactory(CancellationToken.None).ToTextBlock();
                if (textBlock != null && textBlock.Inlines.Count > 0)
                {
                    contentPanel.Children.Add(new StackPanel
                    {
                        Orientation = Orientation.Horizontal,
                        Children    =
                        {
                            new TextBlock {
                                Text = param.Name + ": ", FontWeight = FontWeights.Bold
                            },
                            textBlock
                        }
                    });
                }
            }
        }
Example #2
0
 public Parameter(Signature signature, SignatureHelpParameter parameter, Span locus, Span prettyPrintedLocus)
 {
     Signature          = signature ?? throw new ArgumentNullException(nameof(signature));
     Locus              = locus;
     PrettyPrintedLocus = prettyPrintedLocus;
     this.parameter     = parameter ?? throw new ArgumentNullException(nameof(parameter));
 }
 private static ParameterInformation ConvertParameter(SignatureHelpParameter parameter, CancellationToken cancellationToken)
 {
     return(new ParameterInformation
     {
         Label = parameter.Name,
         Documentation = parameter.DocumentationFactory(cancellationToken).GetFullText()
     });
 }
 private SignatureHelpParameter ReplaceAnonymousTypes(
     SignatureHelpParameter parameter,
     AnonymousTypeDisplayInfo info)
 {
     return(new SignatureHelpParameter(
                parameter.Name,
                parameter.IsOptional,
                parameter.DocumentationFactory,
                info.ReplaceAnonymousTypes(parameter.DisplayParts),
                info.ReplaceAnonymousTypes(parameter.SelectedDisplayParts)));
 }
Example #5
0
 public Parameter(
     Signature signature,
     SignatureHelpParameter parameter,
     string content,
     int index,
     int prettyPrintedIndex)
 {
     _parameter          = parameter;
     this.Signature      = signature;
     _contentLength      = content.Length;
     _index              = index;
     _prettyPrintedIndex = prettyPrintedIndex;
 }
 public Parameter(
     Signature signature,
     SignatureHelpParameter parameter,
     string content,
     int index,
     int prettyPrintedIndex)
 {
     _parameter = parameter;
     this.Signature = signature;
     _contentLength = content.Length;
     _index = index;
     _prettyPrintedIndex = prettyPrintedIndex;
 }
Example #7
0
        public Parameter(
            Signature signature,
            SignatureHelpParameter parameter,
            string content,
            int index,
            int prettyPrintedIndex)
        {
            this.Signature = signature;
            this.Name = parameter.Name;
            this.Documentation = parameter.Documentation.GetFullText();

            this.Locus = new Span(index, content.Length);
            this.PrettyPrintedLocus = new Span(prettyPrintedIndex, content.Length);
        }
Example #8
0
        public Parameter(
            Signature signature,
            SignatureHelpParameter parameter,
            string content,
            int index,
            int prettyPrintedIndex)
        {
            this.Signature     = signature;
            this.Name          = parameter.Name;
            this.Documentation = parameter.Documentation.GetFullText();

            this.Locus = new Span(index, content.Length);
            this.PrettyPrintedLocus = new Span(prettyPrintedIndex, content.Length);
        }
 private SignatureHelpParameter InlineDelegateAnonymousTypes(
     SignatureHelpParameter parameter,
     SemanticModel semanticModel,
     int position,
     ISymbolDisplayService symbolDisplayService,
     IAnonymousTypeDisplayService anonymousTypeDisplayService)
 {
     return(new SignatureHelpParameter(
                parameter.Name,
                parameter.IsOptional,
                parameter.DocumentationFactory,
                anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.DisplayParts, semanticModel, position, symbolDisplayService),
                anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.PrefixDisplayParts, semanticModel, position, symbolDisplayService),
                anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SuffixDisplayParts, semanticModel, position, symbolDisplayService),
                anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SelectedDisplayParts, semanticModel, position, symbolDisplayService)));
 }
 private SignatureHelpParameter InlineDelegateAnonymousTypes(
     SignatureHelpParameter parameter,
     SemanticModel semanticModel,
     int position,
     ISymbolDisplayService symbolDisplayService,
     IAnonymousTypeDisplayService anonymousTypeDisplayService)
 {
     return new SignatureHelpParameter(
         parameter.Name,
         parameter.IsOptional,
         parameter.DocumentationFactory,
         anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.DisplayParts, semanticModel, position, symbolDisplayService),
         anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.PrefixDisplayParts, semanticModel, position, symbolDisplayService),
         anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SuffixDisplayParts, semanticModel, position, symbolDisplayService),
         anonymousTypeDisplayService.InlineDelegateAnonymousTypes(parameter.SelectedDisplayParts, semanticModel, position, symbolDisplayService));
 }
 private SignatureHelpParameter ReplaceAnonymousTypes(
     SignatureHelpParameter parameter,
     AnonymousTypeDisplayInfo info)
 {
     return new SignatureHelpParameter(
         parameter.Name,
         parameter.IsOptional,
         parameter.DocumentationFactory,
         info.ReplaceAnonymousTypes(parameter.DisplayParts),
         info.ReplaceAnonymousTypes(parameter.SelectedDisplayParts));
 }
Example #12
0
    string _FormatHtml(int iSel, bool userSelected)
    {
        _data.iSelected = iSel;
        if (userSelected)
        {
            _data.iUserSelected = iSel;
        }

        var     r           = _data.r;
        ISymbol currentItem = null;
        SignatureHelpParameter currentParameter = null;
        var b = new StringBuilder("<body>");

        //AOutput.Clear();
        for (int i = 0; i < r.Items.Count; i++)
        {
            var sh = r.Items[i];
            if (sh is AbstractSignatureHelpProvider.SymbolKeySignatureHelpItem kk)
            {
                var sym = kk.Symbol;
                using var li = new CiHtml.HtmlListItem(b, i == iSel);
                if (i != iSel)
                {
                    b.AppendFormat("<a href='^{0}'>", i);
                }
                else
                {
                    currentItem = sym;
                }
#if false
                CiHtml.TaggedPartsToHtml(b, sh.PrefixDisplayParts);                 //works, but formats not as I like (too much garbage). Has bugs with tuples.
#else
                //if(nt != null) {
                //	AOutput.Write(1, nt.IsGenericType, nt.IsTupleType, nt.IsUnboundGenericType, nt.Arity, nt.CanBeReferencedByName);
                //	AOutput.Write(2, nt.IsAnonymousType, nt.IsDefinition, nt.IsImplicitlyDeclared, nt.Kind, nt.TypeKind);
                //	AOutput.Write(3, nt.MemberNames);
                //	AOutput.Write(4, nt.Name, nt.MetadataName, nt.OriginalDefinition, nt.TupleUnderlyingType);
                //	AOutput.Write("TypeParameters:");
                //	AOutput.Write(nt.TypeParameters);
                //	AOutput.Write("TypeArguments:");
                //	AOutput.Write(nt.TypeArguments);
                //	AOutput.Write("TupleElements:");
                //	try { var te = nt.TupleElements; if(!te.IsDefault) AOutput.Write(te); } catch(Exception e1) { AOutput.Write(e1.ToStringWithoutStack()); }
                //	AOutput.Write("---");
                //}

                int isTuple = 0;                 //1 ValueTuple<...>, 2 (...)
                var nt      = sym as INamedTypeSymbol;
                if (nt != null && nt.IsTupleType)
                {
                    isTuple = nt.IsDefinition ? 1 : 2;
                }

                if (isTuple == 1)
                {
                    b.Append("ValueTuple");                              //SymbolWithoutParametersToHtml formats incorrectly
                }
                else if (isTuple == 0)
                {
                    CiHtml.SymbolWithoutParametersToHtml(b, sym);
                }
                string b1 = "(", b2 = ")";
                if (nt != null)
                {
                    if (nt.IsGenericType && isTuple != 2)
                    {
                        b1 = "&lt;"; b2 = "&gt;";
                    }
                }
                else if (sym is IPropertySymbol)
                {
                    b1 = "["; b2 = "]";
                }
                b.Append(b1);
#endif
                int iArg = r.ArgumentIndex, lastParam = sh.Parameters.Length - 1;
                int selParam = iArg <= lastParam ? iArg : (sh.IsVariadic ? lastParam : -1);
                if (!r.ArgumentName.NE())
                {
                    var pa = sh.Parameters;
                    for (int pi = 0; pi < pa.Length; pi++)
                    {
                        if (pa[pi].Name == r.ArgumentName)
                        {
                            selParam = pi; break;
                        }
                    }
                }
                CiHtml.ParametersToHtml(b, sym, selParam, sh);
                //CiHtml.ParametersToHtml(b, sh, selParam); //works, but formats not as I like (too much garbage)
#if false
                CiHtml.TaggedPartsToHtml(b, sh.SuffixDisplayParts);
#else
                b.Append(b2);
#endif
                if (i != iSel)
                {
                    b.Append("</a>");
                }
                else if (selParam >= 0)
                {
                    currentParameter = sh.Parameters[selParam];
                }
            }
            else
            {
                ADebug.Print(sh);
            }
        }

        if (currentItem != null)
        {
            var    tt        = r.Items[iSel].DocumentationFactory?.Invoke(default);
Example #13
0
    System.Windows.Documents.Section _FormatText(int iSel, bool userSelected)
    {
        _data.iSelected = iSel;
        if (userSelected)
        {
            _data.iUserSelected = iSel;
        }

        var     r           = _data.r;
        ISymbol currentItem = null;
        SignatureHelpParameter currentParameter = null;
        var x = new CiText();

        //print.clear();
        for (int i = 0; i < r.Items.Count; i++)
        {
            var sh = r.Items[i];
            if (sh is AbstractSignatureHelpProvider.SymbolKeySignatureHelpItem kk)
            {
                var sym = kk.Symbol;
                if (i == iSel)
                {
                    currentItem = sym;
                }
                x.StartOverload(i == iSel, i);
#if false
                x.AppendTaggedParts(sh.PrefixDisplayParts);                 //works, but formats not as I like (too much garbage). Has bugs with tuples.
#else
                //if(nt != null) {
                //	print.it(1, nt.IsGenericType, nt.IsTupleType, nt.IsUnboundGenericType, nt.Arity, nt.CanBeReferencedByName);
                //	print.it(2, nt.IsAnonymousType, nt.IsDefinition, nt.IsImplicitlyDeclared, nt.Kind, nt.TypeKind);
                //	print.it(3, nt.MemberNames);
                //	print.it(4, nt.Name, nt.MetadataName, nt.OriginalDefinition, nt.TupleUnderlyingType);
                //	print.it("TypeParameters:");
                //	print.it(nt.TypeParameters);
                //	print.it("TypeArguments:");
                //	print.it(nt.TypeArguments);
                //	print.it("TupleElements:");
                //	try { var te = nt.TupleElements; if(!te.IsDefault) print.it(te); } catch(Exception e1) { print.it(e1.ToStringWithoutStack()); }
                //	print.it("---");
                //}

                int isTuple = 0;                 //1 ValueTuple<...>, 2 (...)
                var nt      = sym as INamedTypeSymbol;
                if (nt != null && nt.IsTupleType)
                {
                    isTuple = nt.IsDefinition ? 1 : 2;
                }

                if (isTuple == 1)
                {
                    x.Append("ValueTuple");                               //AppendSymbolWithoutParameters formats incorrectly
                }
                else if (isTuple == 0)
                {
                    x.AppendSymbolWithoutParameters(sym);
                }
                string b1 = "(", b2 = ")";
                if (nt != null)
                {
                    if (nt.IsGenericType && isTuple != 2)
                    {
                        b1 = "<"; b2 = ">";
                    }
                }
                else if (sym is IPropertySymbol)
                {
                    b1 = "["; b2 = "]";
                }
                x.Append(b1);
#endif
                int iArg = r.ArgumentIndex, lastParam = sh.Parameters.Length - 1;
                int selParam = iArg <= lastParam ? iArg : (sh.IsVariadic ? lastParam : -1);
                if (!r.ArgumentName.NE())
                {
                    var pa = sh.Parameters;
                    for (int pi = 0; pi < pa.Length; pi++)
                    {
                        if (pa[pi].Name == r.ArgumentName)
                        {
                            selParam = pi; break;
                        }
                    }
                }
                x.AppendParameters(sym, selParam, sh);
                //x.AppendParameters(sh, selParam); //works, but formats not as I like (too much garbage)
#if false
                x.AppendTaggedParts(sh.SuffixDisplayParts);
#else
                x.Append(b2);
#endif
                if (i == iSel && selParam >= 0)
                {
                    currentParameter = sh.Parameters[selParam];
                }
                x.EndOverload(i == iSel);
            }
            else
            {
                Debug_.Print(sh);
            }
        }

        if (currentItem != null)
        {
            var    tt        = r.Items[iSel].DocumentationFactory?.Invoke(default);