3rdparty/NRefactory/ICSharpCode.NRefactory.CSharp/IndentEngine/IndentState.cs
/// <summary>
///     Checks if the given string is a keyword and sets the
///     <see cref="NextBody"/> and the <see cref="CurrentStatement"/>
///     variables appropriately.
/// </summary>
/// <param name="keyword">
///     A possible keyword.
/// </param>
Checks if the given string is a keyword and sets the
and the
variables appropriately.
Checks if the given string is a keyword and sets the and the variables appropriately .
public override void CheckKeyword(string keyword)
		{
			if (bodies.ContainsKey(keyword))
			{
				var isKeywordTemplateConstraint =
					classStructKeywords.Contains(keyword) &&
					(NextBody == Body.Class || NextBody == Body.Struct || NextBody == Body.Interface);
				if (!isKeywordTemplateConstraint)
				{
					NextBody = bodies[keyword];
				}
			}
			else if (caseDefaultKeywords.Contains(keyword) && CurrentBody == Body.Switch && Engine.isLineStartBeforeWordToken)
			{
				ChangeState<SwitchCaseState>();
			}
			else if (keyword == "where" && Engine.isLineStartBeforeWordToken)
			{
				ThisLineIndent.Push(IndentType.Continuation);
			}
			else if (statements.ContainsKey(keyword))
			{
				Statement previousStatement = CurrentStatement;
				CurrentStatement = statements[keyword];
				if (CurrentStatement == Statement.Using &&
				   (this is GlobalBodyState || CurrentBody == Body.Namespace))
				{
					return;
				}
				if (Engine.formattingOptions.AlignEmbeddedStatements &&
					previousStatement == Statement.If &&
					CurrentStatement == Statement.If)
				{
					ThisLineIndent.PopIf(IndentType.Continuation);
					NextLineIndent.PopIf(IndentType.Continuation);
				}
				if (Engine.formattingOptions.AlignEmbeddedStatements &&
					previousStatement == Statement.Lock &&
					CurrentStatement == Statement.Lock)
				{
					ThisLineIndent.PopIf(IndentType.Continuation);
					NextLineIndent.PopIf(IndentType.Continuation);
				}
				if (Engine.formattingOptions.AlignEmbeddedStatements &&
					previousStatement == Statement.Using &&
					CurrentStatement == Statement.Using)
				{
					ThisLineIndent.PopIf(IndentType.Continuation);
					NextLineIndent.PopIf(IndentType.Continuation);
				}
				if (!(CurrentStatement == Statement.If && previousStatement == Statement.Else && !Engine.isLineStartBeforeWordToken))
				{
					NextLineIndent.Push(IndentType.Continuation);
				}
				if (CurrentStatement == Statement.If)
				{
					NestedIfStatementLevels.Push(ThisLineIndent);
				}
			}
			if (blocks.Contains(keyword) && Engine.NeedsReindent)
			{
				LastBlockIndent = Indent.ConvertFrom(Engine.CurrentIndent, ThisLineIndent, Engine.textEditorOptions);
			}
		}
public override void CheckKeyword ( string keyword ) { if ( bodies . ContainsKey ( keyword ) ) { var isKeywordTemplateConstraint = classStructKeywords . Contains ( keyword ) && ( NextBody == Body . Class || NextBody == Body . Struct || NextBody == Body . Interface ) ; if ( ! isKeywordTemplateConstraint ) { NextBody = bodies [ keyword ] ; } } else if ( caseDefaultKeywords . Contains ( keyword ) && CurrentBody == Body . Switch && Engine . isLineStartBeforeWordToken ) { ChangeState < SwitchCaseState > ( ) ; } else if ( keyword == " " && Engine . isLineStartBeforeWordToken ) { ThisLineIndent . Push ( IndentType . Continuation ) ; } else if ( statements . ContainsKey ( keyword ) ) { Statement previousStatement = CurrentStatement ; CurrentStatement = statements [ keyword ] ; if ( CurrentStatement == Statement . Using && ( this is GlobalBodyState || CurrentBody == Body . Namespace ) ) { return ; } if ( Engine . formattingOptions . AlignEmbeddedStatements && previousStatement == Statement . If && CurrentStatement == Statement . If ) { ThisLineIndent . PopIf ( IndentType . Continuation ) ; NextLineIndent . PopIf ( IndentType . Continuation ) ; } if ( Engine . formattingOptions . AlignEmbeddedStatements && previousStatement == Statement . Lock && CurrentStatement == Statement . Lock ) { ThisLineIndent . PopIf ( IndentType . Continuation ) ; NextLineIndent . PopIf ( IndentType . Continuation ) ; } if ( Engine . formattingOptions . AlignEmbeddedStatements && previousStatement == Statement . Using && CurrentStatement == Statement . Using ) { ThisLineIndent . PopIf ( IndentType . Continuation ) ; NextLineIndent . PopIf ( IndentType . Continuation ) ; } if ( ! ( CurrentStatement == Statement . If && previousStatement == Statement . Else && ! Engine . isLineStartBeforeWordToken ) ) { NextLineIndent . Push ( IndentType . Continuation ) ; } if ( CurrentStatement == Statement . If ) { NestedIfStatementLevels . Push ( ThisLineIndent ) ; } } if ( blocks . Contains ( keyword ) && Engine . NeedsReindent ) { LastBlockIndent = Indent . ConvertFrom ( Engine . CurrentIndent , ThisLineIndent , Engine . textEditorOptions ) ; } }
Checks if the given string is a keyword and sets the
and the
variables appropriately.
Checks if the given string is a keyword and sets the and the variables appropriately .
// try to capture where (generic type constraint) // return if this is a using declaration or alias // OPTION: CSharpFormattingOptions.AlignEmbeddedIfStatements // OPTION: CSharpFormattingOptions.AlignEmbeddedStatements // OPTION: CSharpFormattingOptions.AlignEmbeddedUsingStatements // only add continuation for 'else' in 'else if' statement.
keyword
string
A possible keyword.
A possible keyword .