Code Coverage Statistics for Source File

c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Document\HighlightingStrategy\SpanStack.cs

Sequence Point Coverage
N/A
0 of 0
Branch Coverage
N/A
0 of 0
Lines
118
Highlight: Uncovered Code Covered Code
L V Source
1
// <file>
2
//     <copyright see="prj:///doc/copyright.txt"/>
3
//     <license see="prj:///doc/license.txt"/>
4
//     <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
5
//     <version>$Revision: 1471 $</version>
6
// </file>
7
8
using System;
9
using System.Collections.Generic;
10
11
namespace ICSharpCode.TextEditor.Document
12
{
13
	/// <summary>
14
	/// A stack of Span instances. Works like Stack&lt;Span&gt;, but can be cloned quickly
15
	/// because it is implemented as linked list.
16
	/// </summary>
17
	public sealed class SpanStack : ICloneable, IEnumerable<Span>
18
	{
19
		internal sealed class StackNode
20
		{
21
			public readonly StackNode Previous;
22
			public readonly Span Data;
23
			
24
			public StackNode(StackNode previous, Span data)
25
			{
26
				this.Previous = previous;
27
				this.Data = data;
28
			}
29
		}
30
		
31
		StackNode top = null;
32
		
33
		public Span Pop()
34
		{
35
			Span s = top.Data;
36
			top = top.Previous;
37
			return s;
38
		}
39
		
40
		public Span Peek()
41
		{
42
			return top.Data;
43
		}
44
		
45
		public void Push(Span s)
46
		{
47
			top = new StackNode(top, s);
48
		}
49
		
50
		public bool IsEmpty {
51
			get {
52
				return top == null;
53
			}
54
		}
55
		
56
		public SpanStack Clone()
57
		{
58
			SpanStack n = new SpanStack();
59
			n.top = this.top;
60
			return n;
61
		}
62
		object ICloneable.Clone()
63
		{
64
			return this.Clone();
65
		}
66
		
67
		public Enumerator GetEnumerator()
68
		{
69
			return new Enumerator(new StackNode(top, null));
70
		}
71
		IEnumerator<Span> IEnumerable<Span>.GetEnumerator()
72
		{
73
			return this.GetEnumerator();
74
		}
75
		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
76
		{
77
			return this.GetEnumerator();
78
		}
79
		
80
		public struct Enumerator : IEnumerator<Span>
81
		{
82
			StackNode c;
83
			
84
			internal Enumerator(StackNode node)
85
			{
86
				c = node;
87
			}
88
			
89
			public Span Current {
90
				get {
91
					return c.Data;
92
				}
93
			}
94
			
95
			object System.Collections.IEnumerator.Current {
96
				get {
97
					return c.Data;
98
				}
99
			}
100
			
101
			public void Dispose()
102
			{
103
				c = null;
104
			}
105
			
106
			public bool MoveNext()
107
			{
108
				c = c.Previous;
109
				return c != null;
110
			}
111
			
112
			public void Reset()
113
			{
114
				throw new NotSupportedException();
115
			}
116
		}
117
	}
118
}