Skip to content

Commit def3c10

Browse files
committed
edit pass: visual-studio-editor
1 parent 13a8cd6 commit def3c10

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

docs/extensibility/visualstudio.extensibility/editor/editor-concepts.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ The Visual Studio editor extensibility object model is composed of a few integra
1818

1919
## ITextViewSnapshot
2020

21-
The [ITextViewSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) parameter contains the URI and version information necessary to acquire an [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) parameter and some properties of the text view, such as selections.
21+
The [ITextViewSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) class contains the URI and version information necessary to acquire an [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) class and some properties of the text view, such as selections.
2222

2323
- This object is immutable and never changes after it's created.
2424
- You can use `ITextViewSnapshot.GetTextDocumentAsync()` to get the content from the document. Calling this method is expensive, and you should do it only if you need the document content.
25-
- The `ITextViewSnapshot` parameter can't be changed directly. All changes are requested via mutation. For more information, see [Make changes in a text document from an extension](./walkthroughs/editing-text.md).
25+
- The `ITextViewSnapshot` class can't be changed directly. All changes are requested via mutation. For more information, see [Make changes in a text document from an extension](./walkthroughs/editing-text.md).
2626

2727
## ITextDocumentSnapshot
2828

29-
The [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) parameter contains the content of the text document from a point in time or version.
29+
The [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) class contains the content of the text document from a point in time or version.
3030

3131
- This object is immutable and never changes after it's created.
32-
- The `ITextDocumentSnapshot` parameter can't be changed directly. All changes are requested via mutation. For more information, see [Make changes in a text document from an extension](./walkthroughs/editing-text.md).
32+
- The `ITextDocumentSnapshot` class can't be changed directly. All changes are requested via mutation. For more information, see [Make changes in a text document from an extension](./walkthroughs/editing-text.md).
3333

3434
If you're familiar with legacy Visual Studio extensions, [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) is almost the same as
3535
[ITextSnapshot](/dotnet/api/microsoft.visualstudio.text.itextsnapshot) and supports most of the same methods for accessing the text.
@@ -40,24 +40,24 @@ If you're familiar with legacy Visual Studio extensions, [ITextDocumentSnapshot]
4040
- Use the indexer syntax, `textDocument[0]`, to read character by character in the document without copying it to a string.
4141
- If you must create a string, such as for use as a dictionary key, use the overload that takes a `Range` to avoid creating a large throwaway string from the entire line or document.
4242
- Avoid the assumption that lines or documents are short. Many languages minify into huge lines or consume large files.
43-
- The [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) parameter references large data structures that might consume memory if an old-enough version is stored. Best practice is to periodically update positions and ranges that you're storing long term to the latest document version via their `TranslateTo()` method so that the old `ITextDocumentSnapshot` version can be collected as garbage.
43+
- The [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) class references large data structures that might consume memory if an old-enough version is stored. Best practice is to periodically update positions and ranges that you're storing long term to the latest document version via their `TranslateTo()` method so that the old `ITextDocumentSnapshot` version can be garbage collected.
4444

4545
## Position
4646

47-
The [TextPosition](/dotnet/api/microsoft.visualstudio.extensibility.editor.textposition) parameter represents a position within the text document. As opposed to `int` positions, the `TextPosition` type is aware of the [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) parameter that it came from and supports `GetChar()` to get the character directly at that point.
47+
The [TextPosition](/dotnet/api/microsoft.visualstudio.extensibility.editor.textposition) class represents a position within the text document. As opposed to `int` positions, the `TextPosition` type is aware of the [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) class that it came from and supports `GetChar()` to get the character directly at that point.
4848

4949
If you're familiar with legacy Visual Studio extensions, `TextPosition` is almost the same as [SnapshotPoint](/dotnet/api/microsoft.visualstudio.text.snapshotpoint) and supports most of the same methods.
5050

5151
## Range
5252

