/// <summary> /// Collapses the next whitespace element from the given block, offset by the child element. /// </summary> /// <param name="block">The block.</param> /// <param name="element">The child element.</param> private void CollapseNextWhiteSpace(Block block, SyntaxTreeNode element) { if (block == null) { return; } var children = block.Children.ToList(); int index = children.IndexOf(element); if (index < (children.Count - 1)) { var potential = children[index + 1] as Span; if (potential != null && potential.Kind == SpanKind.WhiteSpace) { potential.Collapsed = true; } } }
/// <summary> /// Determines if the given node is equivalent to the current node. /// </summary> /// <param name="node">The other node.</param> /// <returns>True if the nodes are equivalent otherwise false.</returns> public abstract bool EquivalentTo(SyntaxTreeNode node, StringBuilder builder, int level);
/// <summary> /// Determines if the given node is equivalent to the current node. /// </summary> /// <param name="node">The other node.</param> /// <returns>True if the nodes are equivalent otherwise false.</returns> public abstract bool EquivalentTo(SyntaxTreeNode node);
/// <inheritdoc /> public override bool EquivalentTo(SyntaxTreeNode node, StringBuilder builder, int level) { var other = node as Block; if (other == null || other.Type != Type || other.Name != Name) { builder.Append(string.Join("", Enumerable.Repeat("\t", level))); builder.AppendFormat("F: Expected: {0}, Actual: {1}\n", this, other); return false; } builder.Append(string.Join("", Enumerable.Repeat("\t", level))); builder.AppendFormat("P: Expected: {0}, Actual: {1}\n", this, other); return Enumerable.SequenceEqual(Children, other.Children, new EquivalanceComparer(builder, level + 1)); }
/// <inheritdoc /> public override bool EquivalentTo(SyntaxTreeNode node) { var other = node as Block; if (other == null || other.Type != Type || other.Name != Name) { return false; } return Enumerable.SequenceEqual(Children, other.Children, new EquivalanceComparer()); }
/// <summary> /// Determines if the given node is equivalent to the current node. /// </summary> /// <param name="node">The other node.</param> /// <returns>True if the nodes are equivalent otherwise false.</returns> public abstract bool EquivalentTo(SyntaxTreeNode node, StringBuilder builder, int level);
/// <summary> /// Determines if the given node is equivalent to the current node. /// </summary> /// <param name="node">The other node.</param> /// <returns>True if the nodes are equivalent otherwise false.</returns> public abstract bool EquivalentTo(SyntaxTreeNode node);
/// <inheritdoc /> public override bool EquivalentTo(SyntaxTreeNode node) { var other = node as Span; return other != null && Kind.Equals(other.Kind) && Start.Equals(other.Start) && Collapsed.Equals(other.Collapsed) && string.Equals(Content, other.Content, StringComparison.Ordinal); }
/// <inheritdoc /> public override bool EquivalentTo(SyntaxTreeNode node, StringBuilder builder, int level) { var result = EquivalentTo(node); builder.Append(string.Join("", Enumerable.Repeat("\t", level))); builder.AppendFormat("{0}: Expected: {1}, Actual: {2}\n", result ? "P" : "F", this, node); return result; }