|
1 | 1 | import { decode } from 'sourcemap-codec';
|
2 | 2 |
|
3 | 3 | class GeneratedFragmentMapper {
|
4 |
| - constructor( |
5 |
| - generated_code, |
6 |
| - tag_info, |
7 |
| - ) { |
| 4 | + constructor(generated_code, diff) { |
8 | 5 | this.generated_code = generated_code;
|
9 |
| - this.tag_info = tag_info; |
| 6 | + this.diff = diff; |
10 | 7 | }
|
11 | 8 |
|
12 | 9 | get_position_relative_to_fragment(position_relative_to_file) {
|
13 | 10 | const fragment_offset = this.offset_in_fragment(offset_at(position_relative_to_file, this.generated_code));
|
14 |
| - return position_at(fragment_offset, this.tag_info.generated_content); |
| 11 | + return position_at(fragment_offset, this.diff.generated_content); |
15 | 12 | }
|
16 | 13 |
|
17 | 14 | offset_in_fragment(offset) {
|
18 |
| - return offset - this.tag_info.generated_start |
| 15 | + return offset - this.diff.generated_start |
19 | 16 | }
|
20 | 17 | }
|
21 | 18 |
|
22 | 19 | class OriginalFragmentMapper {
|
23 |
| - constructor( |
24 |
| - original_code, |
25 |
| - tag_info, |
26 |
| - ) { |
| 20 | + constructor(original_code, diff) { |
27 | 21 | this.original_code = original_code;
|
28 |
| - this.tag_info = tag_info; |
| 22 | + this.diff = diff; |
29 | 23 | }
|
30 | 24 |
|
31 | 25 | get_position_relative_to_file(position_relative_to_fragment) {
|
32 |
| - const parent_offset = this.offset_in_parent(offset_at(position_relative_to_fragment, this.tag_info.original_content)); |
| 26 | + const parent_offset = this.offset_in_parent(offset_at(position_relative_to_fragment, this.diff.original_content)); |
33 | 27 | return position_at(parent_offset, this.original_code);
|
34 | 28 | }
|
35 | 29 |
|
36 | 30 | offset_in_parent(offset) {
|
37 |
| - return this.tag_info.original_start + offset; |
| 31 | + return this.diff.original_start + offset; |
38 | 32 | }
|
39 | 33 | }
|
40 | 34 |
|
|
0 commit comments