Sdílet prostřednictvím


Source.CommentSpan(TextSpan) Method

Definition

Comments out the specified span of source.

public:
 virtual Microsoft::VisualStudio::TextManager::Interop::TextSpan CommentSpan(Microsoft::VisualStudio::TextManager::Interop::TextSpan span);
public:
 virtual Microsoft::VisualStudio::TextManager::Interop::TextSpan CommentSpan(Microsoft::VisualStudio::TextManager::Interop::TextSpan span);
 virtual Microsoft::VisualStudio::TextManager::Interop::TextSpan CommentSpan(Microsoft::VisualStudio::TextManager::Interop::TextSpan span);
public virtual Microsoft.VisualStudio.TextManager.Interop.TextSpan CommentSpan (Microsoft.VisualStudio.TextManager.Interop.TextSpan span);
abstract member CommentSpan : Microsoft.VisualStudio.TextManager.Interop.TextSpan -> Microsoft.VisualStudio.TextManager.Interop.TextSpan
override this.CommentSpan : Microsoft.VisualStudio.TextManager.Interop.TextSpan -> Microsoft.VisualStudio.TextManager.Interop.TextSpan
Public Overridable Function CommentSpan (span As TextSpan) As TextSpan

Parameters

span
TextSpan

A TextSpan object describing the span of source to comment out.

Returns

A new TextSpan object encompassing the entire commented out span, including any comment start and end strings.

Remarks

This method determines how best to comment out the span by deciding between line and block comments, and then calls the CommentBlock or CommentLines methods on the span. Call the GetCommentFormat method to obtain the strings that define a comment.

The base method calls the GetCommentFormat method, and then calls the CommentLines method if the line comment string is specified; otherwise, calls the CommentBlock method if the block comment strings are specified. Note that this approach always uses line comments if both line comment and block comment strings are specified -- even when commenting out a block of text.

This method is typically called in response to the user selecting the command Comment Selection from the Advanced menu on the Edit menu.

See Commenting Code in a Legacy Language Service for more information on this method is used.

Applies to