Exemplo n.º 1
0
        public void Execute()
        {
            foreach (IndentSquareBracket Bracket in Children)
            {
                //向下一行,[ 不需要缩进,后续子Bracket的缩进是建立在 [ 的缩进深度的基础上
                Bracket.Start.LineDown();

                EditPoint CurrentEditLintPoint = Bracket.Start.CreateEditPoint();
                if (CurrentEditLintPoint == null)
                {
                    continue;
                }

                //循环本区间的每行,删除空白,后面根据层级深度,添加缩进
                do
                {
                    //检查是否在在括号内,子括号内的内容,交给子括号处理
                    if (Bracket.EditLineIsInChildren(CurrentEditLintPoint))
                    {
                        CurrentEditLintPoint.LineDown();
                        continue;
                    }

                    //处理缩进,对比应该的缩进深度,大于缩进深度,则剔除,小于则添加
                    HandleIndent(Bracket, CurrentEditLintPoint);

                    CurrentEditLintPoint.LineDown();
                } while (CurrentEditLintPoint.Line <= Bracket.End.Line);//同时处理最后一个 ] 跟 [ 的深度保持一致

                //遍历执行所有的子Bracket
                Bracket.Execute();
            }
        }