internal CatchStatement(CsTokenList tokens, Microsoft.StyleCop.CSharp.TryStatement tryStatement, Expression classExpression, BlockStatement embeddedStatement)
     : base(StatementType.Catch, tokens)
 {
     this.tryStatement = tryStatement;
     this.catchExpression = classExpression;
     this.embeddedStatement = embeddedStatement;
     if (classExpression != null)
     {
         base.AddExpression(classExpression);
         if (classExpression != null)
         {
             if (classExpression.ExpressionType == ExpressionType.Literal)
             {
                 this.classType = ((LiteralExpression) classExpression).Token as TypeToken;
             }
             else if (classExpression.ExpressionType == ExpressionType.VariableDeclaration)
             {
                 VariableDeclarationExpression expression = (VariableDeclarationExpression) classExpression;
                 this.classType = expression.Type;
                 foreach (VariableDeclaratorExpression expression2 in expression.Declarators)
                 {
                     this.identifier = expression2.Identifier.Text;
                     break;
                 }
             }
         }
     }
     base.AddStatement(embeddedStatement);
 }
 internal FinallyStatement(CsTokenList tokens, Microsoft.StyleCop.CSharp.TryStatement tryStatement, BlockStatement embeddedStatement)
     : base(StatementType.Finally, tokens)
 {
     this.tryStatement = tryStatement;
     this.embeddedStatement = embeddedStatement;
     base.AddStatement(embeddedStatement);
 }
        /// <summary>
        /// Initializes a new instance of the TryStatement class.
        /// </summary>
        /// <param name="embeddedStatement">The statement embedded within this try-statement.</param>
        internal TryStatement(BlockStatement embeddedStatement)
            : base(StatementType.Try)
        {
            Param.AssertNotNull(embeddedStatement, "embeddedStatement");

            this.embeddedStatement = embeddedStatement;
            this.AddStatement(embeddedStatement);
        }
        /// <summary>
        /// Initializes a new instance of the CheckedStatement class.
        /// </summary>
        /// <param name="tokens">The list of tokens that form the statement.</param>
        /// <param name="embeddedStatement">The block statement embedded within this checked statement, if any.</param>
        internal CheckedStatement(CsTokenList tokens, BlockStatement embeddedStatement)
            : base(StatementType.Checked, tokens)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(embeddedStatement, "embeddedStatement");

            this.embeddedStatement = embeddedStatement;
            this.AddStatement(embeddedStatement);
        }
        /// <summary>
        /// Initializes a new instance of the FinallyStatement class.
        /// </summary>
        /// <param name="tokens">The list of tokens that form the statement.</param>
        /// <param name="tryStatement">The try-statement that this finally-statement is embedded to.</param>
        /// <param name="embeddedStatement">The statement embedded within the finally-statement.</param>
        internal FinallyStatement(CsTokenList tokens, TryStatement tryStatement, BlockStatement embeddedStatement)
            : base(StatementType.Finally, tokens)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(tryStatement, "tryStatement");
            Param.AssertNotNull(embeddedStatement, "embeddedStatement");

            this.tryStatement = tryStatement;
            this.embeddedStatement = embeddedStatement;

            this.AddStatement(embeddedStatement);
        }
 internal UnsafeStatement(CsTokenList tokens, BlockStatement embeddedStatement)
     : base(StatementType.Unsafe, tokens)
 {
     this.embeddedStatement = embeddedStatement;
     base.AddStatement(embeddedStatement);
 }
        /// <summary>
        /// Reads the next block statement from the file and returns it.
        /// </summary>
        /// <param name="unsafeCode">Indicates whether the code being parsed resides in an unsafe code block.</param>
        /// <returns>Returns the statement.</returns>
        private BlockStatement ParseBlockStatement(bool unsafeCode)
        {
            Param.Ignore(unsafeCode);

            var statementReference = new Reference<ICodePart>();

            // Get the opening bracket keyword.
            Bracket openingBracket = this.GetBracketToken(CsTokenType.OpenCurlyBracket, SymbolType.OpenCurlyBracket, statementReference);
            Node<CsToken> openingBracketNode = this.tokens.InsertLast(openingBracket);

            // Create the block statement.
            BlockStatement block = new BlockStatement();

            // Get the rest of the statement.
            Node<CsToken> closingBracketNode = this.ParseStatementScope(block, statementReference, unsafeCode);
            if (closingBracketNode == null)
            {
                // If we failed to get a closing bracket back, then there is a syntax
                // error in the document since there is an opening bracket with no matching
                // closing bracket.
                throw this.CreateSyntaxException();
            }

            openingBracket.MatchingBracketNode = closingBracketNode;
            ((Bracket)closingBracketNode.Value).MatchingBracketNode = openingBracketNode;

            // Create the token list for this statement.
            CsTokenList partialTokens = new CsTokenList(this.tokens, openingBracketNode, this.tokens.Last);

            block.Tokens = partialTokens;
            statementReference.Target = block;

            return block;
        }
 internal CheckedStatement(CsTokenList tokens, BlockStatement embeddedStatement)
     : base(StatementType.Checked, tokens)
 {
     this.embeddedStatement = embeddedStatement;
     base.AddStatement(embeddedStatement);
 }
 private BlockStatement ParseBlockStatement(bool unsafeCode)
 {
     Bracket bracketToken = this.GetBracketToken(CsTokenType.OpenCurlyBracket, SymbolType.OpenCurlyBracket);
     Microsoft.StyleCop.Node<CsToken> firstItemNode = this.tokens.InsertLast(bracketToken);
     BlockStatement parent = new BlockStatement();
     Microsoft.StyleCop.Node<CsToken> node2 = this.ParseStatementScope(parent, unsafeCode);
     if (node2 == null)
     {
         throw this.CreateSyntaxException();
     }
     bracketToken.MatchingBracketNode = node2;
     ((Bracket) node2.Value).MatchingBracketNode = firstItemNode;
     CsTokenList list = new CsTokenList(this.tokens, firstItemNode, this.tokens.Last);
     parent.Tokens = list;
     return parent;
 }