// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Text.Tagging; namespace Microsoft.CodeAnalysis.Editor.Tagging { /// /// Flags that affect how the tagger infrastructure responds to caret changes. /// [Flags] internal enum TaggerCaretChangeBehavior { /// /// No special caret change behavior. /// None = 0, /// /// If the caret moves outside of a tag, immediately remove all existing tags. /// RemoveAllTagsOnCaretMoveOutsideOfTag = 1 << 0, } /// /// Data source for the . This type tells the /// when tags need to be recomputed, as well /// as producing the tags when requested. /// internal interface IAsynchronousTaggerDataSource where TTag : ITag { /// /// The behavior the tagger engine will have when text changes happen to the subject buffer /// it is attached to. Most taggers can simply use . /// However, advanced taggers that want to perform specialized behavior depending on what has /// actually changed in the file can specify . /// /// If this is specified the tagger engine will track text changes and pass them along as /// when calling /// . /// TaggerTextChangeBehavior TextChangeBehavior { get; } /// /// The bahavior the tagger will have when changes happen to the caret. /// TaggerCaretChangeBehavior CaretChangeBehavior { get; } /// /// The behavior of tags that are created by the async tagger. This will matter for tags /// created for a previous version of a document that are mapped forward by the async /// tagging architecture. This value cannot be . /// SpanTrackingMode SpanTrackingMode { get; } /// /// Whether or not the the first set of tags for this tagger should be computed synchronously. /// bool ComputeTagsSynchronouslyIfNoAsynchronousComputationHasCompleted { get; } /// /// Options controlling this tagger. The tagger infrastructure will check this option /// against the buffer it is associated with to see if it should tag or not. /// /// An empty enumerable, or null, can be returned to indicate that this tagger should /// run unconditionally. /// IEnumerable> Options { get; } IEnumerable> PerLanguageOptions { get; } /// /// Comparer used to determine if two s are the same. This is used by /// the to determine if a previous set of /// computed tags and a current set of computed tags should be considered the same or not. /// If they are the same, then the UI will not be updated. If they are different then /// the UI will be updated for sets of tags that have been removed or added. /// /// IEqualityComparer TagComparer { get; } /// /// Creates the that notifies the /// that it should recompute tags for the text buffer after an appropriate . /// ITaggerEventSource CreateEventSource(ITextView textViewOpt, ITextBuffer subjectBuffer); /// /// Called by the infrastructure to /// determine the caret position. This value will be passed in as the value to /// in the call to /// . /// /// Return null to get the default tagger behavior. This will the caret /// position in the subject buffer this tagger is attached to. /// SnapshotPoint? GetCaretPoint(ITextView textViewOpt, ITextBuffer subjectBuffer); /// /// Called by the infrastructure to determine /// the set of spans that it should asynchronously tag. This will be called in response to /// notifications from the that something has changed, and /// will only be called from the UI thread. The tagger infrastructure will then determine /// the s associated with these s /// and will asycnhronously call into at some point in /// the future to produce tags for these spans. /// /// Return null to get the default set of spans tagged. This will normally be /// the span of the entire text buffer. /// IEnumerable GetSpansToTag(ITextView textViewOpt, ITextBuffer subjectBuffer); /// /// Produce tags for the given context. /// Task ProduceTagsAsync(AsynchronousTaggerContext context); } }