public SignatureHelp GetSignatureHelp(DocPos caretPos)
        {
            // Get the active parameter.
            int activeParameter = -1;

            if (ParameterRanges != null)
            {
                // Loop through parameter ranges while activeParameter is -1.
                for (int i = 0; i < ParameterRanges.Length && activeParameter == -1; i++)
                {
                    // If the proved caret position is inside the parameter range, set it as the active parameter.
                    if (ParameterRanges[i] != null && ParameterRanges[i].IsInside(caretPos))
                    {
                        activeParameter = i;
                    }
                }
            }

            // Get the signature information.
            SignatureInformation[] overloads = new SignatureInformation[AllOverloads.Length];
            for (int i = 0; i < overloads.Length; i++)
            {
                // Get the parameter information for the signature.
                var parameters = new ParameterInformation[AllOverloads[i].Parameters.Length];

                // Convert parameters to parameter information.
                for (int p = 0; p < parameters.Length; p++)
                {
                    parameters[p] = new ParameterInformation()
                    {
                        // Get the label to show in the signature.
                        Label = AllOverloads[i].Parameters[p].GetLabel(false),
                        // Get the documentation.
                        Documentation = Extras.GetMarkupContent(AllOverloads[i].Parameters[p].Documentation)
                    }
                }
                ;

                // Create the signature information.
                overloads[i] = new SignatureInformation()
                {
                    Label         = AllOverloads[i].GetLabel(false),
                    Parameters    = parameters,
                    Documentation = AllOverloads[i].Documentation
                };
            }

            return(new SignatureHelp()
            {
                ActiveParameter = activeParameter,
                ActiveSignature = Array.IndexOf(AllOverloads, Overload),
                Signatures = overloads
            });
        }
    }
Exemple #2
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
            });
        }
    }
        public SignatureHelp GetSignatureHelp(DocPos caretPos)
        {
            // Get the active parameter.
            int activeParameter = -1;

            // Comma with no proceeding value.
            if (_extraneousParameterRange != null && (_extraneousParameterRange.Start + CallRange.End).IsInside(caretPos))
            {
                activeParameter = _providedParameterCount;
            }
            // Parameter
            else if (ParameterResults != null)
            {
                // Loop through parameter ranges while activeParameter is -1.
                for (int i = 0; i < ParameterResults.Length && activeParameter == -1; i++)
                {
                    // If the proved caret position is inside the parameter range, set it as the active parameter.
                    if (ParameterResults[i].ParameterRange != null && ParameterResults[i].ParameterRange.IsInside(caretPos))
                    {
                        activeParameter = i;
                    }
                }
            }

            // Get the signature information.
            SignatureInformation[] signatureInformations = new SignatureInformation[_matches.Length];
            int activeSignature = -1;

            for (int i = 0; i < signatureInformations.Length; i++)
            {
                var match    = _matches[i];
                var overload = match.Option;

                // If the chosen overload matches the overload being iterated upon, set the active signature.
                if (Overload == overload.Value)
                {
                    activeSignature = i;
                }

                // Get the parameter information for the signature.
                var parameters = new ParameterInformation[overload.Parameters.Length];

                // Convert parameters to parameter information.
                for (int p = 0; p < parameters.Length; p++)
                {
                    parameters[p] = new ParameterInformation()
                    {
                        // Get the label to show in the signature.
                        Label = overload.Parameters[p].GetLabel(_parseInfo.TranslateInfo, new AnonymousLabelInfo(match.TypeArgLinker)),
                        // Get the documentation.
                        Documentation = overload.Parameters[p].Documentation
                    }
                }
                ;

                // Create the signature information.
                signatureInformations[i] = new SignatureInformation()
                {
                    Label = overload.GetLabel(_parseInfo.TranslateInfo, new LabelInfo()
                    {
                        IncludeDocumentation  = false,
                        IncludeParameterNames = true,
                        IncludeParameterTypes = true,
                        IncludeReturnType     = true,
                        AnonymousLabelInfo    = new AnonymousLabelInfo(match.TypeArgLinker)
                    }),
                    Parameters    = parameters,
                    Documentation = overload.Documentation
                };
            }

            return(new SignatureHelp()
            {
                ActiveParameter = activeParameter,
                ActiveSignature = activeSignature,
                Signatures = signatureInformations
            });
        }
    }