C# Class Microsoft.R.Core.Formatting.RFormatter

Formats R code based on tokenization
Mostrar archivo Open project: Microsoft/RTVS Class Usage Examples

Private Properties

Property Type Description
AppendComma void
AppendCondition void
AppendControlBlock void
AppendKeyword void
AppendNextToken void
AppendOperator void
AppendScopeContent void
AppendStatementsInScope void
AppendTextBeforeToken void
AppendToken void
CloseFormattingScope void
GetSingleLineScopeEnd int
HasSameLineElse bool
IsClosingToken bool
IsConditionalBlock bool
IsControlBlock bool
IsKeywordWithoutSpaces bool
IsOpenBraceToken bool
IsOperatorWithoutSpaces bool
KeepCurlyAndElseTogether bool
LeadingSpaceNeeded bool
OpenFormattingScope void
ShouldAppendTextBeforeToken bool
SoftLineBreak void
Tokenize void

Public Methods

Method Description
Format ( string text ) : string

Format string containing R code

RFormatter ( ) : System.Collections.Generic
RFormatter ( Microsoft.R.Core.Formatting.RFormatOptions options ) : System.Collections.Generic

Private Methods

Method Description
AppendComma ( ) : void
AppendCondition ( ) : void

Formats conditional statement after 'if' or 'while'

AppendControlBlock ( string keyword ) : void
AppendKeyword ( ) : void

Appends keyword and its constructs such as condition that follows 'if' And the following scope controlling indentation as appropriate.

AppendNextToken ( ) : void
AppendOperator ( ) : void
AppendScopeContent ( bool stopAtLineBreak, bool stopAtElse = false ) : void

Iterates over tokens in the current scope and constructs formatted text

AppendStatementsInScope ( string keyword ) : void

Appends statements inside scope that follows control block such as if() { } or a single statement that follows scope-less as in 'if() stmt' conditional.

AppendTextBeforeToken ( bool preserveUserIndent = false ) : void
AppendToken ( bool leadingSpace, bool trailingSpace ) : void
CloseFormattingScope ( ) : void
GetSingleLineScopeEnd ( ) : int

Calculates position of a end of a single-line scope. The simple scope ends at a line break or at opening or closing curly brace.

HasSameLineElse ( ) : bool
IsClosingToken ( RToken token, AstRoot ast = null ) : bool
IsConditionalBlock ( string text ) : bool
IsControlBlock ( string text ) : bool
IsKeywordWithoutSpaces ( string text ) : bool
IsOpenBraceToken ( RTokenType tokenType ) : bool
IsOperatorWithoutSpaces ( string text ) : bool
KeepCurlyAndElseTogether ( ) : bool
LeadingSpaceNeeded ( ) : bool
OpenFormattingScope ( ) : void

Opens new formatting scope. Scope is opened when either code discovers open curly brace or when line break suppression is on.

ShouldAppendTextBeforeToken ( ) : bool
SoftLineBreak ( ) : void
Tokenize ( string text ) : void

Tokenizes provided string that contains R code

Method Details

Format() public method

Format string containing R code
public Format ( string text ) : string
text string
return string

RFormatter() public method

public RFormatter ( ) : System.Collections.Generic
return System.Collections.Generic

RFormatter() public method

public RFormatter ( Microsoft.R.Core.Formatting.RFormatOptions options ) : System.Collections.Generic
options Microsoft.R.Core.Formatting.RFormatOptions
return System.Collections.Generic