public static SignatureAnalysis GetSignatures(this ITextSnapshot snapshot, ITrackingSpan span) { #pragma warning disable 0618 return(VsProjectAnalyzer.GetSignatures(PythonToolsPackage.Instance, snapshot, span)); #pragma warning restore 0618 }
public override CompletionSet GetCompletions(IGlyphService glyphService) { var start1 = _stopwatch.ElapsedMilliseconds; IEnumerable <MemberResult> members = null; IEnumerable <MemberResult> replMembers = null; IInteractiveEvaluator eval; IPythonReplIntellisense pyReplEval = null; if (_snapshot.TextBuffer.Properties.TryGetProperty(typeof(IInteractiveEvaluator), out eval)) { pyReplEval = eval as IPythonReplIntellisense; } var analysis = GetAnalysisEntry(); string text; SnapshotSpan statementRange; if (!GetPrecedingExpression(out text, out statementRange)) { return(null); } else if (string.IsNullOrEmpty(text)) { if (analysis != null) { lock (_analyzer) { var location = VsProjectAnalyzer.TranslateIndex( statementRange.Start.Position, statementRange.Snapshot, analysis ); var parameters = Enumerable.Empty <MemberResult>(); var sigs = VsProjectAnalyzer.GetSignatures(_serviceProvider, _snapshot, Span); if (sigs.Signatures.Any()) { parameters = sigs.Signatures .SelectMany(s => s.Parameters) .Select(p => p.Name) .Distinct() .Select(n => new MemberResult(n, PythonMemberType.Field)); } members = analysis.GetAllAvailableMembers(location, _options.MemberOptions) .Union(parameters, CompletionComparer.MemberEquality); } } if (pyReplEval != null) { replMembers = pyReplEval.GetMemberNames(string.Empty); } } else { if (analysis != null && (pyReplEval == null || !pyReplEval.LiveCompletionsOnly)) { lock (_analyzer) { var location = VsProjectAnalyzer.TranslateIndex( statementRange.Start.Position, statementRange.Snapshot, analysis ); members = analysis.GetMembers(text, location, _options.MemberOptions); } } if (pyReplEval != null && _snapshot.TextBuffer.GetAnalyzer(_serviceProvider).ShouldEvaluateForCompletion(text)) { replMembers = pyReplEval.GetMemberNames(text); } } if (replMembers != null) { if (members != null) { members = members.Union(replMembers, CompletionComparer.MemberEquality); } else { members = replMembers; } } var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ (end - start1) > TooMuchTime) { if (members != null) { var memberArray = members.ToArray(); members = memberArray; Trace.WriteLine(String.Format("{0} lookup time {1} for {2} members", this, end - start1, members.Count())); } else { Trace.WriteLine(String.Format("{0} lookup time {1} for zero members", this, end - start1)); } } if (members == null) { // The expression is invalid so we shouldn't provide // a completion set at all. return(null); } var start = _stopwatch.ElapsedMilliseconds; var result = new FuzzyCompletionSet( "Python", "Python", Span, members.Select(m => PythonCompletion(glyphService, m)), _options, CompletionComparer.UnderscoresLast, matchInsertionText: true ); end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ (end - start1) > TooMuchTime) { Trace.WriteLine(String.Format("{0} completion set time {1} total time {2}", this, end - start, end - start1)); } return(result); }
/// <summary> /// Gets a list of signatures available for the expression at the provided location in the snapshot. /// </summary> internal static SignatureAnalysis GetSignatures(this ITextSnapshot snapshot, IServiceProvider serviceProvider, ITrackingSpan span) { return(VsProjectAnalyzer.GetSignatures(serviceProvider, snapshot, span)); }