Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Document\TextAnchor.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
88
|
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: 2683 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
||
10 |
namespace ICSharpCode.TextEditor.Document |
|
11 |
{ |
|
12 |
/// <summary> |
|
13 |
/// Description of TextAnchor. |
|
14 |
/// </summary> |
|
15 |
public sealed class TextAnchor |
|
16 |
{ |
|
17 |
static Exception AnchorDeletedError() |
|
18 |
{ |
|
19 |
return new InvalidOperationException("The text containing the anchor was deleted"); |
|
20 |
} |
|
21 |
||
22 |
LineSegment lineSegment; |
|
23 |
int columnNumber; |
|
24 |
||
25 |
public LineSegment Line { |
|
26 |
get { |
|
27 |
if (lineSegment == null) throw AnchorDeletedError(); |
|
28 |
return lineSegment; |
|
29 |
} |
|
30 |
internal set { |
|
31 |
lineSegment = value; |
|
32 |
} |
|
33 |
} |
|
34 |
||
35 |
public bool IsDeleted { |
|
36 |
get { |
|
37 |
return lineSegment == null; |
|
38 |
} |
|
39 |
} |
|
40 |
||
41 |
public int LineNumber { |
|
42 |
get { |
|
43 |
return this.Line.LineNumber; |
|
44 |
} |
|
45 |
} |
|
46 |
||
47 |
public int ColumnNumber { |
|
48 |
get { |
|
49 |
if (lineSegment == null) throw AnchorDeletedError(); |
|
50 |
return columnNumber; |
|
51 |
} |
|
52 |
internal set { |
|
53 |
columnNumber = value; |
|
54 |
} |
|
55 |
} |
|
56 |
||
57 |
public TextLocation Location { |
|
58 |
get { |
|
59 |
return new TextLocation(this.ColumnNumber, this.LineNumber); |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
public int Offset { |
|
64 |
get { |
|
65 |
return this.Line.Offset + columnNumber; |
|
66 |
} |
|
67 |
} |
|
68 |
||
69 |
internal void Deleted() |
|
70 |
{ |
|
71 |
lineSegment = null; |
|
72 |
} |
|
73 |
||
74 |
internal TextAnchor(LineSegment lineSegment, int columnNumber) |
|
75 |
{ |
|
76 |
this.lineSegment = lineSegment; |
|
77 |
this.columnNumber = columnNumber; |
|
78 |
} |
|
79 |
||
80 |
public override string ToString() |
|
81 |
{ |
|
82 |
if (this.IsDeleted) |
|
83 |
return "[TextAnchor (deleted)]"; |
|
84 |
else |
|
85 |
return "[TextAnchor " + this.Location.ToString() + "]"; |
|
86 |
} |
|
87 |
} |
|
88 |
} |