Ejemplo n.º 1
0
        private IEnumerable <IRFunctionSignatureHelp> GetSignaturesAsync(RFunctionSignatureInfo signatureInfo, IRIntellisenseContext context, Action <IEnumerable <IRFunctionSignatureHelp> > callback)
        {
            var snapshot = context.EditorBuffer.CurrentSnapshot;
            var position = Math.Min(Math.Min(signatureInfo.FunctionCall.SignatureEnd, context.Position), snapshot.Length);

            var           applicableToSpan = GetApplicableSpan(signatureInfo, context);
            IFunctionInfo functionInfo     = null;
            string        packageName      = null;

            // First try user-defined function
            if (string.IsNullOrEmpty(signatureInfo.PackageName))
            {
                functionInfo = context.AstRoot.GetUserFunctionInfo(signatureInfo.FunctionName, position);
            }
            else
            {
                packageName = signatureInfo.PackageName;
            }

            if (functionInfo != null)
            {
                return(MakeSignatures(functionInfo, applicableToSpan, context));
            }

            if (callback != null)
            {
                // Get collection of function signatures from documentation (parsed RD file)
                _functionIndex.GetFunctionInfoAsync(signatureInfo.FunctionName, packageName, (fi, o) => {
                    InvokeSignaturesCallback(fi, applicableToSpan, context, callback);
                });
            }
            return(null);
        }
Ejemplo n.º 2
0
        private ITrackingTextRange GetApplicableSpan(RFunctionSignatureInfo signatureInfo, IRIntellisenseContext context)
        {
            var snapshot = context.EditorBuffer.CurrentSnapshot;
            var start    = signatureInfo.FunctionCall.OpenBrace.End;
            var end      = Math.Min(signatureInfo.FunctionCall.SignatureEnd, snapshot.Length);

            return(snapshot.CreateTrackingRange(TextRange.FromBounds(start, end)));
        }