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); } }
protected override void OnSyntaxEditorIntelliPromptParameterInfoParameterIndexChanged(ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor, EventArgs e) { IntelliPromptParameterInfo pi = syntaxEditor.IntelliPrompt.ParameterInfo; if (UpdateParameterInfoText(pi)) { syntaxEditor.IntelliPrompt.ParameterInfo.MeasureAndResize(pi.Bounds.Location); } }
private bool UpdateParameterInfoText(IntelliPromptParameterInfo pi) { var functions = pi.Context as LuatValue[]; if (functions != null) { pi.Info[pi.SelectedIndex] = GetQuickInfoForFunctionCall(functions[pi.SelectedIndex], pi.ParameterIndex); } return(true); }
public void ParameterInfo() { EnsureBound(); IntelliPromptParameterInfo infoTip = _syntaxEditor.IntelliPrompt.ParameterInfo; if (infoTip.Visible) { HideParameterInfoPopup(); } else { ShowParameterInfoPopup(); } }
/// <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; } } }
private bool UpdateParameterInfoText(IntelliPromptParameterInfo pi) { var functions = pi.Context as LuatValue[]; if (functions != null) pi.Info[pi.SelectedIndex] = GetQuickInfoForFunctionCall(functions[pi.SelectedIndex], pi.ParameterIndex); return true; }
public ParameterInfoAcceptor(IntelliPromptParameterInfo infoTip, int parameterIndex) { _infoTip = infoTip; _parameterIndex = parameterIndex; }
/// <summary> /// Presents the parameter info prompt to the user /// </summary> /// <param name="syntaxEditor"></param> /// <returns></returns> private bool ShowIntelliPromptParameterInfoImmediate(ActiproSoftware.SyntaxEditor.SyntaxEditor syntaxEditor) { // Initialize the parameter info syntaxEditor.IntelliPrompt.ParameterInfo.Hide(); syntaxEditor.IntelliPrompt.ParameterInfo.Info.Clear(); syntaxEditor.IntelliPrompt.ParameterInfo.SelectedIndex = 0; // Get the compilation unit var cu = syntaxEditor.Document.SemanticParseData as CompilationUnit; if (cu == null) { return(false); } // Move back to the last open bracket int caret = syntaxEditor.Caret.Offset; TextStream stream = syntaxEditor.Document.GetTextStream(caret); stream.GoToPreviousTokenWithID(LuatTokenId.OpenParenthesis); // Find the argument list the caret is within var arguments = cu.FindNodeRecursive <ArgumentList>(stream.Offset); ArgumentList next = arguments; while (null != next && false == arguments.InsideBrackets(caret)) { arguments = next; next = next.FindAncestor <ArgumentList>(); } if (arguments == null) { return(false); } var call = arguments.ParentNode as FunctionCall; if (call == null) { throw new Exception("ArgumentList does not have FunctionCall as parent"); } // Configure the parameter info var textRange = new TextRange(arguments.ListTextRange.StartOffset, arguments.ListTextRange.EndOffset + 1); IntelliPromptParameterInfo pi = syntaxEditor.IntelliPrompt.ParameterInfo; pi.ValidTextRange = textRange; pi.CloseDelimiterCharacter = ')'; pi.UpdateParameterIndex(); pi.HideOnParentFormDeactivate = true; var functions = new List <LuatValue>(); foreach (var value in call.ResolvedFunctions) { if (false == value.Type is LuatTypeFunction) { continue; } functions.Merge(value); pi.Info.Add(GetQuickInfoForFunctionCall(value, pi.ParameterIndex)); } // Store the function types in the context pi.Context = functions.ToArray(); // Show the parameter info pi.Show(caret); return(false); }