forked from SimonRichards/clang-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SourceRange.cs
42 lines (33 loc) · 1.29 KB
/
SourceRange.cs
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
namespace ClangSharp {
public class SourceRange {
internal Interop.SourceRange Native { get; private set; }
internal SourceRange(Interop.SourceRange native) {
Native = native;
var start = new SourceLocation(Interop.clang_getRangeStart(Native));
var end = new SourceLocation(Interop.clang_getRangeEnd(Native));
if (end < start) {
Start = end;
End = start;
} else {
Start = start;
End = end;
}
}
public SourceRange(SourceLocation start, SourceLocation end) :
this(Interop.clang_getRange(start.Native, end.Native)) { }
public static SourceRange Null {
get { return new SourceRange(Interop.clang_getNullRange()); }
}
public SourceLocation Start { get; private set; }
public SourceLocation End { get; private set; }
public bool Equals(SourceRange other) {
return Start == other.Start && End == other.End;
}
public override bool Equals(object obj) {
return obj is SourceRange && Equals((SourceRange)obj);
}
public override int GetHashCode() {
return Start.GetHashCode() + End.GetHashCode();
}
}
}