-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathlocation.dart
More file actions
53 lines (42 loc) · 1.25 KB
/
Copy pathlocation.dart
File metadata and controls
53 lines (42 loc) · 1.25 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
47
48
49
50
51
52
53
import 'package:meta/meta.dart';
@immutable
class Loc {
final int? line;
final int? column;
const Loc({this.line, this.column});
}
class Segment extends Loc {
final int? offset;
Segment(int? line, int? column, this.offset)
: super(line: line, column: column);
@override
bool operator ==(Object other) =>
other is Segment &&
line == other.line &&
column == other.column &&
offset == other.offset;
@override
int get hashCode => line.hashCode ^ column.hashCode ^ offset.hashCode;
}
@immutable
class Location {
final Segment start;
final Segment end;
final String? source;
const Location(this.start, this.end, [this.source]);
@override
bool operator ==(Object other) =>
other is Location &&
start == other.start &&
end == other.end &&
source == other.source;
static Location create(int? startLine, int? startColumn, int? startOffset,
int? endLine, int? endColumn, int? endOffset,
[String? source]) {
final startSegment = Segment(startLine, startColumn, startOffset);
final endSegment = Segment(endLine, endColumn, endOffset);
return Location(startSegment, endSegment, source);
}
@override
int get hashCode => start.hashCode ^ end.hashCode ^ source.hashCode;
}