private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session) { SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition); ITextStructureNavigator navigator = _provider.NavigatorService.GetTextStructureNavigator(_textBuffer); TextExtent extent = navigator.GetExtentOfWord(currentPoint); return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive); }
private Model( DisconnectedBufferGraph disconnectedBufferGraph, IList<CompletionItem> totalItems, IList<CompletionItem> filteredItems, CompletionItem selectedItem, bool isHardSelection, bool isUnique, bool useSuggestionCompletionMode, CompletionItem builder, CompletionItem defaultBuilder, CompletionTriggerInfo triggerInfo, ITrackingPoint commitSpanEndPoint, bool dismissIfEmpty) { Contract.ThrowIfNull(selectedItem); Contract.ThrowIfFalse(totalItems.Count != 0, "Must have at least one item."); Contract.ThrowIfFalse(filteredItems.Count != 0, "Must have at least one filtered item."); Contract.ThrowIfFalse(filteredItems.Contains(selectedItem) || defaultBuilder == selectedItem, "Selected item must be in filtered items."); _disconnectedBufferGraph = disconnectedBufferGraph; this.TotalItems = totalItems; this.FilteredItems = filteredItems; this.SelectedItem = selectedItem; this.IsHardSelection = isHardSelection; this.IsUnique = isUnique; this.UseSuggestionCompletionMode = useSuggestionCompletionMode; this.Builder = builder; this.DefaultBuilder = defaultBuilder; this.TriggerInfo = triggerInfo; this.CommitTrackingSpanEndPoint = commitSpanEndPoint; this.DismissIfEmpty = dismissIfEmpty; }
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, IIntellisenseSession session) { var currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1; var navigator = _sourceProvider.NavigatorService.GetTextStructureNavigator(_textBuffer); var extent = navigator.GetExtentOfWord(currentPoint); return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive); }
public override IEnumerable<INavigateToTarget> GoToSourceImpl(VSOBJGOTOSRCTYPE gotoSourceType, ITrackingPoint triggerPoint) { if (triggerPoint == null) return new INavigateToTarget[0]; return base.GoToSourceImpl(gotoSourceType, triggerPoint); }
private Model( DisconnectedBufferGraph disconnectedBufferGraph, IList<CompletionItem> totalItems, IList<CompletionItem> filteredItems, CompletionItem selectedItem, ImmutableArray<CompletionItemFilter> completionItemFilters, ImmutableDictionary<CompletionItemFilter, bool> filterState, IReadOnlyDictionary<CompletionItem, string> completionItemToFilterText, bool isHardSelection, bool isUnique, bool useSuggestionCompletionMode, CompletionItem builder, CompletionItem defaultBuilder, CompletionTriggerInfo triggerInfo, ITrackingPoint commitSpanEndPoint, bool dismissIfEmpty) { Contract.ThrowIfFalse(totalItems.Count != 0, "Must have at least one item."); _disconnectedBufferGraph = disconnectedBufferGraph; this.TotalItems = totalItems; this.FilteredItems = filteredItems; this.FilterState = filterState; this.SelectedItem = selectedItem; this.CompletionItemFilters = completionItemFilters; this.CompletionItemToFilterText = completionItemToFilterText; this.IsHardSelection = isHardSelection; this.IsUnique = isUnique; this.UseSuggestionCompletionMode = useSuggestionCompletionMode; this.Builder = builder; this.DefaultBuilder = defaultBuilder; this.TriggerInfo = triggerInfo; this.CommitTrackingSpanEndPoint = commitSpanEndPoint; this.DismissIfEmpty = dismissIfEmpty; }
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session, out bool isUpperCase) { SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1; ITextStructureNavigator navigator = sourceProvider.NavigatorService.GetTextStructureNavigator(textBuffer); TextExtent extent = navigator.GetExtentOfWord(currentPoint); string text = extent.Span.GetText(); string strText = navigator.GetExtentOfWord((session.TextView.Caret.Position.BufferPosition) - text.Length - 1).Span.GetText(); int uppercasePosition = 0; int underscorePosition = 0; if (NLAConfiguration.UnderscoreSeparator) { uppercasePosition = text.LastIndexOf("_"); if (uppercasePosition > 0) { uppercasePosition = uppercasePosition + 1; // get passed the underscore character underscorePosition = uppercasePosition; } } else if (NLAConfiguration.UpperCaseSeparator) { uppercasePosition = text.LastIndexOf(text.LastOrDefault(c => char.IsUpper(c))); underscorePosition = uppercasePosition - 1; } isUpperCase = char.IsUpper(text[0]); if (!NLAConfiguration.AllowInStrings) { var line = currentPoint.GetContainingLine(); var doubleQuote = line.GetText().IndexOf("\""); var singleQuote = line.GetText().IndexOf("'"); if ((doubleQuote >= 0 && line.Start.Position + doubleQuote <= currentPoint.Position) || (singleQuote >= 0 && line.Start.Position + singleQuote <= currentPoint.Position)) { return null; } } if (uppercasePosition > 0) { var span = currentPoint.Snapshot.CreateTrackingSpan(extent.Span.Start.Position + uppercasePosition, text.Length - uppercasePosition, SpanTrackingMode.EdgeInclusive); var underscoreSpan = currentPoint.Snapshot.CreateTrackingSpan(extent.Span.Start.Position + underscorePosition, text.Length - underscorePosition, SpanTrackingMode.EdgeInclusive); if (!NLAConfiguration.UnderscoreSeparator && underscoreSpan.GetText(currentPoint.Snapshot).StartsWith("_")) // avoid this "word_Composition" when camel case is not active { return null; } text = span.GetText(currentPoint.Snapshot); if (!String.IsNullOrEmpty(text)) { isUpperCase = char.IsUpper(text[0]); } return span; } return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive); }
/// <summary> /// Moves the cursor to the current mark in the location stack and moves the current mark to the location where the cursor mark was when the command was invoked. /// </summary> internal void SwapPointAndMark() { var previousActiveMark = this.activeMark; this.activeMark = this.currentMark = CreateTrackingPoint(view.GetCaretPosition()); this.view.Caret.MoveTo(previousActiveMark.GetPoint(view.TextSnapshot)); this.IsActive = true; UpdateSelection(); }
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession completionSession) { SnapshotPoint ssPoint = (completionSession.TextView.Caret.Position.BufferPosition) - 1; ITextStructureNavigator navigator = sourceProvider.TextNavigatorService.GetTextStructureNavigator(this.textBuffer); TextExtent textExtent = navigator.GetExtentOfWord(ssPoint); return ssPoint.Snapshot.CreateTrackingSpan(textExtent.Span, SpanTrackingMode.EdgeInclusive); }
public TypingAgent(RemoteAgentTag tag, string textToType, SnapshotPoint insertionPoint, Dispatcher dispatcher) { Tag = tag; _textToType = textToType; _insertionPoint = insertionPoint.Snapshot.CreateTrackingPoint(insertionPoint, PointTrackingMode.Positive); _dispatcher = dispatcher; }
internal MarkSession(ITextView view, EmacsCommandsManager manager) { this.manager = manager; this.view = view; this.view.Selection.SelectionChanged += new EventHandler(Selection_SelectionChanged); this.activeMark = this.currentMark = CreateTrackingPoint(0); }
public ISignatureHelpSession TriggerSignatureHelp(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); var session = CreateSignatureHelpSession(textView, triggerPoint, trackCaret); session.Start(); return session.IsDismissed ? null : session; }
public IQuickInfoSession TriggerQuickInfo(ITextView textView, ITrackingPoint triggerPoint, bool trackMouse) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); var session = CreateQuickInfoSession(textView, triggerPoint, trackMouse); session.Start(); return session.IsDismissed ? null : session; }
public IQuickInfoSession CreateQuickInfoSession(ITextView textView, ITrackingPoint triggerPoint, bool trackMouse) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); var stack = intellisenseSessionStackMapService.Value.GetStackForTextView(textView); var session = new QuickInfoSession(textView, triggerPoint, trackMouse, intellisensePresenterFactoryService.Value, quickInfoSourceProviders); stack.PushSession(session); return session; }
public static SnapshotPoint? GetTriggerPoint(ITextView textView, ITrackingPoint triggerPoint, ITextSnapshot textSnapshot) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (textSnapshot == null) throw new ArgumentNullException(nameof(textSnapshot)); return triggerPoint.GetPoint(textView.TextSnapshot); }
public ISignatureHelpSession CreateSignatureHelpSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); var stack = intellisenseSessionStackMapService.Value.GetStackForTextView(textView); var session = new SignatureHelpSession(textView, triggerPoint, trackCaret, intellisensePresenterFactoryService.Value, signatureHelpSourceProviders); currentLineSpaceReservationService.Value.SessionCreated(session); stack.PushSession(session); return session; }
public ISmartTagSession CreateSmartTagSession(ITextView textView, SmartTagType type, ITrackingPoint triggerPoint, SmartTagState state) { var session = new MockSmartTagSession(this) { TextView = textView, Type = type, TriggerPoint = triggerPoint, State = state }; lock (_sessions) { _sessions.Add(new KeyValuePair<ITextView, ISmartTagSession>(textView, session)); } session.Dismissed += Session_Dismissed; return session; }
public static ITrackingPoint GetTriggerPoint(ITextView textView, ITrackingPoint triggerPoint, ITextBuffer textBuffer) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (textBuffer == null) throw new ArgumentNullException(nameof(textBuffer)); var point = GetTriggerPoint(textView, triggerPoint, textBuffer.CurrentSnapshot); if (point == null) return null; return point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Negative); }
public void Setup() { _stubSession = MockRepository.GenerateStub<ICompletionSession>(); _stubTextBuffer = MockRepository.GenerateStub<ITextBuffer>(); _stubViewExplorer = MockRepository.GenerateStub<IViewExplorer>(); _stubTrackingPoint = MockRepository.GenerateStub<ITrackingPoint>(); _stubTrackingSpan = MockRepository.GenerateStub<ITrackingSpan>(); _stubSnapshot = MockRepository.GenerateStub<ITextSnapshot>(); _stubTextBuffer.Stub(x => x.CurrentSnapshot).Return(_stubSnapshot); _stubSession.Stub(x => x.GetTriggerPoint(_stubTextBuffer)).Return(_stubTrackingPoint); _stubTrackingPoint.Stub(x => x.GetPoint(_stubSnapshot)).Return(new SnapshotPoint(_stubSnapshot, 0)); _stubViewExplorer.Stub(x => x.GetRelatedPartials()).Return(new List<string>()); }
/// <summary> /// Finds the span of completion text to replace and use for searching. /// </summary> ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session, CompletionMode mode) { var end = session.TextView.Caret.Position.BufferPosition; var start = end; var ch = start.GetChar(); while (start.Position > 0) { var temp = start - 1; ch = temp.GetChar(); if (!(char.IsLetterOrDigit(ch) || ch == ':' || ch == '_') || ch == '"' || ch == '\'' || ch == '.') break; start = temp; } var span = Span.FromBounds(start.Position, end.Position); return start.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive); }
void textView_MouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?ssPoint = textView.BufferGraph.MapDownToFirstMatch(new SnapshotPoint(textView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => textBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (ssPoint != null) { ITrackingPoint point = ssPoint.Value.Snapshot.CreateTrackingPoint(ssPoint.Value.Position, PointTrackingMode.Positive); if (!controllerProvider.QuickInfoBroker.IsQuickInfoActive(this.textView)) { quickInfoSession = controllerProvider.QuickInfoBroker.TriggerQuickInfo(textView, point, true); } } }
/// <summary> /// Determine if the mouse is hovering over a token. If so, highlight the token and display QuickInfo /// </summary> private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?point = GetMousePosition(new SnapshotPoint(_textView.TextSnapshot, e.Position)); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); // Find the broker for this buffer if (!_componentContext.QuickInfoBroker.IsQuickInfoActive(_textView)) { _componentContext.QuickInfoBroker.TriggerQuickInfoAsync(_textView, triggerPoint); } } }
private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?point = GetMousePosition(new SnapshotPoint(TextView.TextSnapshot, e.Position)); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); // Find the broker for this buffer if (!Provider.QuickInfoBroker.IsQuickInfoActive(TextView)) { Session = Provider.QuickInfoBroker.CreateQuickInfoSession(TextView, triggerPoint, true); Session.Start(); } } }
private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { // I don't really know what this is all for; but it's in the MSDN sample... // http://msdn.microsoft.com/en-us/library/vstudio/ee197646(v=vs.120).aspx SnapshotPoint?point = textView.BufferGraph.MapDownToFirstMatch(new SnapshotPoint(textView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => subjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); if (!provider.QuickInfoBroker.IsQuickInfoActive(textView)) { session = provider.QuickInfoBroker.TriggerQuickInfo(textView, triggerPoint, true); } } }
public static SnapshotPoint?GetTriggerPoint(ITextView textView, ITrackingPoint triggerPoint, ITextSnapshot textSnapshot) { if (textView is null) { throw new ArgumentNullException(nameof(textView)); } if (triggerPoint is null) { throw new ArgumentNullException(nameof(triggerPoint)); } if (textSnapshot is null) { throw new ArgumentNullException(nameof(textSnapshot)); } return(triggerPoint.GetPoint(textView.TextSnapshot)); }
public ISignatureHelpSession CreateSignatureHelpSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret) { if (textView == null) { throw new ArgumentNullException(nameof(textView)); } if (triggerPoint == null) { throw new ArgumentNullException(nameof(triggerPoint)); } var stack = intellisenseSessionStackMapService.Value.GetStackForTextView(textView); var session = new SignatureHelpSession(textView, triggerPoint, trackCaret, intellisensePresenterFactoryService.Value, signatureHelpSourceProviders); currentLineSpaceReservationService.Value.SessionCreated(session); stack.PushSession(session); return(session); }
private void ProcessOutput(ITextSnapshot snapshot, ITrackingPoint startPoint, ITrackingPoint endPoint) { int textStart = startPoint.GetPosition(snapshot); int textLength = endPoint.GetPoint(snapshot) - startPoint.GetPoint(snapshot); string text = snapshot.GetText(textStart, textLength); BindingEntry[] entries = this.bindingParser.ParseOutput(text); if (entries.Length > 0) { this.JoinableTaskFactory.RunAsync(async delegate { await this.JoinableTaskFactory.SwitchToMainThreadAsync(); this.viewModel.AddEntries(entries); }).FileAndForget(Constants.VsBindingPaneFeaturePrefix + nameof(this.ProcessOutput)); } }
internal void PopMark() { if (marks.Count > 0) { if (currentMark != activeMark) { currentMark = activeMark; } activeMark = marks.Pop(); } else { currentMark = activeMark = CreateTrackingPoint(0); } view.Caret.MoveTo(currentMark.GetPoint(view.TextSnapshot)); UpdateSelection(); }
void UpdateAtCaretPosition(CaretPosition caretPosition) { SnapshotPoint?point = caretPosition.Point.GetPoint(m_textView.TextSnapshot, caretPosition.Affinity); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); if (!m_provider.QuickInfoBroker.IsQuickInfoActive(m_textView)) { m_session = m_provider.QuickInfoBroker.TriggerQuickInfo(m_textView, triggerPoint, true); } } }
private void AsyncStartCompletionSession() { this.editorElement.Dispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback((object o) => { ITrackingPoint trackingPoint = this.textView.TextBuffer.CurrentSnapshot.CreateTrackingPoint(this.textView.Caret.Position.Index, PointTrackingMode.Positive); if (this.activeSession == null) { ICompletionSession completionSession = this.completionBroker.TriggerCompletion(trackingPoint); ICompletionSession completionSession1 = completionSession; this.activeSession = completionSession; if (completionSession1 != null) { this.InitializeActiveCompletionSession(); } } return(null); }), null); }
private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session) { SnapshotPoint currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1; ITextStructureNavigator navigator = m_sourceProvider.NavigatorService.GetTextStructureNavigator(m_textBuffer); // Extend the span until the first whitespace char occurs beforehand. var currentExtent = navigator.GetExtentOfWord(currentPoint); var lastPosition = currentExtent.Span.End; while (!char.IsWhiteSpace(currentExtent.Span.Start.GetChar())) { currentExtent = navigator.GetExtentOfWord(currentExtent.Span.Start - 1); } var targetSpan = new SnapshotSpan(currentExtent.Span.End, lastPosition); return(currentPoint.Snapshot.CreateTrackingSpan(targetSpan, SpanTrackingMode.EdgeInclusive)); }
private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?point = _textView.BufferGraph.MapDownToFirstMatch (new SnapshotPoint(_textView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => _subjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); if (!_provider.QuickInfoBroker.IsQuickInfoActive(_textView)) { _session = _provider.QuickInfoBroker.TriggerQuickInfo(_textView, triggerPoint, true); } } }
public QuickInfoSession(ITextView textView, ITrackingPoint triggerPoint, bool trackMouse, IIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy<IQuickInfoSourceProvider, IOrderableContentTypeMetadata>[] quickInfoSourceProviders) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (intellisensePresenterFactoryService == null) throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); if (quickInfoSourceProviders == null) throw new ArgumentNullException(nameof(quickInfoSourceProviders)); Properties = new PropertyCollection(); QuickInfoContent = new BulkObservableCollection<object>(); TextView = textView; this.triggerPoint = triggerPoint; TrackMouse = trackMouse; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.quickInfoSourceProviders = quickInfoSourceProviders; TextView.Closed += TextView_Closed; }
/// <summary> /// Finds the token span at current position. /// </summary> /// <param name="point">The <see cref="ITrackingPoint"/>.</param> /// <param name="session">The <see cref="ICompletionSession"/>.</param> /// <returns>The <see cref="ITrackingSpan"/>.</returns> private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session) { try { // Data validation if (point == null || session == null) { return(null); } // Find the token span at current position SnapshotPoint currentPoint = session.TextView.Caret.Position.BufferPosition - 1; return(currentPoint.Snapshot.CreateTrackingSpan(currentPoint.Position, 1, SpanTrackingMode.EdgeInclusive)); } catch (Exception) { } return(null); }
/// <summary> /// Creates new instance of the <see cref="NestedPeekTriggeredEventArgs"/>. /// </summary> /// <param name="relationshipName">Case insensitive name of the relationship that was used to invoke nested Peek.</param> /// <param name="peekableItems">The list of the <see cref="IPeekableItem"/> objects that can provide results of the /// nested Peek invocation.</param> public NestedPeekTriggeredEventArgs(string relationshipName, ITrackingPoint trackingPoint, IEnumerable <IPeekableItem> peekableItems) { if (string.IsNullOrWhiteSpace(relationshipName)) { throw new ArgumentException("cannot be null or whitespace", nameof(relationshipName)); } if (peekableItems == null) { throw new ArgumentNullException(nameof(peekableItems)); } if (trackingPoint == null) { throw new ArgumentNullException(nameof(trackingPoint)); } RelationshipName = relationshipName; PeekableItems = peekableItems; TrackingPoint = trackingPoint; }
public CompletionSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret, IIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy<ICompletionSourceProvider, IOrderableContentTypeMetadata>[] completionSourceProviders) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (intellisensePresenterFactoryService == null) throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); if (completionSourceProviders == null) throw new ArgumentNullException(nameof(completionSourceProviders)); completionSets = new ObservableCollection<CompletionSet>(); CompletionSets = new ReadOnlyObservableCollection<CompletionSet>(completionSets); Properties = new PropertyCollection(); TextView = textView; this.triggerPoint = triggerPoint; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.completionSourceProviders = completionSourceProviders; //TODO: Use trackCaret TextView.Closed += TextView_Closed; }
public int InsertNamedExpansion(string pszTitle, string pszPath, TextSpan textSpan) { if (_session != null) { // if the user starts an expansion session while one is in progress // then abort the current expansion session _session.EndCurrentExpansion(1); _session = null; } var expansion = _lines as IVsExpansion; if (expansion == null) { return(VSConstants.S_OK); } var selection = _textView.Selection; var snapshot = selection.Start.Position.Snapshot; _selectionStart = snapshot.CreateTrackingPoint(selection.Start.Position, PointTrackingMode.Positive); _selectionEnd = snapshot.CreateTrackingPoint(selection.End.Position, PointTrackingMode.Negative); _selectEndSpan = _sessionEnded = false; var hr = expansion.InsertNamedExpansion( pszTitle, pszPath, textSpan, this, new Guid(GuidList.PowerShellLanguage), 0, out _session ); if (ErrorHandler.Succeeded(hr)) { if (_sessionEnded) { _session = null; } } return(VSConstants.S_OK); }
// TODO Investigate ITrackingPoint for updating TODO state. (edit). // TODO by Friday See if can use tracking to update line number of reminder. /* * SnapshotPoint? point = textView.BufferGraph.MapDownToFirstMatch( * new SnapshotPoint(textView.TextSnapshot, e.Position), * PointTrackingMode.Positive, * snapshot => textBuffers.Contains(snapshot.TextBuffer), * PositionAffinity.Predecessor * ); * if ( point != null ) { * ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint( * point.Value.Position, PointTrackingMode.Positive); * if ( provider.QuickInfoBroker.IsQuickInfoActive(textView) ) { * session = provider.QuickInfoBroker.TriggerQuickInfo(textView, triggerPoint, true); * } * }*/ void createTrackingPointTest(SnapshotPoint point, ITextView textView) { if (point != null) { ITrackingPoint triggerPoint = point.Snapshot.CreateTrackingPoint( point.Position, PointTrackingMode.Positive); //var updatedPoint = triggerPoint.GetPoint( textView.TextSnapshot ); } //SnapshotPoint? point = textView.BufferGraph.MapDownToFirstMatch( // new SnapshotPoint(textView.TextSnapshot, e.Position), // PointTrackingMode.Positive, // snapshot => textView.BufferGraph.GetTextBuffers( null ).Contains(snapshot.TextBuffer), // PositionAffinity.Predecessor //); //if ( provider.QuickInfoBroker.IsQuickInfoActive(textView) ) { // session = provider.QuickInfoBroker.TriggerQuickInfo(textView, triggerPoint, true); }
void TextView_MouseHover(object sender, MouseHoverEventArgs e) { // find the mouse position by mapping down to the subject buffer SnapshotPoint?point = this.textView.BufferGraph.MapDownToFirstMatch (new SnapshotPoint(this.textView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => this.subjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); if (!this.provider.QuickInfoBroker.IsQuickInfoActive(this.textView)) { this.session = this.provider.QuickInfoBroker.TriggerQuickInfo(this.textView, triggerPoint, true); } } }
/// <summary> /// Moves the cursor to the current mark and then removes the mark for the location stack. /// </summary> internal void PopMark() { if (this.marks.Count > 0) { if (this.currentMark != activeMark) { this.currentMark = activeMark; } this.activeMark = this.marks.Pop(); } else { this.currentMark = activeMark = CreateTrackingPoint(0); } this.view.Caret.MoveTo(currentMark.GetPoint(this.view.TextSnapshot)); this.UpdateSelection(); }
private void AddTrackingPoint(CaretPosition caretPosition) { ITrackingPoint trackingPoint = _view.TextSnapshot.CreateTrackingPoint(caretPosition.BufferPosition.Position, PointTrackingMode.Positive); if (trackingPoint.GetPosition(_view.TextSnapshot) >= 0) { _trackPointList.Add(trackingPoint); } else { trackingPoint = _view.TextSnapshot.CreateTrackingPoint(0, PointTrackingMode.Positive); _trackPointList.Add(trackingPoint); } if (caretPosition.VirtualSpaces > 0) { _view.Caret.MoveTo(trackingPoint.GetPoint(_view.TextSnapshot)); } }
internal void ApplyStashedCaretPosition() { if (!Selections.Any( s => s.Caret.GetPoint(Snapshot).Position == stashedCaretPosition.GetPoint(Snapshot).Position) ) { Selections.Add( new Selection { Start = null, End = null, Caret = stashedCaretPosition } ); } stashedCaretPosition = null; }
/// <summary> /// Initializes a new instance of the <see cref="InlineCommentPeekViewModel"/> class. /// </summary> public InlineCommentPeekViewModel(IInlineCommentPeekService peekService, IPeekSession peekSession, IPullRequestSessionManager sessionManager, INextInlineCommentCommand nextCommentCommand, IPreviousInlineCommentCommand previousCommentCommand, IViewViewModelFactory factory) { Guard.ArgumentNotNull(peekService, nameof(peekService)); Guard.ArgumentNotNull(peekSession, nameof(peekSession)); Guard.ArgumentNotNull(sessionManager, nameof(sessionManager)); Guard.ArgumentNotNull(nextCommentCommand, nameof(nextCommentCommand)); Guard.ArgumentNotNull(previousCommentCommand, nameof(previousCommentCommand)); Guard.ArgumentNotNull(factory, nameof(factory)); this.peekService = peekService; this.peekSession = peekSession; this.sessionManager = sessionManager; this.factory = factory; triggerPoint = peekSession.GetTriggerPoint(peekSession.TextView.TextBuffer); peekSession.Dismissed += (s, e) => Dispose(); Close = this.WhenAnyValue(x => x.Thread) .Where(x => x != null) .SelectMany(x => x.IsNewThread ? x.Comments.Single().CancelEdit.SelectUnit() : Observable.Never <Unit>()); NextComment = ReactiveCommand.CreateFromTask( () => nextCommentCommand.Execute(new InlineCommentNavigationParams { FromLine = peekService.GetLineNumber(peekSession, triggerPoint).Item1, }), Observable.Return(nextCommentCommand.Enabled)); PreviousComment = ReactiveCommand.CreateFromTask( () => previousCommentCommand.Execute(new InlineCommentNavigationParams { FromLine = peekService.GetLineNumber(peekSession, triggerPoint).Item1, }), Observable.Return(previousCommentCommand.Enabled)); }
public void PushSession(IBraceCompletionSession session) { ITextView view = null; ITextBuffer buffer = null; _guardedOperations.CallExtensionPoint(() => { view = session.TextView; buffer = session.SubjectBuffer; }); if (view != null && buffer != null) { SetCurrentBuffer(buffer); bool validStart = false; // start the session to add the closing brace _guardedOperations.CallExtensionPoint(() => { session.Start(); // verify the session is valid before going on. // some sessions may want to leave the stack at this point validStart = (session.OpeningPoint != null && session.ClosingPoint != null); }); if (validStart) { // highlight the brace ITrackingPoint closingPoint = null; _guardedOperations.CallExtensionPoint(() => { closingPoint = session.ClosingPoint; }); HighlightSpan(closingPoint); // put it on the stack for tracking _stack.Push(session); } } }
private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { //find the mouse position by mapping down to the subject buffer SnapshotPoint?point = m_textView.BufferGraph.MapDownToFirstMatch (new SnapshotPoint(m_textView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => m_subjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); if (!m_provider.QuickInfoBroker.IsQuickInfoActive(m_textView)) // check the quick info feather is enable in this textView { /// Trigger QUickInfoProvider below m_session = m_provider.QuickInfoBroker.TriggerQuickInfo(m_textView, triggerPoint, true); } } }
/// <summary> /// Finds the span of completion text to replace and use for searching. /// </summary> ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession session, CompletionMode mode) { var end = session.TextView.Caret.Position.BufferPosition; var start = end; var ch = start.GetChar(); while (start.Position > 0) { var temp = start - 1; ch = temp.GetChar(); if (!(char.IsLetterOrDigit(ch) || ch == ':' || ch == '_') || ch == '"' || ch == '\'' || ch == '.') { break; } start = temp; } var span = Span.FromBounds(start.Position, end.Position); return(start.Snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive)); }
public SignatureHelpSession(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret, IIntellisensePresenterFactoryService intellisensePresenterFactoryService, Lazy<ISignatureHelpSourceProvider, IOrderableContentTypeMetadata>[] signatureHelpSourceProviders) { if (textView == null) throw new ArgumentNullException(nameof(textView)); if (triggerPoint == null) throw new ArgumentNullException(nameof(triggerPoint)); if (intellisensePresenterFactoryService == null) throw new ArgumentNullException(nameof(intellisensePresenterFactoryService)); if (signatureHelpSourceProviders == null) throw new ArgumentNullException(nameof(signatureHelpSourceProviders)); Properties = new PropertyCollection(); TextView = textView; this.triggerPoint = triggerPoint; this.trackCaret = trackCaret; this.intellisensePresenterFactoryService = intellisensePresenterFactoryService; this.signatureHelpSourceProviders = signatureHelpSourceProviders; signatures = new ObservableCollection<ISignature>(); Signatures = new ReadOnlyObservableCollection<ISignature>(signatures); TextView.Closed += TextView_Closed; }
private void ProcessOutput(ITextSnapshot snapshot, ITrackingPoint startPoint, ITrackingPoint endPoint) { int textStart = startPoint.GetPosition(snapshot); int textLength = endPoint.GetPoint(snapshot) - startPoint.GetPoint(snapshot); string text = snapshot.GetText(textStart, textLength); IReadOnlyList <ITableEntry> entries = this.outputParser.ParseOutput(text); if (entries.Count > 0) { this.package.JoinableTaskFactory.RunAsync(async delegate { await this.package.JoinableTaskFactory.SwitchToMainThreadAsync(); if (this.viewModel.AddEntries(entries)) { this.NotifyUserAboutNewEntries(); } }).FileAndForget(Constants.VsBindingPaneFeaturePrefix + nameof(this.ProcessOutput)); } }
/// <summary> /// Called when [text view mouse hover]. /// </summary> /// <param name = "sender">The sender.</param> /// <param name = "e">The <see cref = "Microsoft.VisualStudio.Text.Editor.MouseHoverEventArgs" /> instance containing the event data.</param> private void OnTextViewMouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?point = GetMousePosition(new SnapshotPoint(_TextView.TextSnapshot, e.Position)); if (!point.HasValue) { return; } ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); // Find the broker for this buffer if (!_ComponentContext.QuickInfoBroker.IsQuickInfoActive(_TextView)) { _Session = _ComponentContext.QuickInfoBroker.CreateQuickInfoSession(_TextView, triggerPoint, true); _Session.Start(); } }
internal void SelectNextWord() { _view.Selection.Clear(); _view.Caret.IsHidden = true; // Faz com que o "cursor" vá para o final da palavra, pois aqui é SelectNextWord, ou seja a próxima palavra for (int i = 0; i < _trackPointList.Count; i++) { ITrackingPoint cursorPos = _trackPointList[i]; WordPosition nextWord = WordPosition.NextWord(_view.TextViewLines.FormattedSpan.GetText(), cursorPos.GetPosition(_view.TextSnapshot)); int newCursorPosition = ((_trackPointList[i].GetPosition(_view.TextSnapshot) + nextWord.Word.Length) < _view.TextViewLines.FormattedSpan.GetText().Length) && (nextWord.Word.Length > 0) ? (_trackPointList[i].GetPosition(_view.TextSnapshot) + nextWord.Word.Length) : _view.TextViewLines.FormattedSpan.GetText().Length - 1; _trackPointList[i] = _view.TextSnapshot.CreateTrackingPoint(new SnapshotPoint(_view.TextSnapshot, newCursorPosition), PointTrackingMode.Positive); if (_selectionList.Count < _trackPointList.Count) { _selectionList.Add(new TextSelection( new Tuple <ITrackingPoint, ITrackingPoint> ( _view.TextSnapshot.CreateTrackingPoint(new SnapshotPoint(_view.TextSnapshot, nextWord.Start), PointTrackingMode.Positive), _view.TextSnapshot.CreateTrackingPoint(new SnapshotPoint(_view.TextSnapshot, nextWord.End), PointTrackingMode.Positive) ), _view)); } else { _selectionList[i].Move(newCursorPosition); } } Selecting = true; RedrawScreen(); // Diz que está editando Editing = true; }
// Bug #512117: Remove compatibility shims for 2nd gen. Quick Info APIs. // This overload exists only to expose additional functionality required // by the shims. #region ILegacyQuickInfoBrokerSupport public async Task <IAsyncQuickInfoSession> TriggerQuickInfoAsync( ITextView textView, ITrackingPoint triggerPoint, QuickInfoSessionOptions options, PropertyCollection propertyCollection, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); // Dismiss any currently open session. var currentSession = this.GetSession(textView); if (currentSession != null) { await currentSession.DismissAsync().ConfigureAwait(true); } triggerPoint = await this.ResolveAndMapUpTriggerPointAsync(textView, triggerPoint, cancellationToken).ConfigureAwait(false); if (triggerPoint == null) { return(null); } var newSession = new AsyncQuickInfoPresentationSession( this.OrderedSourceProviders, this.guardedOperations, this.joinableTaskContext, this.toolTipService, textView, triggerPoint, options, propertyCollection); // StartAsync() is responsible for dispatching a StateChange // event if canceled so no need to clean these up on cancellation. newSession.StateChanged += this.OnStateChanged; textView.Properties.AddProperty(typeof(AsyncQuickInfoPresentationSession), newSession); return(await StartQuickInfoSessionAsync(newSession, cancellationToken).ConfigureAwait(false)); }
internal SnapshotPoint ApplyStashedCaretPosition() { var stashedCaretPosition = StashedCaret.GetPosition(Snapshot); var position = view.Caret.Position.BufferPosition; view.Caret.MoveTo(StashedCaret.GetPoint(Snapshot)); if (!Selections.Any(s => s.Caret.GetPoint(Snapshot) == stashedCaretPosition)) { Selections.Add( new Selection { Caret = StashedCaret, ColumnPosition = GetColumnPosition() } ); } StashedCaret = null; return(position); }
private Model( DisconnectedBufferGraph disconnectedBufferGraph, CompletionList originalList, ImmutableArray<PresentationItem> totalItems, ImmutableArray<PresentationItem> filteredItems, PresentationItem selectedItem, ImmutableArray<CompletionItemFilter> completionItemFilters, ImmutableDictionary<CompletionItemFilter, bool> filterState, IReadOnlyDictionary<CompletionItem, string> completionItemToFilterText, bool isHardSelection, bool isUnique, bool useSuggestionMode, PresentationItem suggestionModeItem, PresentationItem defaultSuggestionModeItem, CompletionTrigger trigger, ITrackingPoint commitSpanEndPoint, bool dismissIfEmpty) { Contract.ThrowIfNull(selectedItem); Contract.ThrowIfFalse(totalItems.Length != 0, "Must have at least one item."); Contract.ThrowIfFalse(filteredItems.Length != 0, "Must have at least one filtered item."); Contract.ThrowIfFalse(filteredItems.Contains(selectedItem) || defaultSuggestionModeItem == selectedItem, "Selected item must be in filtered items."); _disconnectedBufferGraph = disconnectedBufferGraph; this.OriginalList = originalList; this.TotalItems = totalItems; this.FilteredItems = filteredItems; this.FilterState = filterState; this.SelectedItem = selectedItem; this.CompletionItemFilters = completionItemFilters; this.CompletionItemToFilterText = completionItemToFilterText; this.IsHardSelection = isHardSelection; this.IsUnique = isUnique; this.UseSuggestionMode = useSuggestionMode; this.SuggestionModeItem = suggestionModeItem; this.DefaultSuggestionModeItem = defaultSuggestionModeItem; this.Trigger = trigger; this.CommitTrackingSpanEndPoint = commitSpanEndPoint; this.DismissIfEmpty = dismissIfEmpty; }
private Model( DisconnectedBufferGraph disconnectedBufferGraph, CompletionList originalList, ImmutableArray <PresentationItem> totalItems, ImmutableArray <PresentationItem> filteredItems, PresentationItem selectedItem, ImmutableArray <CompletionItemFilter> completionItemFilters, ImmutableDictionary <CompletionItemFilter, bool> filterState, IReadOnlyDictionary <CompletionItem, string> completionItemToFilterText, bool isHardSelection, bool isUnique, bool useSuggestionMode, PresentationItem suggestionModeItem, PresentationItem defaultSuggestionModeItem, CompletionTrigger trigger, ITrackingPoint commitSpanEndPoint, bool dismissIfEmpty) { Contract.ThrowIfNull(selectedItem); Contract.ThrowIfFalse(totalItems.Length != 0, "Must have at least one item."); Contract.ThrowIfFalse(filteredItems.Length != 0, "Must have at least one filtered item."); Contract.ThrowIfFalse(filteredItems.Contains(selectedItem) || defaultSuggestionModeItem == selectedItem, "Selected item must be in filtered items."); _disconnectedBufferGraph = disconnectedBufferGraph; this.OriginalList = originalList; this.TotalItems = totalItems; this.FilteredItems = filteredItems; this.FilterState = filterState; this.SelectedItem = selectedItem; this.CompletionItemFilters = completionItemFilters; this.CompletionItemToFilterText = completionItemToFilterText; this.IsHardSelection = isHardSelection; this.IsUnique = isUnique; this.UseSuggestionMode = useSuggestionMode; this.SuggestionModeItem = suggestionModeItem; this.DefaultSuggestionModeItem = defaultSuggestionModeItem; this.Trigger = trigger; this.CommitTrackingSpanEndPoint = commitSpanEndPoint; this.DismissIfEmpty = dismissIfEmpty; }
public static SyntaxNode GetAnyCallNodeAboveTriggerPoint(ITrackingPoint triggerPoint, ITextSnapshot snapshot, SyntaxTree parseTree) { Contract.Requires(snapshot != null); Contract.Requires(parseTree != null); Contract.Requires(triggerPoint != null); SyntaxNode syntaxRoot; if (!parseTree.TryGetRoot(out syntaxRoot)) return null; var leafNode = syntaxRoot.FindToken(triggerPoint.GetPosition(snapshot), false); if (leafNode.IsKind(SyntaxKind.None)) return null; //Is anyone in our ancestry a call node? var nodeInQuestion = leafNode.Parent; SyntaxNode ptn = null; while (nodeInQuestion != null) { //Is the node in question a node call? var asCall = nodeInQuestion as InvocationExpressionSyntax; if (asCall != null) { ptn = asCall; break; } var asCtorCall = nodeInQuestion as ObjectCreationExpressionSyntax; if (asCtorCall != null) { ptn = asCtorCall; break; } //Climb higher up our ancestry for the next iteration nodeInQuestion = nodeInQuestion.Parent; } //Did we successfully find a call node? return ptn; }
private Model( Document triggerDocument, DisconnectedBufferGraph disconnectedBufferGraph, CompletionList originalList, ImmutableArray<CompletionItem> filteredItems, CompletionItem selectedItem, ImmutableArray<CompletionItemFilter> completionItemFilters, ImmutableDictionary<CompletionItemFilter, bool> filterState, string filterText, bool isHardSelection, bool isUnique, bool useSuggestionMode, CompletionItem suggestionModeItem, CompletionTrigger trigger, ITrackingPoint commitSpanEndPoint, bool dismissIfEmpty) { Contract.ThrowIfFalse(originalList.Items.Length != 0, "Must have at least one item."); Contract.ThrowIfNull(selectedItem); this.TriggerDocument = triggerDocument; _disconnectedBufferGraph = disconnectedBufferGraph; this.OriginalList = originalList; this.FilteredItems = filteredItems; this.FilterState = filterState; this.SelectedItem = selectedItem; this.CompletionItemFilters = completionItemFilters; this.FilterText = filterText; this.IsHardSelection = isHardSelection; this.IsUnique = isUnique; this.Trigger = trigger; this.CommitTrackingSpanEndPoint = commitSpanEndPoint; this.DismissIfEmpty = dismissIfEmpty; this.UseSuggestionMode = useSuggestionMode; this.SuggestionModeItem = suggestionModeItem ?? CreateDefaultSuggestionModeItem(); }
public MockTrackingSpan(MockTextSnapshot snapshot, int start, int length, SpanTrackingMode trackingMode = SpanTrackingMode.EdgeExclusive) { _start = start; _length = length; _snapshot = snapshot; _trackingMode = trackingMode; switch(_trackingMode) { case SpanTrackingMode.EdgeExclusive: _startPoint = new MockTrackingPoint(snapshot, start, PointTrackingMode.Positive); _endPoint = new MockTrackingPoint(snapshot, start + length, PointTrackingMode.Negative); break; case SpanTrackingMode.EdgeInclusive: _startPoint = new MockTrackingPoint(snapshot, start, PointTrackingMode.Negative); _endPoint = new MockTrackingPoint(snapshot, start + length, PointTrackingMode.Positive); break; case SpanTrackingMode.EdgeNegative: _startPoint = new MockTrackingPoint(snapshot, start, PointTrackingMode.Negative); _endPoint = new MockTrackingPoint(snapshot, start + length, PointTrackingMode.Negative); break; case SpanTrackingMode.EdgePositive: _startPoint = new MockTrackingPoint(snapshot, start, PointTrackingMode.Positive); _endPoint = new MockTrackingPoint(snapshot, start + length, PointTrackingMode.Positive); break; } }
/// <summary> /// Gets a CompletionList providing a list of possible members the user can dot through. /// </summary> internal static CompletionAnalysis GetCompletions(IServiceProvider serviceProvider, ITextSnapshot snapshot, ITrackingSpan span, ITrackingPoint point, CompletionOptions options) { return TrySpecialCompletions(serviceProvider, snapshot, span, point, options) ?? GetNormalCompletionContext(serviceProvider, snapshot, span, point, options); }
private static bool IsSpaceCompletion(ITextSnapshot snapshot, ITrackingPoint loc) { var pos = loc.GetPosition(snapshot); if (pos > 0) { return snapshot.GetText(pos - 1, 1) == " "; } return false; }
private static CompletionAnalysis GetNormalCompletionContext(IServiceProvider serviceProvider, ITextSnapshot snapshot, ITrackingSpan applicableSpan, ITrackingPoint point, CompletionOptions options) { var span = applicableSpan.GetSpan(snapshot); if (IsSpaceCompletion(snapshot, point) && !IntellisenseController.ForceCompletions) { return CompletionAnalysis.EmptyCompletionContext; } var parser = new ReverseExpressionParser(snapshot, snapshot.TextBuffer, applicableSpan); if (parser.IsInGrouping()) { options = options.Clone(); options.IncludeStatementKeywords = false; } return new NormalCompletionAnalysis( snapshot.TextBuffer.GetAnalyzer(serviceProvider), snapshot, applicableSpan, snapshot.TextBuffer, options, serviceProvider ); }
private static CompletionAnalysis TrySpecialCompletions(IServiceProvider serviceProvider, ITextSnapshot snapshot, ITrackingSpan span, ITrackingPoint point, CompletionOptions options) { var snapSpan = span.GetSpan(snapshot); var buffer = snapshot.TextBuffer; var classifier = buffer.GetPythonClassifier(); if (classifier == null) { return null; } var parser = new ReverseExpressionParser(snapshot, buffer, span); var statementRange = parser.GetStatementRange(); if (!statementRange.HasValue) { statementRange = snapSpan.Start.GetContainingLine().Extent; } if (snapSpan.Start < statementRange.Value.Start) { return null; } var tokens = classifier.GetClassificationSpans(new SnapshotSpan(statementRange.Value.Start, snapSpan.Start)); if (tokens.Count > 0) { // Check for context-sensitive intellisense var lastClass = tokens[tokens.Count - 1]; if (lastClass.ClassificationType == classifier.Provider.Comment) { // No completions in comments return CompletionAnalysis.EmptyCompletionContext; } else if (lastClass.ClassificationType == classifier.Provider.StringLiteral) { // String completion if (lastClass.Span.Start.GetContainingLine().LineNumber == lastClass.Span.End.GetContainingLine().LineNumber) { return new StringLiteralCompletionList(span, buffer, options); } else { // multi-line string, no string completions. return CompletionAnalysis.EmptyCompletionContext; } } else if (lastClass.ClassificationType == classifier.Provider.Operator && lastClass.Span.GetText() == "@") { if (tokens.Count == 1) { return new DecoratorCompletionAnalysis(span, buffer, options); } // TODO: Handle completions automatically popping up // after '@' when it is used as a binary operator. } else if (CompletionAnalysis.IsKeyword(lastClass, "def")) { return new OverrideCompletionAnalysis(span, buffer, options); } // Import completions var first = tokens[0]; if (CompletionAnalysis.IsKeyword(first, "import")) { return ImportCompletionAnalysis.Make(tokens, span, buffer, options); } else if (CompletionAnalysis.IsKeyword(first, "from")) { return FromImportCompletionAnalysis.Make(tokens, span, buffer, options); } else if (CompletionAnalysis.IsKeyword(first, "raise") || CompletionAnalysis.IsKeyword(first, "except")) { if (tokens.Count == 1 || lastClass.ClassificationType.IsOfType(PythonPredefinedClassificationTypeNames.Comma) || (lastClass.IsOpenGrouping() && tokens.Count < 3)) { return new ExceptionCompletionAnalysis(span, buffer, options); } } return null; } else if ((tokens = classifier.GetClassificationSpans(snapSpan.Start.GetContainingLine().ExtentIncludingLineBreak)).Count > 0 && tokens[0].ClassificationType == classifier.Provider.StringLiteral) { // multi-line string, no string completions. return CompletionAnalysis.EmptyCompletionContext; } else if (snapshot.IsReplBufferWithCommand()) { return CompletionAnalysis.EmptyCompletionContext; } return null; }