Пример #1
0
        static SAddLineResult AddLine(CKey inParent, CKey inCurrentArrayKey, CTokenLine line, ITreeBuildSupport inSupport, CBuildCommands inCommands)
        {
            SAddLineResult result = new SAddLineResult();

            if (line.IsEmpty())
            {
                if (line.Comments != null)
                {
                    inCommands.SetNextLineComment(line.Comments.Text, line.Position.Line, inParent);
                }
                result.current_array_key = inCurrentArrayKey;
            }
            else if (line.IsRecordDivider())
            {
                result.current_array_key = null;
                result.WasRecordDivider  = true;
            }
            else if (line.IsCommandLine())
            {
                result.current_array_key = ExecuteCommand(inParent, inCurrentArrayKey, line, inSupport, inCommands);
            }
            else if (line.Head != null)
            {
                result.current_array_key = inCurrentArrayKey;
                if (result.current_array_key == null)
                {
                    result.current_array_key = CreateNewArrayKey(inParent, line, inCommands);
                }

                if (line.AdditionMode == EKeyAddingMode.AddUnique && result.current_array_key.IsKeyWithNamePresent(line.Head.Text))
                {
                    inSupport.GetLogger().LogError(EErrorCode.ElementWithNameAlreadyPresent, line);
                }

                result.last_key_add_mode = line.AdditionMode;
                result.last_record_key   = CKey.Create(result.current_array_key, line, inSupport.GetLogger());

                if (inCommands.IsNextLineCommentPresent)
                {
                    result.last_record_key.AddComments(inCommands.PopNextLineComments(inParent));
                }
            }
            else if (!line.IsTailEmpty)
            {
                //if (!line.IsNewArrayLine && line.TailLength == 1 && !inParent.IsArray)
                //    inParent.AddTokenTail(line, true, inSupport.GetLogger());
                //else
                {
                    result.current_array_key = CreateNewArrayKey(inParent, line, inCommands);
                    result.current_array_key.AddTokenTail(line, inSupport.GetLogger());
                }
            }

            return(result);
        }