Code Coverage Statistics for Source File

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

Sequence Point Coverage
N/A
0 of 0
Branch Coverage
N/A
0 of 0
Lines
128
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: 2658$</version>
6
// </file>
7
8
using System;
9
10
namespace ICSharpCode.TextEditor
11
{
12
	/// <summary>
13
	/// A line/column position.
14
	/// Text editor lines/columns are counting from zero.
15
	/// </summary>
16
	public struct TextLocation : IComparable<TextLocation>, IEquatable<TextLocation>
17
	{
18
		/// <summary>
19
		/// Represents no text location (-1, -1).
20
		/// </summary>
21
		public static readonly TextLocation Empty = new TextLocation(-1, -1);
22
		
23
		public TextLocation(int column, int line)
24
		{
25
			x = column;
26
			y = line;
27
		}
28
		
29
		int x, y;
30
		
31
		public int X {
32
			get { return x; }
33
			set { x = value; }
34
		}
35
		
36
		public int Y {
37
			get { return y; }
38
			set { y = value; }
39
		}
40
		
41
		public int Line {
42
			get { return y; }
43
			set { y = value; }
44
		}
45
		
46
		public int Column {
47
			get { return x; }
48
			set { x = value; }
49
		}
50
		
51
		public bool IsEmpty {
52
			get {
53
				return x <= 0 && y <= 0;
54
			}
55
		}
56
		
57
		public override string ToString()
58
		{
59
			return string.Format("(Line {1}, Col {0})", this.x, this.y);
60
		}
61
		
62
		public override int GetHashCode()
63
		{
64
			return unchecked (87 * x.GetHashCode() ^ y.GetHashCode());
65
		}
66
		
67
		public override bool Equals(object obj)
68
		{
69
			if (!(obj is TextLocation)) return false;
70
			return (TextLocation)obj == this;
71
		}
72
		
73
		public bool Equals(TextLocation other)
74
		{
75
			return this == other;
76
		}
77
		
78
		public static bool operator ==(TextLocation a, TextLocation b)
79
		{
80
			return a.x == b.x && a.y == b.y;
81
		}
82
		
83
		public static bool operator !=(TextLocation a, TextLocation b)
84
		{
85
			return a.x != b.x || a.y != b.y;
86
		}
87
		
88
		public static bool operator <(TextLocation a, TextLocation b)
89
		{
90
			if (a.y < b.y)
91
				return true;
92
			else if (a.y == b.y)
93
				return a.x < b.x;
94
			else
95
				return false;
96
		}
97
		
98
		public static bool operator >(TextLocation a, TextLocation b)
99
		{
100
			if (a.y > b.y)
101
				return true;
102
			else if (a.y == b.y)
103
				return a.x > b.x;
104
			else
105
				return false;
106
		}
107
		
108
		public static bool operator <=(TextLocation a, TextLocation b)
109
		{
110
			return !(a > b);
111
		}
112
		
113
		public static bool operator >=(TextLocation a, TextLocation b)
114
		{
115
			return !(a < b);
116
		}
117
		
118
		public int CompareTo(TextLocation other)
119
		{
120
			if (this == other)
121
				return 0;
122
			if (this < other)
123
				return -1;
124
			else
125
				return 1;
126
		}
127
	}
128
}