~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to contrib/NRefactory/Project/Src/Visitors/SetParentVisitor.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// <file>
2
 
//     <copyright see="prj:///doc/copyright.txt"/>
3
 
//     <license see="prj:///doc/license.txt"/>
4
 
//     <author name="Daniel Grunwald"/>
5
 
//     <version>$Revision: 4482 $</version>
6
 
// </file>
7
 
 
8
 
using System;
9
 
using ICSharpCode.OldNRefactory.Ast;
10
 
using System.Collections.Generic;
11
 
 
12
 
namespace ICSharpCode.OldNRefactory.Visitors
13
 
{
14
 
        /// <summary>
15
 
        /// Sets the parent property on all nodes in the tree.
16
 
        /// </summary>
17
 
        public class SetParentVisitor : NodeTrackingAstVisitor
18
 
        {
19
 
                Stack<INode> nodeStack = new Stack<INode>();
20
 
                
21
 
                public SetParentVisitor()
22
 
                {
23
 
                        nodeStack.Push(null);
24
 
                }
25
 
                
26
 
                protected override void BeginVisit(INode node)
27
 
                {
28
 
                        node.Parent = nodeStack.Peek();
29
 
                        nodeStack.Push(node);
30
 
                }
31
 
                
32
 
                protected override void EndVisit(INode node)
33
 
                {
34
 
                        nodeStack.Pop();
35
 
                }
36
 
        }
37
 
}