protected override SyntaxTreeNode RewriteBlock(BlockBuilder parent, Block block) { var newBlock = new BlockBuilder(block); newBlock.Children.Clear(); var ws = block.Children.FirstOrDefault() as Span; IEnumerable <SyntaxTreeNode> newNodes = block.Children; if (ws.Content.All(char.IsWhiteSpace)) { // Add this node to the parent var builder = new SpanBuilder(ws); builder.ClearSymbols(); FillSpan(builder, ws.Start, ws.Content); parent.Children.Add(builder.Build()); // Remove the old whitespace node newNodes = block.Children.Skip(1); } foreach (SyntaxTreeNode node in newNodes) { newBlock.Children.Add(node); } return(newBlock.Build()); }
protected virtual SpanBuilder UpdateSpan(Span target, SourceChange change) { var newContent = change.GetEditedContent(target); var newSpan = new SpanBuilder(target); newSpan.ClearSymbols(); foreach (var token in Tokenizer(newContent)) { newSpan.Accept(token); } if (target.Next != null) { var newEnd = SourceLocationTracker.CalculateNewLocation(target.Start, newContent); target.Next.ChangeStart(newEnd); } return(newSpan); }