public Blender(Lexer lexer, CSharp.CSharpSyntaxNode oldTree, IEnumerable <TextChangeRange> changes) { Debug.Assert(lexer != null); this.lexer = lexer; this.changes = ImmutableStack.Create <TextChangeRange>(); if (changes != null) { // TODO: Consider implementing NormalizedChangeCollection for TextSpan. the real // reason why we are collapsing is because we want to extend change ranges and // cannot allow them to overlap. This does not seem to be a big deal since multiple // changes are infrequent and typically close to each other. However if we have // NormalizedChangeCollection for TextSpan we can have both - we can extend ranges // and not require collapsing them. NormalizedChangeCollection would also ensure // that changes are always normalized. // TODO: this is a temporary measure to prevent individual change spans from // overlapping after they are widened to effective width (+1 token at the start). // once we have normalized collection for TextSpan we will not need to collapse all // the change spans. var collapsed = changes.Collapse(); // extend the change to its affected range. This will make it easier // to filter out affected nodes since we will be able simply check // if node intersects with a change. var affectedRange = ExtendToAffectedRange(oldTree, collapsed); this.changes = this.changes.Push(affectedRange); } if (oldTree == null) { // start at lexer current position if no nodes specified this.oldTreeCursor = new Cursor(); this.newPosition = lexer.TextWindow.Position; } else { this.oldTreeCursor = Cursor.FromRoot(oldTree).MoveToFirstChild(); this.newPosition = 0; } this.changeDelta = 0; this.newDirectives = default(DirectiveStack); this.oldDirectives = default(DirectiveStack); this.newLexerDrivenMode = 0; }
public Blender(Lexer lexer, CSharp.CSharpSyntaxNode oldTree, IEnumerable<TextChangeRange> changes) { Debug.Assert(lexer != null); this.lexer = lexer; this.changes = ImmutableStack.Create<TextChangeRange>(); if (changes != null) { // TODO: Consider implementing NormalizedChangeCollection for TextSpan. the real // reason why we are collapsing is because we want to extend change ranges and // cannot allow them to overlap. This does not seem to be a big deal since multiple // changes are infrequent and typically close to each other. However if we have // NormalizedChangeCollection for TextSpan we can have both - we can extend ranges // and not require collapsing them. NormalizedChangeCollection would also ensure // that changes are always normalized. // TODO: this is a temporary measure to prevent individual change spans from // overlapping after they are widened to effective width (+1 token at the start). // once we have normalized collection for TextSpan we will not need to collapse all // the change spans. var collapsed = changes.Collapse(); // extend the change to its affected range. This will make it easier // to filter out affected nodes since we will be able simply check // if node intersects with a change. var affectedRange = ExtendToAffectedRange(oldTree, collapsed); this.changes = this.changes.Push(affectedRange); } if (oldTree == null) { // start at lexer current position if no nodes specified this.oldTreeCursor = new Cursor(); this.newPosition = lexer.TextWindow.Position; } else { this.oldTreeCursor = Cursor.FromRoot(oldTree).MoveToFirstChild(); this.newPosition = 0; } this.changeDelta = 0; this.newDirectives = default(DirectiveStack); this.oldDirectives = default(DirectiveStack); this.newLexerDrivenMode = 0; }