In This Article

LineBasedLineCommenter Class

Represents an object that can comment and uncomment lines on a per-line basis.

public class LineBasedLineCommenter : ILineCommenter
Inheritance:
object object
Implements:
ILineCommenter

Remarks

The StartDelimiter is required.

The start delimiter is added/removed from each line in 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

LineBasedLineCommenter()

Initializes an instance of the class.

public LineBasedLineCommenter()

Properties

CanCommentEmptyLines

Gets or sets a value indicating whether to comment empty lines, when the target range includes more than one line.

public bool CanCommentEmptyLines { get; set; }

Property Value

bool:

true if empty lines are to be commented, when the target range includes more than one line; otherwise, false.

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

In C#, 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.

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.

Inherited Members