Esempio n. 1
0
        //inStartLine - next of parent line
        static void CollectByDivs(CKey inParent, int inParentRank, int inStartLine, int inEndLine, List <CTokenLine> inLines,
                                  ITreeBuildSupport inSupport, CKey inRoot, EKeyAddingMode inKeyAddingMode)
        {
            int curr_rank = inParentRank + 1;
            List <Tuple <int, int> > recs_by_divs = new List <Tuple <int, int> >();

            CollectDividers(inStartLine, inEndLine, curr_rank, inLines, inSupport, recs_by_divs);

            if (recs_by_divs.Count > 1)
            {
                if (inKeyAddingMode == EKeyAddingMode.Override)
                {
                    inParent.ClearAllArrayKeys();
                }

                for (int i = 0; i < recs_by_divs.Count; i++)
                {
                    int first_line       = recs_by_divs[i].Item1;
                    int exlude_last_line = recs_by_divs[i].Item2;
                    if (first_line < exlude_last_line)
                    {
                        CKey arr_key = CKey.CreateArrayKey(inParent, inLines[first_line].Position);

                        if (IsLinePresent(curr_rank, first_line, exlude_last_line, inLines))
                        {
                            Collect(arr_key, curr_rank, first_line, exlude_last_line, inLines, inSupport, inRoot, EKeyAddingMode.AddUnique);
                        }
                        else
                        {
                            CollectByDivs(arr_key, curr_rank, first_line, exlude_last_line, inLines, inSupport, inRoot, EKeyAddingMode.AddUnique);
                        }

                        if (arr_key.IsEmpty)
                        {
                            arr_key.SetParent(null);
                        }
                    }
                }
            }
            else
            {
                Collect(inParent, inParentRank, recs_by_divs[0].Item1, recs_by_divs[0].Item2, inLines, inSupport, inRoot, inKeyAddingMode);
            }
        }