コード例 #1
0
        private void ShowParameterInfoPopup()
        {
            _parameterInfoLocation = CurrentLocation;

            _evaluatable.Text = _syntaxEditor.Text;

            IntelliPromptParameterInfo infoTip = _syntaxEditor.IntelliPrompt.ParameterInfo;
            int lastSelectedFunction           = infoTip.SelectedIndex;

            infoTip.Info.Clear();

            try
            {
                ICodeAssistanceContextProvider codeAssistanceContextProvider = _evaluatable.GetCodeAssistanceContextProvider();
                IParameterInfoContext          parameterInfoContext          = codeAssistanceContextProvider.ProvideParameterInfoContext(CurrentLocation);
                ParameterInfoAcceptor          acceptor = new ParameterInfoAcceptor(infoTip, parameterInfoContext.ParameterIndex);
                parameterInfoContext.Enumerate(acceptor);

                if (infoTip.Info.Count == 0)
                {
                    infoTip.Hide();
                }
                else
                {
                    infoTip.SelectedIndex = lastSelectedFunction;
                    infoTip.Show(_syntaxEditor.Caret.Offset);
                }
            }
            catch (NQueryException ex)
            {
                ShowErrorQuickInfo(ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// Occurs after a <see cref="Trigger"/> is activated
        /// for a <see cref="SyntaxEditor"/> that has a <see cref="Document"/> using this language.
        /// </summary>
        /// <param name="syntaxEditor">The <see cref="SyntaxEditor"/> that will raise the event.</param>
        /// <param name="e">An <c>TriggerEventArgs</c> that contains the event data.</param>
        protected override void OnSyntaxEditorTriggerActivated(SyntaxEditor syntaxEditor, TriggerEventArgs e)
        {
            switch (e.Trigger.Key)
            {
            case "MemberListTrigger":
            {
                // Hide parameter info
                syntaxEditor.IntelliPrompt.ParameterInfo.Hide();

                // Create an intermediate member list
                List <IntelliPromptMemberListItem> memberList = new List <IntelliPromptMemberListItem>();

                // Retrieve the namespace in front of the caret
                TextStream scriptStream = syntaxEditor.Document.GetTextStream(syntaxEditor.Caret.Offset);
                Namespace  ns           = GetNamespace(scriptStream, syntaxEditor.Document);

                // Set the image list
                syntaxEditor.IntelliPrompt.MemberList.ImageList = SyntaxEditor.ReflectionImageList;

                // Add items to the intermediate list
                if (ns != null)
                {
                    int imageIndex;

                    imageIndex = (int)ActiproSoftware.Products.SyntaxEditor.IconResource.PublicMethod;
                    foreach (Function f in ns.Functions)
                    {
                        memberList.Add(new IntelliPromptMemberListItem(f.Name, imageIndex, GetFunctionDescription(f, -1)));
                    }

                    imageIndex = (int)ActiproSoftware.Products.SyntaxEditor.IconResource.PublicField;
                    foreach (Global g in ns.Globals)
                    {
                        memberList.Add(new IntelliPromptMemberListItem(g.Name, imageIndex, GetGlobalDescription(g)));
                    }

                    imageIndex = (int)ActiproSoftware.Products.SyntaxEditor.IconResource.Namespace;
                    foreach (Namespace n in ns.Namespaces)
                    {
                        memberList.Add(new IntelliPromptMemberListItem(n.Name, imageIndex));
                    }
                }

                syntaxEditor.IntelliPrompt.MemberList.Clear();

                // Commit and show the list
                if (memberList.Count > 0)
                {
                    // Add all member list items at once for better performance
                    syntaxEditor.IntelliPrompt.MemberList.AddRange(memberList.ToArray());
                    syntaxEditor.IntelliPrompt.MemberList.Show();
                }
                break;
            }

            case "OpenParameterInfoTrigger":
            {
                IntelliPromptParameterInfo paramInfo = syntaxEditor.IntelliPrompt.ParameterInfo;
                paramInfo.Info.Clear();

                TextStream scriptStream = syntaxEditor.Document.GetTextStream(syntaxEditor.Caret.Offset);
                Function   f            = GetFunction(scriptStream, syntaxEditor.Document);
                if (f == null)
                {
                    paramInfo.Hide();
                    break;
                }

                for (int i = 0; i < f.Overloads.Length; i++)
                {
                    paramInfo.Info.Add(GetFunctionDescription(f, i));
                }

                paramInfo.Show(syntaxEditor.Caret.Offset);
                break;
            }

            case "CloseParameterInfoTrigger":
            {
                IntelliPromptParameterInfo paramInfo = syntaxEditor.IntelliPrompt.ParameterInfo;
                paramInfo.Info.Clear();

                TextStream scriptStream = syntaxEditor.Document.GetTextStream(syntaxEditor.Caret.Offset);
                Function   f            = GetFunction(scriptStream, syntaxEditor.Document);
                if (f == null)
                {
                    paramInfo.Hide();
                    break;
                }

                for (int i = 0; i < f.Overloads.Length; i++)
                {
                    paramInfo.Info.Add(GetFunctionDescription(f, i));
                }

                paramInfo.Show(syntaxEditor.Caret.Offset);
                break;
            }
            }
        }