RangeLineCommenter Class
Represents an object that can comment and uncomment lines over a particular range.
public class RangeLineCommenter : ILineCommenter
- Inheritance:
- object object
- Derived:
- XmlLineCommenter
- Implements:
- ILineCommenter
Remarks
The StartDelimiter and EndDelimiter properties are both required.
The start delimiter is added/removed from the start of the range. The end delimiter is added/removed from the end of the range.
Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language for the ILineCommenter interface type, its features can be used by the language.
Constructors
RangeLineCommenter()
Initializes an instance of the class.
public RangeLineCommenter()
Properties
CommentTokenId
Gets or sets the comment token ID.
public int? CommentTokenId { get; set; }
Property Value
- int?:
The comment token ID.
Remarks
If a token ID is specified for the comment, it can be used to help locate a surrounding comment when uncommenting.
EndDelimiter
Gets or sets the end delimiter text that is added or removed during comment/uncomment operations.
public string EndDelimiter { get; set; }
Property Value
- string:
The end delimiter text that is added or removed during comment/uncomment operations.
Remarks
For instance, in XML
the end delimiter would be -->
.
StartDelimiter
Gets or sets the start delimiter text that is added or removed during comment/uncomment operations.
public string StartDelimiter { get; set; }
Property Value
- string:
The start delimiter text that is added or removed during comment/uncomment operations.
Remarks
For instance, in XML
the start delimiter would be <!--
.
Methods
Comment(ITextSnapshot, ITextPositionRangeCollection, ITextChangeOptions)
Comments out the lines of code in the specified position ranges.
public virtual void Comment(ITextSnapshot snapshot, ITextPositionRangeCollection positionRanges, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The target ITextSnapshot. |
positionRanges | ITextPositionRangeCollection | The ITextPositionRangeCollection indicating the position ranges over which to comment lines. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |
FindCommentTextRange(TextSnapshotRange)
Returns the full text range of the comment that surrounds the specified snapshot range, if any.
protected virtual TextRange? FindCommentTextRange(TextSnapshotRange snapshotRange)
Parameter | Type | Description |
---|---|---|
snapshotRange | TextSnapshotRange | The TextSnapshotRange to examine. |
Returns
- TextRange?:
The full text range of the comment that surrounds the specified snapshot range, if any.
Uncomment(ITextSnapshot, ITextPositionRangeCollection, ITextChangeOptions)
Uncomments the lines of code in the specified position ranges.
public virtual void Uncomment(ITextSnapshot snapshot, ITextPositionRangeCollection positionRanges, ITextChangeOptions options)
Parameter | Type | Description |
---|---|---|
snapshot | ITextSnapshot | The target ITextSnapshot. |
positionRanges | ITextPositionRangeCollection | The ITextPositionRangeCollection indicating the position ranges over which to uncomment lines. |
options | ITextChangeOptions | The ITextChangeOptions for the change. |