private async Task <List <AnalysisVariable> > GetKeywordParameters(string expr, string originalName) { List <AnalysisVariable> paramVars = new List <AnalysisVariable>(); if (expr.IndexOf('.') == -1) { // let's check if we'r re-naming a keyword argument... ITrackingSpan span = _view.GetCaretSpan(); var sigs = await _uiThread.InvokeTask(() => _serviceProvider.GetPythonToolsService().GetSignaturesAsync(_view, _view.TextBuffer.CurrentSnapshot, span)) .ConfigureAwait(false); foreach (var sig in sigs.Signatures) { PythonSignature overloadRes = sig as PythonSignature; if (overloadRes != null) { foreach (PythonParameter param in overloadRes.Parameters) { if (param.Name == originalName && param.Variables != null) { paramVars.AddRange(param.Variables); } } } } } return(paramVars); }
private void Backspace() { if (_sigHelpSession != null) { SnapshotPoint?caretPoint = GetCaretPoint(); if (caretPoint != null && caretPoint.Value.Position != 0) { string deleting = _textView.TextSnapshot.GetText(caretPoint.Value.Position - 1, 1); if (deleting == ",") { PythonSignature sig = _sigHelpSession.SelectedSignature as PythonSignature; if (sig != null) { int curParam = sig.Parameters.IndexOf(sig.CurrentParameter); if (curParam > 0) { sig.SetCurrentParameter(sig.Parameters[curParam - 1]); } } } else if (deleting == "(") { // TODO: See if we should pop to an outer nesting of signature help _sigHelpSession.Dismiss(); } } } }
private void CommaFindBestSignature(int curParam) { // see if we have a signature which accomodates this... // TODO: We should also take into account param arrays // TODO: We should also get the types of the arguments and use that to // pick the best signature when the signature includes types. foreach (var availableSig in _sigHelpSession.Signatures) { if (availableSig.Parameters.Count > (curParam + 1)) { _sigHelpSession.SelectedSignature = availableSig; PythonSignature sig = availableSig as PythonSignature; if (sig != null) { sig.SetCurrentParameter(sig.Parameters[curParam + 1]); } break; } } }
private void CommaAdvanceParameter() { // we advance to the next parameter // TODO: Take into account params arrays // TODO: need to parse and see if we have keyword arguments entered into the current signature yet PythonSignature sig = _sigHelpSession.SelectedSignature as PythonSignature; if (sig != null) { int curParam = sig.Parameters.IndexOf(sig.CurrentParameter); if (curParam != -1) { if (curParam < sig.Parameters.Count - 1) { sig.SetCurrentParameter(sig.Parameters[curParam + 1]); } else { CommaFindBestSignature(curParam); } } } }