Ejemplo n.º 1
0
        private ISignature CreateSignature(ISignatureHelpSession session,
                                           IFunctionInfo functionInfo, ISignatureInfo signatureInfo,
                                           ITrackingSpan span, AstRoot ast, int position)
        {
            SignatureHelp     sig       = new SignatureHelp(session, _textBuffer, functionInfo.Name, string.Empty, signatureInfo);
            List <IParameter> paramList = new List <IParameter>();

            // Locus points in the pretty printed signature (the one displayed in the tooltip)
            var    locusPoints     = new List <int>();
            string signatureString = signatureInfo.GetSignatureString(locusPoints);

            sig.Content          = signatureString;
            sig.ApplicableToSpan = span;

            sig.Documentation = functionInfo.Description?.Wrap(Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length));

            Debug.Assert(locusPoints.Count == signatureInfo.Arguments.Count + 1);
            for (int i = 0; i < signatureInfo.Arguments.Count; i++)
            {
                IArgumentInfo p = signatureInfo.Arguments[i];
                if (p != null)
                {
                    int locusStart  = locusPoints[i];
                    int locusLength = locusPoints[i + 1] - locusStart;

                    Debug.Assert(locusLength >= 0);
                    Span locus = new Span(locusStart, locusLength);

                    /// VS may end showing very long tooltip so we need to keep
                    /// description reasonably short: typically about
                    /// same length as the function signature.
                    paramList.Add(
                        new SignatureParameter(
                            p.Description.Wrap(
                                Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length)),
                            locus, locus, p.Name, sig));
                }
            }

            sig.Parameters = new ReadOnlyCollection <IParameter>(paramList);
            sig.ComputeCurrentParameter(ast, position);

            return(sig);
        }
Ejemplo n.º 2
0
        public static IRFunctionSignatureHelp Create(IRIntellisenseContext context, IFunctionInfo functionInfo, ISignatureInfo signatureInfo, ITrackingTextRange applicableSpan)
        {
            var sig       = new RFunctionSignatureHelp(context.Session, context.EditorBuffer, functionInfo.Name, string.Empty, signatureInfo);
            var paramList = new List <ISignatureParameterHelp>();

            // Locus points in the pretty printed signature (the one displayed in the tooltip)
            var locusPoints     = new List <int>();
            var signatureString = signatureInfo.GetSignatureString(functionInfo.Name, locusPoints);

            sig.Content           = signatureString;
            sig.ApplicableToRange = applicableSpan;

            sig.Documentation = functionInfo.Description?.Wrap(Math.Min(MaxSignatureLength, sig.Content.Length));

            Debug.Assert(locusPoints.Count == signatureInfo.Arguments.Count + 1);
            for (var i = 0; i < signatureInfo.Arguments.Count; i++)
            {
                var p = signatureInfo.Arguments[i];
                if (p != null)
                {
                    var locusStart  = locusPoints[i];
                    var locusLength = locusPoints[i + 1] - locusStart;

                    Debug.Assert(locusLength >= 0);
                    var locus = new TextRange(locusStart, locusLength);

                    // VS may end showing very long tooltip so we need to keep
                    // description reasonably short: typically about
                    // same length as the function signature.
                    var description = p.Description.Wrap(Math.Min(MaxSignatureLength, sig.Content.Length));
                    paramList.Add(new RSignatureParameterHelp(description, locus, p.Name, sig));
                }
            }

            sig.Parameters = new ReadOnlyCollection <ISignatureParameterHelp>(paramList);
            sig.ComputeCurrentParameter(context.AstRoot, context.Position);

            return(sig);
        }
Ejemplo n.º 3
0
        private ISignature CreateSignature(ISignatureHelpSession session,
                                       string functionName, IFunctionInfo functionInfo, ISignatureInfo signatureInfo,
                                       ITrackingSpan span, AstRoot ast, int position) {
            SignatureHelp sig = new SignatureHelp(session, _textBuffer, functionName, string.Empty, signatureInfo, _shell);
            List<IParameter> paramList = new List<IParameter>();

            // Locus points in the pretty printed signature (the one displayed in the tooltip)
            var locusPoints = new List<int>();
            string signatureString = signatureInfo.GetSignatureString(functionName, locusPoints);
            sig.Content = signatureString;
            sig.ApplicableToSpan = span;

            sig.Documentation = functionInfo.Description?.Wrap(Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length));

            Debug.Assert(locusPoints.Count == signatureInfo.Arguments.Count + 1);
            for (int i = 0; i < signatureInfo.Arguments.Count; i++) {
                IArgumentInfo p = signatureInfo.Arguments[i];
                if (p != null) {
                    int locusStart = locusPoints[i];
                    int locusLength = locusPoints[i + 1] - locusStart;

                    Debug.Assert(locusLength >= 0);
                    Span locus = new Span(locusStart, locusLength);

                    /// VS may end showing very long tooltip so we need to keep 
                    /// description reasonably short: typically about
                    /// same length as the function signature.
                    paramList.Add(
                        new SignatureParameter(
                            p.Description.Wrap(
                                Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length)),
                                locus, locus, p.Name, sig));
                }
            }

            sig.Parameters = new ReadOnlyCollection<IParameter>(paramList);
            sig.ComputeCurrentParameter(ast, position);

            return sig;
        }