aboutsummaryrefslogtreecommitdiffstatsci
path: root/CrowIDE/src/Editors/CodeBuffer/Node.cs
blob: 9db5542856cdd8c1f50731e0ae18d862ffe7eed4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;

namespace Crow.Coding
{
	public class Node
	{
		public Node Parent;
		public string Name;
		public string Type;
		public CodeLine StartLine;
		public CodeLine EndLine;
		public Dictionary<string,string> Attributes = new Dictionary<string, string> ();

		public List<Node> Children = new List<Node>();

		public Node ()
		{
		}

		public void AddChild (Node child) {
			child.Parent = this;
			Children.Add (child);
		}

		public int Level {
			get { return Parent == null ? 1 : Parent.Level + 1; } 
		}

		public override string ToString ()
		{
			return string.Format ("Name:{0}, Type:{1}\n\tparent:{2}", Name, Type, Parent);
		}
	}
}