public async void ShowParameterInfo(ParameterHintingResult provider, int overload, int _currentParam, int maxSize) { if (provider == null) { throw new ArgumentNullException("provider"); } int numParams = System.Math.Max(0, provider [overload].ParameterCount); var currentParam = System.Math.Min(_currentParam, numParams - 1); if (numParams > 0 && currentParam < 0) { currentParam = 0; } if (lastParam == currentParam && (currentTooltipInformation != null) && lastProvider == provider) { return; } lastProvider = provider; lastParam = currentParam; var parameterHintingData = (ParameterHintingData)provider [overload]; ResetTooltipInformation(); if (ext == null) { // ext == null means HideParameterInfo was called aka. we are not in valid context to display tooltip anymore lastParam = -2; return; } var ct = new CancellationTokenSource(); try { cancellationTokenSource = ct; currentTooltipInformation = await parameterHintingData.CreateTooltipInformation(ext.Editor, ext.DocumentContext, currentParam, false, ct.Token); } catch (Exception ex) { if (!(ex is TaskCanceledException)) { LoggingService.LogError("Error while getting tooltip information", ex); } return; } if (ct.IsCancellationRequested) { return; } cancellationTokenSource = null; Theme.NumPages = provider.Count; Theme.CurrentPage = overload; if (provider.Count > 1) { Theme.DrawPager = true; Theme.PagerVertical = true; } ShowTooltipInfo(); }
public override async Task <int> GuessBestMethodOverload(MonoDevelop.Ide.CodeCompletion.ParameterHintingResult provider, int currentOverload, CancellationToken token) { var analysisDocument = DocumentContext.AnalysisDocument; if (analysisDocument == null) { return(-1); } var result = await ICSharpCode.NRefactory6.CSharp.ParameterUtil.GetCurrentParameterIndex(analysisDocument, provider.ApplicableSpan.Start, Editor.CaretOffset); var cparam = result.ParameterIndex; var list = result.UsedNamespaceParameters; if (cparam > provider [currentOverload].ParameterCount && !provider [currentOverload].IsParameterListAllowed || !HasAllUsedParameters(provider [currentOverload], list)) { // Look for an overload which has more parameters int bestOverload = -1; int bestParamCount = int.MaxValue; for (int n = 0; n < provider.Count; n++) { int pc = provider [n].ParameterCount; if (pc < bestParamCount && pc >= cparam) { if (HasAllUsedParameters(provider [n], list)) { bestOverload = n; bestParamCount = pc; } } } if (bestOverload == -1) { for (int n = 0; n < provider.Count; n++) { if (provider [n].IsParameterListAllowed && HasAllUsedParameters(provider [n], list)) { bestOverload = n; break; } } } return(bestOverload); } return(-1); }
internal static void ShowWindow(CompletionTextEditorExtension ext, ICompletionWidget widget, CodeCompletionContext ctx, ParameterHintingResult provider) { if (provider.Count == 0) { return; } // There can be several method parameter lists open at the same time, so // they have to be queued. The last one of queue is the one being shown // in the information window. MethodData md = new MethodData(); md.MethodProvider = provider; md.CurrentOverload = 0; md.CompletionContext = ctx; currentMethodGroup = md; UpdateOverload(ext, widget, default(CancellationToken)); UpdateWindow(ext, widget); }