Example #1
0
        public SignatureHelp GetSignatureHelp(Pos caretPos)
        {
            int activeParameter = -1;

            if (ParameterRanges != null)
            {
                for (int i = 0; i < ParameterRanges.Length && activeParameter == -1; i++)
                {
                    if (ParameterRanges[i] != null && ParameterRanges[i].IsInside(caretPos))
                    {
                        activeParameter = i;
                    }
                }
            }

            SignatureInformation[] overloads = new SignatureInformation[CurrentOptions.Count];
            for (int i = 0; i < overloads.Length; i++)
            {
                var parameters = new ParameterInformation[CurrentOptions[i].Parameters.Length];
                for (int p = 0; p < parameters.Length; p++)
                {
                    parameters[p] = new ParameterInformation()
                    {
                        Label         = CurrentOptions[i].Parameters[p].GetLabel(false),
                        Documentation = new StringOrMarkupContent(new MarkupContent()
                        {
                            Kind  = MarkupKind.Markdown,
                            Value = CurrentOptions[i].Parameters[p].Documentation
                        })
                    }
                }
                ;

                overloads[i] = new SignatureInformation()
                {
                    Label         = CurrentOptions[i].GetLabel(false),
                    Parameters    = parameters,
                    Documentation = CurrentOptions[i].Documentation
                };
            }

            return(new SignatureHelp()
            {
                ActiveParameter = activeParameter,
                ActiveSignature = CurrentOptions.IndexOf(Overload),
                Signatures = overloads
            });
        }
    }