本文整理汇总了C#中ImmutableStack.Collapse方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableStack.Collapse方法的具体用法?C# ImmutableStack.Collapse怎么用?C# ImmutableStack.Collapse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableStack
的用法示例。
在下文中一共展示了ImmutableStack.Collapse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Blender
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;
}