Ejemplo n.º 1
0
        public void AddContinuationLine(AbsoluteCodeLine line)
        {
            var last = _lines.Last();

            line.IsDeclarationContinuation = last.HasDeclarationContinuation && !line.ContainsOnlyComment;
            _lines.Add(line);
        }
Ejemplo n.º 2
0
        private IEnumerable <LogicalCodeLine> BuildLogicalCodeLines(IEnumerable <string> lines, out IIndenterSettings settings)
        {
            settings = _settings.Invoke();
            var              logical  = new List <LogicalCodeLine>();
            LogicalCodeLine  current  = null;
            AbsoluteCodeLine previous = null;

            foreach (var line in lines)
            {
                var absolute = new AbsoluteCodeLine(line, settings, previous);
                if (current == null)
                {
                    current = new LogicalCodeLine(absolute, settings);
                    logical.Add(current);
                }
                else
                {
                    current.AddContinuationLine(absolute);
                }

                if (!absolute.HasContinuation)
                {
                    current = null;
                }
                previous = absolute;
            }
            return(logical);
        }
Ejemplo n.º 3
0
        public AbsoluteCodeLine(string code, IIndenterSettings settings, AbsoluteCodeLine previous)
        {
            _settings = settings;
            Previous  = previous;

            if (code.EndsWith(StupidLineEnding))
            {
                _code             = code.Substring(0, code.Length - StupidLineEnding.Length);
                _stupidLineEnding = true;
            }
            else
            {
                _code = code;
            }

            Original = code;

            _escaper = new StringLiteralAndBracketEscaper(_code);
            _code    = _escaper.EscapedString;

            ExtractLineNumber();
            ExtractEndOfLineComment();

            _segments = _code.Split(new[] { ": " }, StringSplitOptions.None);
        }
Ejemplo n.º 4
0
        private void RebuildContinuedLine()
        {
            if (_rebuilt != null)
            {
                return;
            }
            if (_lines.Count == 1)
            {
                _rebuilt = _lines.First();
                return;
            }
            var code = _lines.Aggregate(string.Empty, (c, line) => c + line.ContinuationRebuildText);

            _rebuilt = new AbsoluteCodeLine(code, _settings);
        }
Ejemplo n.º 5
0
 public LogicalCodeLine(AbsoluteCodeLine first, IIndenterSettings settings)
 {
     _lines.Add(first);
     _settings = settings;
 }
Ejemplo n.º 6
0
 public void AddContinuationLine(AbsoluteCodeLine line)
 {
     _lines.Add(line);
 }