IEditorHostService.CreatePositionAsync Method

Definition

Overloads

CreatePositionAsync(VersionedTextDocumentPositionContract, CancellationToken)

Creates a new TextPosition from a serializable Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract RPC contract and other version metadata.

CreatePositionAsync(Uri, Int32, TextPositionContract, CancellationToken)

Creates a new TextPosition from a serializable Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract RPC contract and other version metadata.

CreatePositionAsync(VersionedTextDocumentPositionContract, CancellationToken)

Creates a new TextPosition from a serializable Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract RPC contract and other version metadata.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.TextPosition> CreatePositionAsync (Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract textDocumentPosition, System.Threading.CancellationToken cancellationToken);
abstract member CreatePositionAsync : Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.TextPosition>
Public Function CreatePositionAsync (textDocumentPosition As VersionedTextDocumentPositionContract, cancellationToken As CancellationToken) As Task(Of TextPosition)

Parameters

textDocumentPosition
Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract

The Microsoft.VisualStudio.RpcContracts.Utilities.VersionedTextDocumentPositionContract to realize into TextPosition.

cancellationToken
CancellationToken

Cancels the request.

Returns

A ITextDocumentSnapshot thick object that can be used to interact with the text of the span in the document.

Remarks

This overload potentially forces a load of the document if it's not yet open, accessible via Document. Since this is potentially expensive, it's recommended that you only create TextPositions when you actually need to view the content of the document and not just the range.

Applies to

CreatePositionAsync(Uri, Int32, TextPositionContract, CancellationToken)

Creates a new TextPosition from a serializable Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract RPC contract and other version metadata.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.TextPosition> CreatePositionAsync (Uri documentUri, int version, Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract position, System.Threading.CancellationToken cancellationToken);
abstract member CreatePositionAsync : Uri * int * Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Extensibility.Editor.TextPosition>
Public Function CreatePositionAsync (documentUri As Uri, version As Integer, position As TextPositionContract, cancellationToken As CancellationToken) As Task(Of TextPosition)

Parameters

documentUri
Uri

The Uri of the document.

version
Int32

The version number to create the span on.

position
Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract

The Microsoft.VisualStudio.RpcContracts.Utilities.TextPositionContract to realize into a TextPosition.

cancellationToken
CancellationToken

Cancels the request.

Returns

A TextPosition thick object that can be used to interact with the text of the span in the document.

Remarks

This overload potentially forces a load of the document if it's not yet open, accessible via Document. Since this is potentially expensive, it's recommend that you only create TextRanges when you actually need to view the content of the document and not just the range.

Applies to