Skip to content

Commit dd6220a

Browse files
committed
fix a bunch of indentation
1 parent d3cf462 commit dd6220a

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

src/mapping.js

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class GeneratedFragmentMapper {
1010
}
1111

1212
get_position_relative_to_fragment(positionRelativeToFile) {
13-
const fragment_offset = this.offset_in_fragment(offset_at(positionRelativeToFile, this.generated_code));
14-
return position_at(fragment_offset, this.tag_info.generated_content);
13+
const fragment_offset = this.offset_in_fragment(offset_at(positionRelativeToFile, this.generated_code));
14+
return position_at(fragment_offset, this.tag_info.generated_content);
1515
}
1616

1717
offset_in_fragment(offset) {
@@ -72,7 +72,7 @@ class SourceMapper {
7272
return { line: -1, column: -1 };
7373
}
7474

75-
const column_match = line_match.find((col, idx) =>
75+
const column_match = line_match.find((col, idx) =>
7676
idx + 1 === line_match.length ||
7777
(col[0] <= column && line_match[idx + 1][0] > column)
7878
);
@@ -101,33 +101,33 @@ export class DocumentMapper {
101101
});
102102
}
103103

104-
get_original_position(generated_position) {
104+
get_original_position(generated_position) {
105105
generated_position = { line: generated_position.line - 1, column: generated_position.column };
106-
const offset = offset_at(generated_position, this.generated_code);
107-
let original_offset = offset;
108-
for (const mapper of this.mappers) {
106+
const offset = offset_at(generated_position, this.generated_code);
107+
let original_offset = offset;
108+
for (const mapper of this.mappers) {
109109
if (offset >= mapper.start && offset <= mapper.end) {
110110
return this.map(mapper, generated_position);
111111
}
112-
if (offset > mapper.end) {
113-
original_offset -= mapper.diff;
114-
}
115-
}
116-
const original_position = position_at(original_offset, this.original_code);
112+
if (offset > mapper.end) {
113+
original_offset -= mapper.diff;
114+
}
115+
}
116+
const original_position = position_at(original_offset, this.original_code);
117117
return this.to_ESLint_position(original_position);
118-
}
118+
}
119119

120120
map(mapper, generatedPosition) {
121-
// Map the position to be relative to the transpiled fragment
122-
const position_in_transpiled_fragment = mapper.generated_fragment_mapper.get_position_relative_to_fragment(
123-
generatedPosition
124-
);
125-
// Map the position, using the sourcemap, to the original position in the source fragment
126-
const position_in_original_fragment = mapper.source_mapper.getOriginalPosition(
127-
position_in_transpiled_fragment
128-
);
129-
// Map the position to be in the original fragment's parent
130-
const original_position = mapper.original_fragment_mapper.get_position_relative_to_file(position_in_original_fragment);
121+
// Map the position to be relative to the transpiled fragment
122+
const position_in_transpiled_fragment = mapper.generated_fragment_mapper.get_position_relative_to_fragment(
123+
generatedPosition
124+
);
125+
// Map the position, using the sourcemap, to the original position in the source fragment
126+
const position_in_original_fragment = mapper.source_mapper.getOriginalPosition(
127+
position_in_transpiled_fragment
128+
);
129+
// Map the position to be in the original fragment's parent
130+
const original_position = mapper.original_fragment_mapper.get_position_relative_to_file(position_in_original_fragment);
131131
return this.to_ESLint_position(original_position);
132132
}
133133

@@ -144,69 +144,69 @@ export class DocumentMapper {
144144
* @param text The text for which the offset should be retrived
145145
*/
146146
function offset_at(position, text) {
147-
const line_offsets = get_line_offsets(text);
147+
const line_offsets = get_line_offsets(text);
148148

149-
if (position.line >= line_offsets.length) {
150-
return text.length;
151-
} else if (position.line < 0) {
152-
return 0;
153-
}
149+
if (position.line >= line_offsets.length) {
150+
return text.length;
151+
} else if (position.line < 0) {
152+
return 0;
153+
}
154154

155-
const line_offset = line_offsets[position.line];
156-
const next_line_offset =
157-
position.line + 1 < line_offsets.length ? line_offsets[position.line + 1] : text.length;
155+
const line_offset = line_offsets[position.line];
156+
const next_line_offset =
157+
position.line + 1 < line_offsets.length ? line_offsets[position.line + 1] : text.length;
158158

159-
return clamp(next_line_offset, line_offset, line_offset + position.column);
159+
return clamp(next_line_offset, line_offset, line_offset + position.column);
160160
}
161161

162162
function position_at(offset, text) {
163-
offset = clamp(offset, 0, text.length);
164-
165-
const line_offsets = get_line_offsets(text);
166-
let low = 0;
167-
let high = line_offsets.length;
168-
if (high === 0) {
169-
return { line: 0, column: offset };
170-
}
171-
172-
while (low < high) {
173-
const mid = Math.floor((low + high) / 2);
174-
if (line_offsets[mid] > offset) {
175-
high = mid;
176-
} else {
177-
low = mid + 1;
178-
}
179-
}
180-
181-
// low is the least x for which the line offset is larger than the current offset
182-
// or array.length if no line offset is larger than the current offset
183-
const line = low - 1;
184-
return { line, column: offset - line_offsets[line] };
163+
offset = clamp(offset, 0, text.length);
164+
165+
const line_offsets = get_line_offsets(text);
166+
let low = 0;
167+
let high = line_offsets.length;
168+
if (high === 0) {
169+
return { line: 0, column: offset };
170+
}
171+
172+
while (low < high) {
173+
const mid = Math.floor((low + high) / 2);
174+
if (line_offsets[mid] > offset) {
175+
high = mid;
176+
} else {
177+
low = mid + 1;
178+
}
179+
}
180+
181+
// low is the least x for which the line offset is larger than the current offset
182+
// or array.length if no line offset is larger than the current offset
183+
const line = low - 1;
184+
return { line, column: offset - line_offsets[line] };
185185
}
186186

187187
function get_line_offsets(text) {
188-
const line_offsets = [];
189-
let is_line_start = true;
190-
191-
for (let i = 0; i < text.length; i++) {
192-
if (is_line_start) {
193-
line_offsets.push(i);
194-
is_line_start = false;
195-
}
196-
const ch = text.charAt(i);
197-
is_line_start = ch === '\r' || ch === '\n';
198-
if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
199-
i++;
200-
}
201-
}
202-
203-
if (is_line_start && text.length > 0) {
204-
line_offsets.push(text.length);
205-
}
206-
207-
return line_offsets;
188+
const line_offsets = [];
189+
let is_line_start = true;
190+
191+
for (let i = 0; i < text.length; i++) {
192+
if (is_line_start) {
193+
line_offsets.push(i);
194+
is_line_start = false;
195+
}
196+
const ch = text.charAt(i);
197+
is_line_start = ch === '\r' || ch === '\n';
198+
if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
199+
i++;
200+
}
201+
}
202+
203+
if (is_line_start && text.length > 0) {
204+
line_offsets.push(text.length);
205+
}
206+
207+
return line_offsets;
208208
}
209209

210210
function clamp(num, min, max) {
211-
return Math.max(min, Math.min(max, num));
211+
return Math.max(min, Math.min(max, num));
212212
}

0 commit comments

Comments
 (0)