53-
The [TextRange](/dotnet/api/microsoft.visualstudio.extensibility.editor.textrange) parameter represents a contiguous substring of characters within an [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) parameter. As opposed to a string created with `string.Substring()` or `ITextDocumentSnapshot.CopyToString()`, creating a `TextRange` parameter doesn't require any allocations or extra memory. Later, you can call [CopyToString()](/dotnet/api/microsoft.visualstudio.extensibility.editor.textextensions.copytostring) to realize it into a string in a deferred fashion.
53+
The [TextRange](/dotnet/api/microsoft.visualstudio.extensibility.editor.textrange) class represents a contiguous substring of characters within an [ITextDocumentSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextdocumentsnapshot) class. As opposed to a string created with `string.Substring()` or `ITextDocumentSnapshot.CopyToString()`, creating a `TextRange` class doesn't require any allocations or extra memory. Later, you can call [CopyToString()](/dotnet/api/microsoft.visualstudio.extensibility.editor.textextensions.copytostring) to realize it into a string in a deferred fashion.
5454

5555
If you're familiar with legacy Visual Studio extensions, `TextRange` is almost the same as
5656
[SnapshotSpan](/dotnet/api/microsoft.visualstudio.text.snapshotSpan) and supports most of the same methods.
5757

5858
## Tracking modes
5959

60-
The `TextPosition` and `TextRange` parameters are associated with a specific `ITextDocumentSnapshot` parameter, which is the state of the document at a specific time. You can use the `TranslateTo` methods to translate such positions and ranges to a different snapshot. Such translation takes into account any text that was added or removed before, after (or, in the case of ranges, in the middle of) the position or range. When any of these edits happen exactly at the position or exactly at the edge of the range, [TextPositionTrackingMode](/dotnet/api/microsoft.visualstudio.extensibility.editor.textpositiontrackingmode) and [TextRangeTrackingMode](/dotnet/api/microsoft.visualstudio.extensibility.editor.textrangetrackingmode) are used to specify how the translation should behave.
60+
The `TextPosition` and `TextRange` classs are associated with a specific `ITextDocumentSnapshot` class, which is the state of the document at a specific time. You can use the `TranslateTo` methods to translate such positions and ranges to a different snapshot. Such translation takes into account any text that was added or removed before, after (or, in the case of ranges, in the middle of) the position or range. When any of these edits happen exactly at the position or exactly at the edge of the range, [TextPositionTrackingMode](/dotnet/api/microsoft.visualstudio.extensibility.editor.textpositiontrackingmode) and [TextRangeTrackingMode](/dotnet/api/microsoft.visualstudio.extensibility.editor.textrangetrackingmode) are used to specify how the translation should behave.
6161

6262
## Tag
6363

