public override CompletionSet GetCompletions(IGlyphService glyphService) { var start = _stopwatch.ElapsedMilliseconds; var analysis = GetAnalysisEntry(); var completions = analysis.GetAllAvailableMembersByIndex(Span.GetEndPoint(TextBuffer.CurrentSnapshot).Position, GetMemberOptions.None) .Where(IsExceptionType) .Select(member => JCompletion(glyphService, member)) .OrderBy(completion => completion.DisplayText); var res = new FuzzyCompletionSet("JExceptions", "J", Span, completions, _options, CompletionComparer.UnderscoresLast); var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ end - start > TooMuchTime) { Trace.WriteLine(String.Format("{0} lookup time {1} for {2} classes", this, end - start, res.Completions.Count)); } return res; }
public override CompletionSet GetCompletions(IGlyphService glyphService) { var start1 = _stopwatch.ElapsedMilliseconds; var members = Enumerable.Empty<MemberResult>(); IReplEvaluator eval; IJReplIntellisense pyReplEval = null; if (_snapshot.TextBuffer.Properties.TryGetProperty<IReplEvaluator>(typeof(IReplEvaluator), out eval)) { pyReplEval = eval as IJReplIntellisense; } var analysis = GetAnalysisEntry(); var text = PrecedingExpression; if (!string.IsNullOrEmpty(text)) { string fixedText = FixupCompletionText(text); if (analysis != null && fixedText != null && (pyReplEval == null || !pyReplEval.LiveCompletionsOnly)) { lock (_analyzer) { members = members.Concat(analysis.GetMembersByIndex( fixedText, Span.GetEndPoint(_snapshot).Position, _options.MemberOptions ).ToArray()); } } if (pyReplEval != null && fixedText != null && _snapshot.TextBuffer.GetAnalyzer().ShouldEvaluateForCompletion(fixedText)) { var replStart = _stopwatch.ElapsedMilliseconds; var replMembers = pyReplEval.GetMemberNames(fixedText); if (replMembers != null) { members = members.Union(replMembers, CompletionComparer.MemberEquality); } } } else { members = analysis.GetAllAvailableMembersByIndex(Span.GetStartPoint(_snapshot).Position, _options.MemberOptions); } var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ (end - start1) > TooMuchTime) { var memberArray = members.ToArray(); members = memberArray; Trace.WriteLine(String.Format("{0} lookup time {1} for {2} members", this, end - start1, members.Count())); } var start = _stopwatch.ElapsedMilliseconds; var result = new FuzzyCompletionSet( "J", "J", Span, members.Select(m => JCompletion(glyphService, m)), _options, CompletionComparer.UnderscoresLast); 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; }
public override CompletionSet GetCompletions(IGlyphService glyphService) { var start = _stopwatch.ElapsedMilliseconds; var completions = GetModules(_namespace, true).Select(m => JCompletion(glyphService, m)); var res = new FuzzyCompletionSet("JImports", "J", Span, completions, _options, CompletionComparer.UnderscoresLast); var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ end - start > TooMuchTime) { Trace.WriteLine(String.Format("{0} lookup time {1} for {2} imports", this, end - start, res.Completions.Count)); } return res; }
public override CompletionSet GetCompletions(IGlyphService glyphService) { var start = _stopwatch.ElapsedMilliseconds; var line = Span.GetStartPoint(TextBuffer.CurrentSnapshot).GetContainingLine(); int lineStart = line.Start.Position; int defIndent = line.GetText().IndexOf("def"); var pyAnalysis = TextBuffer.GetJAnalysis(); JAst ast; IAnalysisCookie cookie; pyAnalysis.GetTreeAndCookie(out ast, out cookie); var sCookie = cookie as SnapshotCookie; if (sCookie != null) { // Map the analysis position to its location in the analyzed // snapshot, but keep the indent level unchanged. This ensures // that if the user has typed 'def' before the analysis is // updated they will get completions for the correct class. if (sCookie.Snapshot.TextBuffer != TextBuffer) { IBufferGraph graph; if (sCookie.Snapshot.TextBuffer.Properties.TryGetProperty(typeof(IBufferGraph), out graph)) { var newLine = graph.MapDownToInsertionPoint(line.Start, PointTrackingMode.Positive, JCoreConstants.IsJContent); if (newLine != null) { lineStart = newLine.Value.Position; } } } else if (sCookie.Snapshot != line.Snapshot) { var newLine = Span.GetStartPoint(sCookie.Snapshot).GetContainingLine(); lineStart = newLine.Start.Position; } } int pos = lineStart + defIndent; var analysis = GetAnalysisEntry(); var cls = analysis.GetDefinitionTreeByIndex(pos).LastOrDefault(member => member.MemberType == Interpreter.JMemberType.Class); var members = analysis.GetOverrideableByIndex(pos).ToArray(); var completions = members .Select(member => JCompletion(glyphService, member.Name, MakeCompletionString(member, cls.Name), member.Documentation, StandardGlyphGroup.GlyphGroupOverload)); var res = new FuzzyCompletionSet("JOverrides", "J", Span, completions, _options, CompletionComparer.UnderscoresLast); var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ end - start > TooMuchTime) { Trace.WriteLine(String.Format("{0} lookup time {1} for {2} classes", this, end - start, res.Completions.Count)); } return res; }
public override CompletionSet GetCompletions(IGlyphService glyphService) { if (_noCompletions) { return null; } if (_importKeywordOnly) { var completion = new[] { JCompletion(glyphService, "import", null, StandardGlyphGroup.GlyphKeyword) }; return new FuzzyCompletionSet("JImportKeyword", "J", Span, completion, _options, CompletionComparer.UnderscoresLast); } var start = _stopwatch.ElapsedMilliseconds; var completions = GetModules(_namespace, _modulesOnly).Select(m => JCompletion(glyphService, m)); if (_includeStar) { var completion = new[] { JCompletion(glyphService, "*", "Import all members from the module", StandardGlyphGroup.GlyphArrow) }; completions = completions.Concat(completion); } var res = new FuzzyCompletionSet("JFromImports", "J", Span, completions, _options, CompletionComparer.UnderscoresLast); var end = _stopwatch.ElapsedMilliseconds; if (/*Logging &&*/ end - start > TooMuchTime) { Trace.WriteLine(String.Format("{0} lookup time {1} for {2} imports", this, end - start, res.Completions.Count)); } return res; }