コード例 #1
0
        private SignatureInformation ToSignatureInformation(IOverloadResult overload)
        {
            var si = new SignatureInformation();

            if (_clientCaps?.textDocument?.signatureHelp?.signatureInformation?._shortLabel ?? false)
            {
                si.label = overload.Name;
            }
            else
            {
                si.label = "{0}({1})".FormatInvariant(
                    overload.Name,
                    string.Join(", ", overload.Parameters.Select(FormatParameter))
                    );
            }

            si.documentation = string.IsNullOrEmpty(overload.Documentation) ? null : overload.Documentation;
            si.parameters    = overload.Parameters.MaybeEnumerate().Select(p => new ParameterInformation {
                label         = p.Name,
                documentation = string.IsNullOrEmpty(p.Documentation) ? null : p.Documentation,
                _type         = p.Type,
                _defaultValue = p.DefaultValue
            }).ToArray();

            var formatSetting = _clientCaps.textDocument?.signatureHelp?.signatureInformation?.documentationFormat;

            si.documentation = GetMarkupContent(si.documentation.value, formatSetting);
            foreach (var p in si.parameters)
            {
                p.documentation = GetMarkupContent(p.documentation.value, formatSetting);
            }

            si._returnTypes = (overload as IOverloadResult2)?.ReturnType.OrderBy(k => k).ToArray();
            return(si);
        }
コード例 #2
0
        private static SignatureInformation GetSignatureFromDoc(string doc)
        {
            var si             = new SignatureInformation();
            var firstLineBreak = doc.IndexOfAny(new[] { '\r', '\n' });

            si.label         = firstLineBreak > 0 ? doc.Substring(0, firstLineBreak) : doc;
            si.documentation = doc.Substring(si.label.Length).TrimStart();
            si.parameters    = GetParametersFromDoc(si.label);
            return(si);
        }
コード例 #3
0
        private SignatureInformation ToSignatureInformation(IOverloadResult overload)
        {
            var si = new SignatureInformation();

            si.parameters = overload.Parameters.MaybeEnumerate().Select(p => new ParameterInformation {
                label         = p.Name,
                documentation = string.IsNullOrEmpty(p.Documentation) ? null : p.Documentation,
                _type         = p.Type,
                _defaultValue = p.DefaultValue
            }).ToArray();

            si._returnTypes = (overload as IOverloadResult2)?.ReturnType.OrderBy(k => k).ToArray();

            if (_clientCaps?.textDocument?.signatureHelp?.signatureInformation?._shortLabel ?? false)
            {
                si.label = overload.Name;
            }
            else
            {
                var doc = overload.Documentation;
                // Some function contain signature in the documentation. Example: print.
                // We want to use that signature in VS Code since it contains all arguments.
                if (si.parameters.Length == 0 && !string.IsNullOrEmpty(doc) && doc.StartsWithOrdinal($"{overload.Name}("))
                {
                    return(GetSignatureFromDoc(doc));
                }
                si.label = "{0}({1})".FormatInvariant(
                    overload.Name,
                    string.Join(", ", overload.Parameters.Select(FormatParameter))
                    );
            }

            si.documentation = string.IsNullOrEmpty(overload.Documentation) ? null : overload.Documentation;
            var formatSetting = _clientCaps?.textDocument?.signatureHelp?.signatureInformation?.documentationFormat;

            si.documentation = GetMarkupContent(si.documentation.value, formatSetting);
            foreach (var p in si.parameters)
            {
                p.documentation = GetMarkupContent(p.documentation.value, formatSetting);
            }

            return(si);
        }