docs/extensibility/visualstudio.extensibility/editor/editor-rpc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To facilitate interactions with RPC services, the object model exposes [RpcContr
2525
- `TextView`: 1:1 serialized form of `ITextView`, which you can access through the `RpcContract` property.
2626
- `TextDocument`: 1:1 serialized form of `ITextDocument` through the `RpcContract` property.
2727

28-
As opposed to `VersionedTextDocumentRange` and `VersionedTextDocumentPosition`, `Range` and `Microsoft.VisualStudio.RpcContracts.Utilities.Position` omit the URI and document version, which makes for a smaller serializable representation. Use this type in RPC contracts that contain lots of span or range equivalents that need to reduce their payload size for performance. These RPC contracts need to pass the document URI and version for the spans or range to be instantiated into `Span` and `Position` objects by [IEditorHostService](/dotnet/api/microsoft.visualstudio.extensibility.editor.ieditorhostservice). The `IEditorHostService` parameter interfaces with extension-local copies of the text buffer and manages the opening and closing of documents described by the RPC types.
28+
As opposed to `VersionedTextDocumentRange` and `VersionedTextDocumentPosition`, `Range` and `Microsoft.VisualStudio.RpcContracts.Utilities.Position` omit the URI and document version, which makes for a smaller serializable representation. Use this type in RPC contracts that contain lots of span or range equivalents that need to reduce their payload size for performance. These RPC contracts need to pass the document URI and version for the spans or range to be instantiated into `Span` and `Position` objects by [IEditorHostService](/dotnet/api/microsoft.visualstudio.extensibility.editor.ieditorhostservice). The `IEditorHostService` interfaces with extension-local copies of the text buffer and manages the opening and closing of documents described by the RPC types.
2929

3030
## Related content
3131

docs/extensibility/visualstudio.extensibility/editor/editor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following sections summarize the high-level editor extensibility scenarios t
2727

2828
The most fundamental extensibility point for the Visual Studio editor is to manipulate text, either by reading the text in the editor or editing the text. These scenarios are core to any editor-based extensions. For example, to provide diagnostics information, such as warnings or errors, the extension must read the code in the editor and then interpret it. An extension also needs a way to detect when the text in the editor changed, if a new file opened, or if an open file closed.
2929

30-
For a walkthrough of how to make read-text and track-text changes by using `VisualStudio.Extensibility`, see [Work with text in the editor](./walkthroughs/working-with-text.md).
30+
For a walkthrough of how to make read text and track text changes by using `VisualStudio.Extensibility`, see [Work with text in the editor](./walkthroughs/working-with-text.md).
3131

3232
## Make edits to text in the editor
3333

docs/extensibility/visualstudio.extensibility/editor/walkthroughs/taggers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ ms.subservice: extensibility-integration
1414

1515
Extensions can contribute new taggers to Visual Studio. Taggers are used to associate data with ranges of text. Then other Visual Studio features (for example, [CodeLens](./codelens.md)) can consume the data that the taggers provided.
1616

17-
`VisualStudio.Extensibility` supports tag types that are only provided by the [Microsoft.VisualStudio.Extensibility](https://www.nuget.org/packages/Microsoft.VisualStudio.Extensibility) package and implement the `Microsoft.VisualStudio.Extensibility.Editor.ITag` interface:
17+
`VisualStudio.Extensibility` supports tag types that are only provided by the [Microsoft.VisualStudio.Extensibility](https://www.nuget.org/packages/Microsoft.VisualStudio.Extensibility) package and implement the [ITag](/dotnet/api/microsoft.visualstudio.extensibility.editor.itag) interface:
1818

19-
- `CodeLensTag` is used together with an [ICodeLensProvider](./codelens.md) to add CodeLens to documents.
20-
- `TextMarkerTag` is used to highlight portions of documents. `VisualStudio.Extensibility` doesn't support defining new Text Marker styles yet. For now, you can use only styles that are built into Visual Studio or provided by a Visual Studio SDK extension. (A [VisualStudio.Extensibility in-proc extension](../../get-started/in-proc-extensions.md) can create Text Marker styles with an `[Export(typeof(EditorFormatDefinition))]` parameter.)
19+
- `CodeLensTag` is used together with an [ICodeLensProvider](./codelens.md) to add CodeLens to documents. `TextMarkerTag` and `ClassificationTag` can also be linked to the API documents.
20+
- `TextMarkerTag` is used to highlight portions of documents. `VisualStudio.Extensibility` doesn't support defining new Text Marker styles yet. For now, you can use only styles that are built into Visual Studio or provided by a Visual Studio SDK extension. (A [VisualStudio.Extensibility in-proc extension](../../get-started/in-proc-extensions.md) can create Text Marker styles with `[Export(typeof(EditorFormatDefinition))]`.)
2121
- `ClassificationTag` is used to classify a document's syntax, which allows for the text to be colorized accordingly.
2222

2323
To generate tags, the extension must contribute an extension part that implements `ITextViewTaggerProvider<>` for the type (or types) of tags provided. The extension part also needs to implement `ITextViewChangedListener` to react to document changes:

docs/extensibility/visualstudio.extensibility/editor/walkthroughs/working-with-text.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ When you run your extension, you should see:
6464
- [ITextViewOpenClosedListener.TextViewClosedAsync](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewopenclosedlistener.textviewclosedasync) called any time that a user closes a text view.
6565
- [ITextViewChangedListener.TextViewChangedAsync](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewchangedlistener.textviewchangedasync) called any time that a user makes a text change to a text document that a text view displays.
6666

67-
Each of these methods is passed an [ITextViewSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) parameter that contains the state of the text view and text document at the time that the user invoked the action and a `CancellationToken` that has `IsCancellationRequested == true` when the integrated development environment (IDE) wants to cancel a pending action.
67+
Each of these methods is passed an [ITextViewSnapshot](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) class that contains the state of the text view and text document at the time that the user invoked the action and a `CancellationToken` that has `IsCancellationRequested == true` when the integrated development environment (IDE) wants to cancel a pending action.
6868

6969
## Define when your extension is relevant
7070

@@ -92,7 +92,7 @@ Document types are hierarchical. That is, C# and C++ both descend from `code`, s
9292

9393
You can define a new document type, for example, to support a custom code language, by adding a static [DocumentTypeConfiguration](/dotnet/api/microsoft.visualstudio.extensibility.editor.documenttypeconfiguration) property to any class in the extension project. Then mark the property with the [`VisualStudioContribution`](/dotnet/api/microsoft.visualstudio.extensibility.visualstudiocontributionattribute) attribute.
9494

95-
You can use the `DocumentTypeConfiguration` parameter to define a new document type, specify that it inherits one or more other document types, and specify one or more file extensions that are used to identify the file type.
95+
You can use `DocumentTypeConfiguration` to define a new document type, specify that it inherits one or more other document types, and specify one or more file extensions that are used to identify the file type.
9696

9797
```csharp
9898
using Microsoft.VisualStudio.Extensibility.Editor;
@@ -144,7 +144,7 @@ public sealed class TextViewOperationListener
144144
};
145145
```
146146

147-
The `pattern` parameter represents a glob pattern that's matched on the absolute path of the document.
147+
The pattern represents a glob pattern that's matched on the absolute path of the document.
148148

149149
Glob patterns can have the following syntax:
150150

@@ -167,10 +167,10 @@ EditorExtensibility editorService = this.Extensibility.Editor();
167167
168168
### Access editor state within a command
169169
170-
The `ExecuteCommandAsync()` parameter in each `Command` parameter is passed an `IClientContext` parameter that contains a snapshot of the state of the IDE at the time the command was invoked. You can access the active document via the [`ITextViewSnapshot`](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) interface, which you get from the [`EditorExtensibility`](/dotnet/api/microsoft.visualstudio.extensibility.editor.editorextensibility) object by calling the asynchronous method [`GetActiveTextViewAsync`](/dotnet/api/microsoft.visualstudio.extensibility.editor.editorextensibility.getactivetextviewasync).
170+
The `ExecuteCommandAsync()` method in each `Command` is passed `IClientContext` that contains a snapshot of the state of the IDE at the time the command was invoked. You can access the active document via the [`ITextViewSnapshot`](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) interface, which you get from the [`EditorExtensibility`](/dotnet/api/microsoft.visualstudio.extensibility.editor.editorextensibility) object by calling the asynchronous method [`GetActiveTextViewAsync`](/dotnet/api/microsoft.visualstudio.extensibility.editor.editorextensibility.getactivetextviewasync).
171171
172172
```csharp
173173
using ITextViewSnapshot textView = await this.Extensibility.Editor().GetActiveTextViewAsync(clientContext, cancellationToken);
174174
```
175175
176-
When you have the `ITextViewSnapshot` parameter, you can access the editor state. The [`ITextViewSnapshot`](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) parameter is an immutable view of the editor state at a point in time, so you need to use the other interfaces in the [Editor object model](./../editor-concepts.md) to make edits.
176+
When you have the `ITextViewSnapshot` class, you can access the editor state. The [`ITextViewSnapshot`](/dotnet/api/microsoft.visualstudio.extensibility.editor.itextviewsnapshot) class is an immutable view of the editor state at a point in time, so you need to use the other interfaces in the [Editor object model](./../editor-concepts.md) to make edits.

0 commit comments

Comments
 (0)