internal static async void UpdateCursorPosition(CompletionTextEditorExtension ext, ICompletionWidget widget) { updateSrc.Cancel(); updateSrc = new CancellationTokenSource(); var token = updateSrc.Token; // Called after the key has been processed by the editor if (currentMethodGroup == null) { return; } var actualMethodGroup = new MethodData(); actualMethodGroup.CompletionContext = widget.CurrentCodeCompletionContext; if (!currentMethodGroup.MethodProvider.ApplicableSpan.Contains(ext.Editor.CaretOffset)) { actualMethodGroup.MethodProvider = await ext.ParameterCompletionCommand(widget.CurrentCodeCompletionContext); if (actualMethodGroup.MethodProvider == null) { HideWindow(ext, widget); } } if (actualMethodGroup.MethodProvider != null && (currentMethodGroup == null || !actualMethodGroup.MethodProvider.Equals(currentMethodGroup.MethodProvider))) { currentMethodGroup = actualMethodGroup; } try { int pos = await ext.GetCurrentParameterIndex(currentMethodGroup.MethodProvider.ApplicableSpan.Start, token); if (pos == -1) { if (actualMethodGroup.MethodProvider == null) { currentMethodGroup = null; } else { pos = await ext.GetCurrentParameterIndex(actualMethodGroup.MethodProvider.ApplicableSpan.Start, token); currentMethodGroup = pos >= 0 ? actualMethodGroup : null; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload(ext, widget, token); // Refresh. UpdateWindow(ext, widget); } catch (OperationCanceledException) { } catch (Exception e) { LoggingService.LogError("Error while updating cursor position for parameter info window.", e); } }
public static void PostProcessKeyEvent(CompletionTextEditorExtension ext, ICompletionWidget widget, Gdk.Key key, Gdk.ModifierType modifier) { // Called after the key has been processed by the editor if (methods.Count == 0) { return; } for (int n = 0; n < methods.Count; n++) { // If the cursor is outside of any of the methods parameter list, discard the // information window for that method. MethodData md = methods [n]; int pos = ext.GetCurrentParameterIndex(md.MethodProvider.StartOffset); if (pos == -1) { methods.RemoveAt(n); n--; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload(ext, widget); // Refresh. UpdateWindow(ext, widget); }
internal static async void UpdateCursorPosition(CompletionTextEditorExtension ext, ICompletionWidget widget) { updateSrc.Cancel(); updateSrc = new CancellationTokenSource(); var token = updateSrc.Token; // Called after the key has been processed by the editor if (methods.Count == 0) { return; } for (int n = 0; n < methods.Count; n++) { // If the cursor is outside of any of the methods parameter list, discard the // information window for that method. MethodData md = methods [n]; int pos = await ext.GetCurrentParameterIndex(md.MethodProvider.StartOffset, token); if (pos == -1) { methods.RemoveAt(n); n--; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload(ext, widget); // Refresh. UpdateWindow(ext, widget); }
public override int GetCurrentParameterIndex(int startOffset) { if (!IsActiveExtension()) { return(-1); } return(completionTextEditorExtension.GetCurrentParameterIndex(startOffset)); }
public override Task <int> GetCurrentParameterIndex(int startOffset, System.Threading.CancellationToken token) { if (!IsActiveExtension()) { return(Task.FromResult(-1)); } return(completionTextEditorExtension.GetCurrentParameterIndex(startOffset, token)); }
internal static async void UpdateCursorPosition(CompletionTextEditorExtension ext, ICompletionWidget widget) { updateSrc.Cancel(); updateSrc = new CancellationTokenSource(); var token = updateSrc.Token; // Called after the key has been processed by the editor if (currentMethodGroup == null) { return; } var actualMethodGroup = new MethodData(); actualMethodGroup.CompletionContext = widget.CurrentCodeCompletionContext; actualMethodGroup.MethodProvider = await ext.ParameterCompletionCommand(widget.CurrentCodeCompletionContext); if (actualMethodGroup.MethodProvider != null && (currentMethodGroup == null || !actualMethodGroup.MethodProvider.Equals(currentMethodGroup.MethodProvider))) { currentMethodGroup = actualMethodGroup; } int pos = await ext.GetCurrentParameterIndex(currentMethodGroup.MethodProvider.StartOffset, token); if (pos == -1) { if (actualMethodGroup.MethodProvider == null) { currentMethodGroup = null; } else { pos = await ext.GetCurrentParameterIndex(actualMethodGroup.MethodProvider.StartOffset, token); currentMethodGroup = pos >= 0 ? actualMethodGroup : null; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload(ext, widget, token); // Refresh. UpdateWindow(ext, widget); }
static void UpdateOverload(CompletionTextEditorExtension ext, ICompletionWidget widget) { if (methods.Count == 0) { return; } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. MethodData md = methods [methods.Count - 1]; int cparam = ext.GetCurrentParameterIndex(md.MethodProvider.StartOffset); if (cparam > md.MethodProvider.GetParameterCount(md.CurrentOverload) && !md.MethodProvider.AllowParameterList(md.CurrentOverload)) { // Look for an overload which has more parameters int bestOverload = -1; int bestParamCount = int.MaxValue; for (int n = 0; n < md.MethodProvider.Count; n++) { int pc = md.MethodProvider.GetParameterCount(n); if (pc < bestParamCount && pc >= cparam) { bestOverload = n; bestParamCount = pc; } } if (bestOverload == -1) { for (int n = 0; n < md.MethodProvider.Count; n++) { if (md.MethodProvider.AllowParameterList(n)) { bestOverload = n; break; } } } if (bestOverload != -1) { md.CurrentOverload = bestOverload; } } }
internal static async void UpdateCursorPosition (CompletionTextEditorExtension ext, ICompletionWidget widget) { updateSrc.Cancel (); updateSrc = new CancellationTokenSource (); var token = updateSrc.Token; // Called after the key has been processed by the editor if (currentMethodGroup == null) return; var actualMethodGroup = new MethodData (); actualMethodGroup.CompletionContext = widget.CurrentCodeCompletionContext; actualMethodGroup.MethodProvider = await ext.ParameterCompletionCommand (widget.CurrentCodeCompletionContext); if (actualMethodGroup.MethodProvider != null && !actualMethodGroup.MethodProvider.Equals (currentMethodGroup.MethodProvider)) currentMethodGroup = actualMethodGroup; int pos = await ext.GetCurrentParameterIndex (currentMethodGroup.MethodProvider.StartOffset, token); if (pos == -1) { if (actualMethodGroup.MethodProvider == null) { currentMethodGroup = null; } else { pos = await ext.GetCurrentParameterIndex (actualMethodGroup.MethodProvider.StartOffset, token); currentMethodGroup = pos >= 0 ? actualMethodGroup : null; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload (ext, widget); // Refresh. UpdateWindow (ext, widget); }
internal static void UpdateCursorPosition (CompletionTextEditorExtension ext, ICompletionWidget widget) { // Called after the key has been processed by the editor if (methods.Count == 0) return; for (int n=0; n< methods.Count; n++) { // If the cursor is outside of any of the methods parameter list, discard the // information window for that method. MethodData md = methods [n]; int pos = ext.GetCurrentParameterIndex (md.MethodProvider.StartOffset); if (pos == -1) { methods.RemoveAt (n); n--; } } // If the user enters more parameters than the current overload has, // look for another overload with more parameters. UpdateOverload (ext, widget); // Refresh. UpdateWindow (ext, widget); }