Browse Source
Assign Node.Parent and check its value in unit tests (at least for statements+expressions) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3351 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
9 changed files with 955 additions and 871 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
using NUnit.Framework; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.NRefactory.Ast; |
||||
using ICSharpCode.NRefactory.Visitors; |
||||
|
||||
namespace ICSharpCode.NRefactory.Tests.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// Ensures that all nodes have the Parent property correctly set.
|
||||
/// </summary>
|
||||
public class CheckParentVisitor : NodeTrackingAstVisitor |
||||
{ |
||||
Stack<INode> nodeStack = new Stack<INode>(); |
||||
|
||||
public bool StrictCheck; |
||||
|
||||
public CheckParentVisitor() |
||||
{ |
||||
nodeStack.Push(null); |
||||
} |
||||
|
||||
protected override void BeginVisit(INode node) |
||||
{ |
||||
nodeStack.Push(node); |
||||
} |
||||
|
||||
protected override void EndVisit(INode node) |
||||
{ |
||||
Assert.AreEqual(node, nodeStack.Pop(), "nodeStack was corrupted!"); |
||||
if (StrictCheck |
||||
|| !(node is TypeReference) && !(node is InterfaceImplementation) |
||||
&& !(node is PropertyGetSetRegion) && !(node is ParameterDeclarationExpression) |
||||
&& !(node is TemplateDefinition) && !(node is EventAddRemoveRegion) |
||||
&& !(node is ICSharpCode.NRefactory.Ast.Attribute) && !(node is AttributeSection)) |
||||
{ |
||||
Assert.AreEqual(nodeStack.Peek(), node.Parent, "node " + node + " is missing parent: " + nodeStack.Peek()); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue