/// <summary> /// Parses the body of an element that contains a list of statements as children. /// </summary> /// <param name="parent">The parent of the scope.</param> /// <param name="parentReference">The parent code unit.</param> /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param> /// <returns>Returns the closing curly bracket.</returns> private Node<CsToken> ParseStatementScope(IWriteableCodeUnit parent, Reference<ICodePart> parentReference, bool unsafeCode) { Param.AssertNotNull(parent, "parent"); Param.AssertNotNull(parentReference, "parentReference"); Param.Ignore(unsafeCode); Node<CsToken> closeBracketNode = null; // Keep looping until all the child elements within this container element have been processed. while (true) { // If the next symbol is a closing curly bracket, or we've reached the end of the symbols list, // we're done with this scope. Symbol symbol = this.GetNextSymbol(parentReference); if (symbol == null) { // We've reached the end of the document. break; } else if (symbol.SymbolType == SymbolType.CloseCurlyBracket) { // We've reached the end of the element. Save the closing bracket and exit. Bracket closeBracket = this.GetBracketToken(CsTokenType.CloseCurlyBracket, SymbolType.CloseCurlyBracket, parentReference); closeBracketNode = this.tokens.InsertLast(closeBracket); break; } else { Statement statement = this.GetNextStatement(parentReference, unsafeCode, parent.Variables); if (statement != null) { parent.AddStatement(statement); foreach (Statement attachedStatement in statement.AttachedStatements) { parent.AddStatement(attachedStatement); } } } } return closeBracketNode; }
private Microsoft.StyleCop.Node<CsToken> ParseStatementScope(IWriteableCodeUnit parent, bool unsafeCode) { Microsoft.StyleCop.Node<CsToken> node = null; while (true) { Statement nextStatement; do { Symbol nextSymbol = this.GetNextSymbol(); if (nextSymbol == null) { return node; } if (nextSymbol.SymbolType == SymbolType.CloseCurlyBracket) { Bracket bracketToken = this.GetBracketToken(CsTokenType.CloseCurlyBracket, SymbolType.CloseCurlyBracket); return this.tokens.InsertLast(bracketToken); } nextStatement = this.GetNextStatement(unsafeCode, parent.Variables); } while (nextStatement == null); parent.AddStatement(nextStatement); foreach (Statement statement2 in nextStatement.AttachedStatements) { parent.AddStatement(statement2); } } }