DelimiterIndentProvider Class
Provides an implementation (generally a base class) for a language indent provider service that can auto-indent curly and/or square braces.
public class DelimiterIndentProvider : IIndentProvider, IEditorDocumentTextChangeEventSink
- Inheritance:
- object object
- Implements:
- IIndentProvider IEditorDocumentTextChangeEventSink
Constructors
DelimiterIndentProvider()
Initializes a new instance of the DelimiterIndentProvider
class.
public DelimiterIndentProvider()
Properties
CanAutoIndentCurlyBraces
Gets or sets whether curly braces can be auto-indented.
public bool CanAutoIndentCurlyBraces { get; set; }
Property Value
- bool:
true
if curly braces can be auto-indented; otherwise,false
. The default value istrue
.
CanAutoIndentSquareBraces
Gets or sets whether square braces can be auto-indented.
public bool CanAutoIndentSquareBraces { get; set; }
Property Value
- bool:
true
if square braces can be auto-indented; otherwise,false
. The default value isfalse
.
CloseCurlyBraceTokenId
Gets or sets the optional token ID value used to ensure that a close curly brace character is valid.
public int? CloseCurlyBraceTokenId { get; set; }
Property Value
- int?:
The optional token ID value used to ensure that a close curly brace character is valid.
Remarks
Leave the value null
if token validation is not required for curly braces.
CloseDelimiterIndentLevel
Gets or sets the additional indent level to apply to close delimiters when auto-indenting them.
public int CloseDelimiterIndentLevel { get; set; }
Property Value
- int:
The additional indent level. The default value is
0
.
Remarks
This property can be set to 1
if the close delimiter should be indented one tab stop beyond normal.
CloseSquareBraceTokenId
Gets or sets the optional token ID value used to ensure that a close square brace character is valid.
public int? CloseSquareBraceTokenId { get; set; }
Property Value
- int?:
The optional token ID value used to ensure that a close square brace character is valid.
Remarks
Leave the value null
if token validation is not required for square braces.
Mode
Gets the IndentMode that specifies the mode by which to indent text.
public virtual IndentMode Mode { get; }
Property Value
- IndentMode:
The IndentMode that specifies the mode by which to indent text.
OpenCurlyBraceTokenId
Gets or sets the optional token ID value used to ensure that an open curly brace character is valid.
public int? OpenCurlyBraceTokenId { get; set; }
Property Value
- int?:
The optional token ID value used to ensure that an open curly brace character is valid.
Remarks
Leave the value null
if token validation is not required for curly braces.
OpenSquareBraceTokenId
Gets or sets the optional token ID value used to ensure that an open square brace character is valid.
public int? OpenSquareBraceTokenId { get; set; }
Property Value
- int?:
The optional token ID value used to ensure that an open square brace character is valid.
Remarks
Leave the value null
if token validation is not required for square braces.
Methods
GetIndentAmount(TextSnapshotOffset, int)
Returns the ideal amount of indent, always in columns, for the line containing the snapshot offset.
public virtual int GetIndentAmount(TextSnapshotOffset snapshotOffset, int defaultAmount)
Parameter | Type | Description |
---|---|---|
snapshotOffset | TextSnapshotOffset | The TextSnapshotOffset whose line should be examined. |
defaultAmount | int | The default indent amount, which is the amount used in |
Returns
- int:
The ideal amount of indent, always in columns, for the line containing the snapshot offset.
Remarks
This method is called when the IndentMode is Smart
.
The containing ITextDocument is accessible via the snapshot range's ITextSnapshot.
IsValidEndDelimiter(IToken, char)
Returns whether an IToken represents the specified end delimiter.
protected virtual bool IsValidEndDelimiter(IToken token, char endDelimiter)
Parameter | Type | Description |
---|---|---|
token | IToken | The IToken to examine. |
endDelimiter | char | The end delimiter. |
Returns
Remarks
The default implementation of this method compares the token ID to the ID specified in the CloseCurlyBraceTokenId property. This method is called when determining whether to perform delimiter auto-indent.
IsValidStartDelimiter(IToken, char)
Returns whether an IToken represents the specified start delimiter.
protected virtual bool IsValidStartDelimiter(IToken token, char startDelimiter)
Parameter | Type | Description |
---|---|---|
token | IToken | The IToken to examine. |
startDelimiter | char | The start delimiter. |
Returns
Remarks
The default implementation of this method compares the token ID to the ID specified in the OpenCurlyBraceTokenId property. This method is called when determining whether to perform delimiter auto-indent.
OnDocumentTextChanged(SyntaxEditor, EditorSnapshotChangedEventArgs)
Occurs after a text change occurs to an IEditorDocument that uses this language.
protected virtual void OnDocumentTextChanged(SyntaxEditor editor, EditorSnapshotChangedEventArgs e)
Parameter | Type | Description |
---|---|---|
editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument is changed. |
e | EditorSnapshotChangedEventArgs | The |
OnDocumentTextChanging(SyntaxEditor, EditorSnapshotChangingEventArgs)
Occurs before a text change occurs to an IEditorDocument that uses this language.
protected virtual void OnDocumentTextChanging(SyntaxEditor editor, EditorSnapshotChangingEventArgs e)
Parameter | Type | Description |
---|---|---|
editor | SyntaxEditor | The SyntaxEditor whose IEditorDocument that is changing. |
e | EditorSnapshotChangingEventArgs | The |