Пример #1
0
 internal SqlBuilders(Stmts stmts)
 {
     foreach (var stmt in stmts)
     {
         _sqls.Add(new SqlBuilder(stmt));
     }
 }
Пример #2
0
        //public Tuple<Predicate, Stmts> this[int i] {
        //  get {
        //    return Tuple.Create(_conditions[i], _statmentsList[i]);
        //  }
        //  set {
        //    _conditions[i] = value.Item1;
        //    this.SetParent(value.Item1);
        //    _statmentsList[i] = value.Item2;
        //    this.SetParent(value.Item2);
        //  }
        //}

        public void SetBranch(int index, Predicate condition, Stmts statments)
        {
            _conditions[index] = condition;
            this.SetParent(condition);
            _statmentsList[index] = statments;
            this.SetParent(statments);
        }
Пример #3
0
 // 空SQL文は構文木ではNullStmtオブジェクトが割り当てられるが、
 // IF文の結果には含めないよう削除する
 private Stmts RemoveNullStmt(Stmts stmts)
 {
     for (int i = stmts.Count - 1; i >= 0; --i)
     {
         if (stmts[i].Type == StmtType.Null)
         {
             stmts.RemoveAt(i);
         }
     }
     return(stmts);
 }
Пример #4
0
        internal IfStmt(List <Predicate> conditions
                        , List <Stmts> statementsList
                        , Stmts elseStatements
                        , Comments comments)
        {
            this.Comments       = comments;
            _conditions         = conditions;
            _statmentsList      = statementsList;
            this.ElseStatements = elseStatements;

            foreach (var condition in conditions)
            {
                this.SetParent(condition);
            }
            foreach (var statements in statementsList)
            {
                this.SetParent(statements);
            }
        }
Пример #5
0
        private void ShiftLastCommentToNextStmt(Stmts stmts)
        {
            // 入力文の先頭のコメントを取得する
            // (先頭がコメントでない場合はnull)
            //string lastComment = this.GetTopComment();
            //bool lastAutoWhere = this.GetTopAutoWhere();
            string lastComment   = stmts[0].HeaderComment;
            bool   lastAutoWhere = stmts[0].AutoWhere;

            // SQL文の先頭のコメントをHeaderCommentに設定する
            foreach (var stmt in stmts)
            {
                stmt.HeaderComment = lastComment;
                stmt.AutoWhere     = lastAutoWhere;
                // SQL文の先頭のコメントは、直前のSQL文の末尾のコメントとして格納されている.
                // HeaderCommentと重複しないようにするため、これを削除する
                if (stmt.StmtSeparators > 0 && stmt.Comments.Count > 0)
                {
                    lastComment = stmt.Comments.Last;
                    stmt.Comments[stmt.Comments.Count - 1] = null;
                    lastAutoWhere = stmt.AutoWhere;
                }
                else
                {
                    lastComment   = null;
                    lastAutoWhere = true;
                }
            }

            // SQL文の末尾のコメントを格納する次のSQL文がない場合は、
            // NullStmtを新規に生成してこれに格納する.
            if (lastComment != null)
            {
                var nullStmt = new NullStmt(0, new Comments());
                nullStmt.HeaderComment = lastComment;
                stmts.Add(nullStmt);
            }
        }