-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeLocation.cs
More file actions
46 lines (40 loc) · 1.34 KB
/
CodeLocation.cs
File metadata and controls
46 lines (40 loc) · 1.34 KB
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
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace CodeNavigator
{
class CodeLocation
{
//char offset in the code that includes comments
//- if a comment ends at the end of the file, CharOffsetWithoutComments
// is equal code.Length (ie. not a valid char)
internal int CharOffsetWithoutComments { get; set; }
internal int CharOffsetDifference { get; set; }
//char offset in the code when comments have been removed
internal int CharOffsetWithComments
{
get
{
int diff = CharOffsetDifference;
return (diff == -1 ? CharOffsetWithoutComments : CharOffsetWithoutComments + diff);
}
}
internal CodeLocation()
{
CharOffsetWithoutComments = -1;
CharOffsetDifference = -1;
}
internal CodeLocation(int offsetWithComments, int offsetWithoutComments)
{
CharOffsetDifference = offsetWithComments - offsetWithoutComments;
CharOffsetWithoutComments = offsetWithoutComments;
Debug.Assert(CharOffsetWithoutComments < CharOffsetWithComments);
}
internal bool HasOffset()
{
return CharOffsetDifference != -1;
}
}
}