|
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision: 1965 $</version>
// </file>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace ICSharpCode.NRefactory.Ast
{
public abstract class AbstractNode : INode
{
INode parent;
List<INode> children = new List<INode>();
Location startLocation;
Location endLocation;
public INode Parent {
get {
return parent;
}
set {
parent = value;
}
}
public Location StartLocation {
get {
return startLocation;
}
set {
startLocation = value;
}
}
public Location EndLocation {
get {
return endLocation;
}
set {
endLocation = value;
}
}
public List<INode> Children {
get {
return children;
}
set {
Debug.Assert(value != null);
children = value;
}
}
public virtual void AddChild(INode childNode)
{
Debug.Assert(childNode != null);
children.Add(childNode);
}
public abstract object AcceptVisitor(IAstVisitor visitor, object data);
public virtual object AcceptChildren(IAstVisitor visitor, object data)
{
foreach (INode child in children) {
Debug.Assert(child != null);
child.AcceptVisitor(visitor, data);
}
return data;
}
public static string GetCollectionString(ICollection collection)
{
StringBuilder output = new StringBuilder();
output.Append('{');
if (collection != null) {
IEnumerator en = collection.GetEnumerator();
bool isFirst = true;
while (en.MoveNext()) {
if (!isFirst) {
output.Append(", ");
} else {
isFirst = false;
}
output.Append(en.Current == null ? "<null>" : en.Current.ToString());
}
} else {
return "null";
}
output.Append('}');
return output.ToString();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.