public override void Add(ISyntaxNodeViewModel node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } ICodeLineViewModel line = new CodeLineViewModel(this); if (string.IsNullOrEmpty(OpeningLiteral)) { line.Nodes.Add(new IndentNodeViewModel(this)); } else { line.Nodes.Add(new IndentNodeViewModel(this)); line.Nodes.Add(new IndentNodeViewModel(this)); } if (!string.IsNullOrEmpty(Delimiter)) { int count = 0; count += (string.IsNullOrEmpty(OpeningLiteral) ? 0 : 1); count += (string.IsNullOrEmpty(ClosingLiteral) ? 0 : 1); count = Lines.Count - count; if (count > 0) { line.Nodes.Add(new LiteralNodeViewModel(this) { Literal = Delimiter }); } } line.Nodes.Add(node); if (node is RepeatableOptionViewModel) { if (string.IsNullOrEmpty(OpeningLiteral)) { Lines.Insert(0, line); } else { Lines.Insert(1, line); } } else { if (string.IsNullOrEmpty(ClosingLiteral)) { Lines.Add(line); } else { Lines.Insert(Lines.Count - 1, line); } } }
public static ICodeLineViewModel BottomCodeLine(this ISyntaxNodeViewModel @this) { ICodeLineViewModel codeLine; int count = @this.Lines.Count; if (count == 0) { codeLine = new CodeLineViewModel(@this); @this.Lines.Add(codeLine); } else { codeLine = @this.Lines[count - 1]; } return(codeLine); }
private void ClosingLiteralChanged() { if (string.IsNullOrEmpty(ClosingLiteral)) { // TODO } else { ICodeLineViewModel line = new CodeLineViewModel(this); line.Nodes.Add(new IndentNodeViewModel(this)); line.Nodes.Add(new LiteralNodeViewModel(this) { Literal = ClosingLiteral }); Lines.Add(line); } }
private void OpeningLiteralChanged() { if (string.IsNullOrEmpty(OpeningLiteral)) { // TODO } else { ICodeLineViewModel line = new CodeLineViewModel(this); line.Nodes.Add(new IndentNodeViewModel(this)); line.Nodes.Add(new LiteralNodeViewModel(this) { Literal = OpeningLiteral }); if (Lines.Count == 0) { Lines.Add(line); } else { Lines.Insert(0, line); } } }