Condividi tramite


ITextDocumentSnapshot Interface

Definition

Provides read access to an immutable version of a document in the file system, in memory in this process, or remoted from the host Visual Studio.

public interface ITextDocumentSnapshot : Microsoft.VisualStudio.Extensibility.Editor.IEditable<Microsoft.VisualStudio.Extensibility.Editor.ITextDocumentEditor>
type ITextDocumentSnapshot = interface
    interface IEditable<ITextDocumentEditor>
Public Interface ITextDocumentSnapshot
Implements IEditable(Of ITextDocumentEditor)
Implements

Remarks

ITextDocumentSnapshot represents a document at a point in time and does not change. Most IDE features will be invoked with an ITextDocumentSnapshot with the state of the document when the feature was invoked.

Some advanced scenarios may benefit from caching results computed against previous ITextDocumentSnapshot versions. To facilitate such caching, ITextDocumentSnapshot supports 'translating' positions and ranges on a document between versions using TranslateTo(ITextDocumentSnapshot, TextRangeTrackingMode) and TranslateTo(ITextDocumentSnapshot, TextPositionTrackingMode), respectively.

ITextDocumentSnapshot is not directly mutable. Any changes must be requested via EditorExtensibility.EditAsync(Action<IEditBatch>, System.Threading.CancellationToken).

Properties

IsDirty

Determines whether the ITextDocumentSnapshot is dirty.

Item[Int32]

Gets a single character at the specified position.

Length

Gets the number of UTF-16 characters contained in the document.

Lines

Gets a collection of lines in this version of the document.

RpcContract

Converts this thick object to a serializable representation for use in an RPC call.

Text

Gets a TextRange for the current text of the document.

Uri

The Uri of the file. Most frequently the name and path of the file on disk.

Methods

AsEditable(IEditBatch)

Gets an interface with methods for requesting changes to the underlying IEditable<TEditor> object.

(Inherited from IEditable<TEditor>)
GetEditorOptionValueAsync<T>(TextDocumentOption<T>, CancellationToken)

Gets an editor option value based on the current text document scope.

GetLineFromPosition(Int32)

Gets an ITextDocumentSnapshotLine for a line at the given position.

GetLineNumberFromPosition(Int32)

Gets the number of the line that contains the character at the specified position.

TranslatePositionTo(TextPosition, TextPositionTrackingMode)

Translates a TextPosition forward or backward in time to this ITextDocumentSnapshot's version.

TranslateRangeTo(TextRange, TextRangeTrackingMode)

Translates a TextRange forward or backward in time to this ITextDocumentSnapshot's version.

Applies to