In This Article

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
Derived:
CSharpIndentProvider JavaScriptIndentProvider JsonIndentProvider PythonIndentProvider
Implements:
IIndentProvider IEditorDocumentTextChangeEventSink

Constructors

DelimiterIndentProvider()

Initializes an instance of the class.

public DelimiterIndentProvider()

Properties

CanAutoIndentCurlyBraces

Indicates 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 is true.

CanAutoIndentSquareBraces

Indicates 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 is false.

CloseCurlyBraceTokenId

Indicates the optional token ID value used to ensure that a close curly brace character is valid.

public int? CloseCurlyBraceTokenId { get; set; }

Property Value

int?

Remarks

Leave the value null if token validation is not required for curly braces.

CloseDelimiterIndentLevel

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

The optional token ID value used to ensure that a close square brace character is valid.

public int? CloseSquareBraceTokenId { get; set; }

Property Value

int?

Remarks

Leave the value null if token validation is not required for square braces.

Mode

The IndentMode that specifies the mode by which to indent text.

public virtual IndentMode Mode { get; }

Property Value

IndentMode

OpenCurlyBraceTokenId

The optional token ID value used to ensure that an open curly brace character is valid.

public int? OpenCurlyBraceTokenId { get; set; }

Property Value

int?

Remarks

Leave the value null if token validation is not required for curly braces.

OpenSquareBraceTokenId

The optional token ID value used to ensure that an open square brace character is valid.

public int? OpenSquareBraceTokenId { get; set; }

Property Value

int?

Remarks

Leave the value null if token validation is not required for square braces.

Methods

GetIndentAmount(TextSnapshotOffset, int)

The IndentMode that specifies the mode by which to indent text.

public virtual int GetIndentAmount(TextSnapshotOffset snapshotOffset, int defaultAmount)
Parameter Type Description
snapshotOffset TextSnapshotOffset
defaultAmount int

Returns

int

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

bool:

true if the IToken represents the specified end delimiter; otherwise, false.

Remarks

The default implementation of this method compares the token ID to those specified in the CloseCurlyBraceTokenId and CloseSquareBraceTokenId properties. 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

bool:

true if the IToken represents the specified start delimiter; otherwise, false.

Remarks

The default implementation of this method compares the token ID to those specified in the OpenCurlyBraceTokenId and OpenSquareBraceTokenId properties. 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 EditorSnapshotChangedEventArgs that contains the event data.

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 EditorSnapshotChangingEventArgs that contains the event data.

Inherited Members

Extension Methods