Skip to content

Commit

Permalink
Improve source maps for blocks with using declarations (#15985)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Sep 19, 2023
1 parent 4bf5932 commit b7489e7
Show file tree
Hide file tree
Showing 14 changed files with 539 additions and 1 deletion.
Expand Up @@ -84,7 +84,9 @@ export default declare(api => {
} finally {
${disposeCall}
}
`;
` as t.TryStatement;

t.inherits(replacement.block, path.node);

const { parentPath } = path;
if (
Expand Down
@@ -0,0 +1,4 @@
{
using x = fn();
doSomethingWith(x);
}
@@ -0,0 +1,10 @@
try {
var _stack = [];
const x = babelHelpers.using(_stack, fn());
doSomethingWith(x);
} catch (_) {
var _error = _;
var _hasError = true;
} finally {
babelHelpers.dispose(_stack, _error, _hasError);
}
@@ -0,0 +1,137 @@
(1:0-1) { <-- (1:4-5) try {
^ ^

(1:0-1) { <-- (2:2-6) var _sta
^ ^^^^

(1:0-1) { <-- (2:6-12) var _stack = [
^ ^^^^^^

(1:0-1) { <-- (2:12-18) tack = [];
^ ^^^^^^

(2:2-8) using x = <-- (3:2-8) const x =
^^^^^^ ^^^^^^

(2:8-9) ing x = f <-- (3:8-9) nst x = b
^ ^

(2:9-12) ng x = fn() <-- (3:9-12) st x = babe
^^^ ^^^

(2:9-12) ng x = fn() <-- (3:12-24) x = babelHelpers.usi
^^^ ^^^^^^^^^^^^

(2:9-12) ng x = fn() <-- (3:24-25) pers.usin
^^^ ^

(2:9-12) ng x = fn() <-- (3:25-30) ers.using(_st
^^^ ^^^^^

(2:9-12) ng x = fn() <-- (3:30-31) sing(_sta
^^^ ^

(2:9-12) ng x = fn() <-- (3:31-37) ing(_stack, fn
^^^ ^^^^^^

(2:9-12) ng x = fn() <-- (3:37-39) tack, fn()
^^^ ^^

(2:12-14) x = fn(); <-- (3:39-41) ck, fn());
^^ ^^

(2:14-15) = fn(); <-- (3:41-42) , fn());
^ ^

(2:15-16) fn(); <-- (3:42-43) fn());
^ ^

(2:16-17) fn(); <-- (3:43-45) fn());
^ ^^

(3:2-17) doSomethingWith(x); <-- (4:2-17) doSomethingWith(x);
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^

(3:17-18) With(x); <-- (4:17-18) With(x);
^ ^

(3:18-19) ith(x); <-- (4:18-19) ith(x);
^ ^

(3:19-20) th(x); <-- (4:19-20) th(x);
^ ^

(3:20-21) h(x); <-- (4:20-21) h(x);
^ ^

(4:0-1) } <-- (5:0-1) } cat
^ ^

(4:1-1) } <-- (5:1-9) } catch (_) {
>< ^^^^^^^^

(4:1-1) } <-- (5:9-10) ch (_) {
>< ^

(4:1-1) } <-- (5:10-13) h (_) {
>< ^^^

(4:1-1) } <-- (6:2-6) var _err
>< ^^^^

(4:1-1) } <-- (6:6-12) var _error = _
>< ^^^^^^

(4:1-1) } <-- (6:12-15) rror = _;
>< ^^^

(4:1-1) } <-- (6:15-16) r = _;
>< ^

(4:1-1) } <-- (6:16-17) = _;
>< ^

(4:1-1) } <-- (7:2-6) var _has
>< ^^^^

(4:1-1) } <-- (7:6-15) var _hasError = t
>< ^^^^^^^^^

(4:1-1) } <-- (7:15-23) rror = true;
>< ^^^^^^^^

(4:1-1) } <-- (8:0-11) } finally {
>< ^^^^^^^^^^^

(4:1-1) } <-- (9:2-14) babelHelpers.dis
>< ^^^^^^^^^^^^

(4:1-1) } <-- (9:14-15) pers.disp
>< ^

(4:1-1) } <-- (9:15-22) ers.dispose(_st
>< ^^^^^^^

(4:1-1) } <-- (9:22-23) pose(_sta
>< ^

(4:1-1) } <-- (9:23-29) ose(_stack, _e
>< ^^^^^^

(4:1-1) } <-- (9:29-31) tack, _err
>< ^^

(4:1-1) } <-- (9:31-37) ck, _error, _h
>< ^^^^^^

(4:1-1) } <-- (9:37-39) rror, _has
>< ^^

(4:1-1) } <-- (9:39-48) or, _hasError);
>< ^^^^^^^^^

(4:1-1) } <-- (9:48-50) rror);
>< ^^

(4:1-1) } <-- (10:0-1) }
>< ^
@@ -0,0 +1,22 @@
{
"version": 3,
"names": [
"_stack",
"x",
"babelHelpers",
"using",
"fn",
"doSomethingWith",
"_",
"_error",
"_hasError",
"dispose"
],
"sources": [
"source-maps/block/input.js"
],
"sourcesContent": [
"{\n using x = fn();\n doSomethingWith(x);\n}"
],
"mappings": "IAAA;EAAA,IAAAA,MAAA;EACE,MAAMC,CAAC,GAAAC,YAAA,CAAAC,KAAA,CAAAH,MAAA,EAAGI,EAAE,CAAC,CAAC;EACdC,eAAe,CAACJ,CAAC,CAAC;AACpB,CAAC,QAAAK,CAAA;EAAA,IAAAC,MAAA,GAAAD,CAAA;EAAA,IAAAE,SAAA;AAAA;EAAAN,YAAA,CAAAO,OAAA,CAAAT,MAAA,EAAAO,MAAA,EAAAC,SAAA;AAAA"
}
@@ -0,0 +1,3 @@
for (using x of it) {
doSomethingWith(x);
}
@@ -0,0 +1,10 @@
for (const _x of it) try {
var _stack = [];
const x = babelHelpers.using(_stack, _x);
doSomethingWith(x);
} catch (_) {
var _error = _;
var _hasError = true;
} finally {
babelHelpers.dispose(_stack, _error, _hasError);
}
@@ -0,0 +1,149 @@
(1:0-5) for (usin <-- (1:0-5) for (cons
^^^^^ ^^^^^

(1:5-11) or (using x of <-- (1:5-11) or (const _x o
^^^^^^ ^^^^^^

(1:11-12) ing x of <-- (1:11-13) nst _x of
^ ^^

(1:12-16) ng x of it) <-- (1:13-17) t _x of it)
^^^^ ^^^^

(1:16-18) of it) { <-- (1:17-19) of it) tr
^^ ^^

(1:18-20) f it) { <-- (1:19-25) f it) try {
^^ ^^^^^^

(1:20-20) it) { <-- (1:25-26) try {
>< ^

(1:20-20) it) { <-- (2:2-6) var _sta
>< ^^^^

(1:20-20) it) { <-- (2:6-12) var _stack = [
>< ^^^^^^

(1:20-20) it) { <-- (2:12-18) tack = [];
>< ^^^^^^

(1:20-20) it) { <-- (3:2-8) const x =
>< ^^^^^^

(1:11-12) ing x of <-- (3:8-9) nst x = b
^ ^

(1:12-21) ng x of it) { <-- (3:9-12) st x = babe
^^^^^^^^^ ^^^

(1:12-21) ng x of it) { <-- (3:12-24) x = babelHelpers.usi
^^^^^^^^^ ^^^^^^^^^^^^

(1:12-21) ng x of it) { <-- (3:24-25) pers.usin
^^^^^^^^^ ^

(1:12-21) ng x of it) { <-- (3:25-30) ers.using(_st
^^^^^^^^^ ^^^^^

(1:12-21) ng x of it) { <-- (3:30-31) sing(_sta
^^^^^^^^^ ^

(1:12-21) ng x of it) { <-- (3:31-37) ing(_stack, _x
^^^^^^^^^ ^^^^^^

(1:12-21) ng x of it) { <-- (3:37-39) tack, _x);
^^^^^^^^^ ^^

(1:12-21) ng x of it) { <-- (3:39-41) ck, _x);
^^^^^^^^^ ^^

(1:12-21) ng x of it) { <-- (3:41-43) , _x);
^^^^^^^^^ ^^

(2:2-17) doSomethingWith(x); <-- (4:2-17) doSomethingWith(x);
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^

(2:17-18) With(x); <-- (4:17-18) With(x);
^ ^

(2:18-19) ith(x); <-- (4:18-19) ith(x);
^ ^

(2:19-20) th(x); <-- (4:19-20) th(x);
^ ^

(2:20-21) h(x); <-- (4:20-21) h(x);
^ ^

(3:0-1) } <-- (5:0-1) } cat
^ ^

(3:1-1) } <-- (5:1-9) } catch (_) {
>< ^^^^^^^^

(3:1-1) } <-- (5:9-10) ch (_) {
>< ^

(3:1-1) } <-- (5:10-13) h (_) {
>< ^^^

(3:1-1) } <-- (6:2-6) var _err
>< ^^^^

(3:1-1) } <-- (6:6-12) var _error = _
>< ^^^^^^

(3:1-1) } <-- (6:12-15) rror = _;
>< ^^^

(3:1-1) } <-- (6:15-16) r = _;
>< ^

(3:1-1) } <-- (6:16-17) = _;
>< ^

(3:1-1) } <-- (7:2-6) var _has
>< ^^^^

(3:1-1) } <-- (7:6-15) var _hasError = t
>< ^^^^^^^^^

(3:1-1) } <-- (7:15-23) rror = true;
>< ^^^^^^^^

(3:1-1) } <-- (8:0-11) } finally {
>< ^^^^^^^^^^^

(3:1-1) } <-- (9:2-14) babelHelpers.dis
>< ^^^^^^^^^^^^

(3:1-1) } <-- (9:14-15) pers.disp
>< ^

(3:1-1) } <-- (9:15-22) ers.dispose(_st
>< ^^^^^^^

(3:1-1) } <-- (9:22-23) pose(_sta
>< ^

(3:1-1) } <-- (9:23-29) ose(_stack, _e
>< ^^^^^^

(3:1-1) } <-- (9:29-31) tack, _err
>< ^^

(3:1-1) } <-- (9:31-37) ck, _error, _h
>< ^^^^^^

(3:1-1) } <-- (9:37-39) rror, _has
>< ^^

(3:1-1) } <-- (9:39-48) or, _hasError);
>< ^^^^^^^^^

(3:1-1) } <-- (9:48-50) rror);
>< ^^

(3:1-1) } <-- (10:0-1) }
>< ^
@@ -0,0 +1,23 @@
{
"version": 3,
"names": [
"_x",
"it",
"_stack",
"x",
"babelHelpers",
"using",
"doSomethingWith",
"_",
"_error",
"_hasError",
"dispose"
],
"sources": [
"source-maps/for-of/input.js"
],
"sourcesContent": [
"for (using x of it) {\n doSomethingWith(x);\n}"
],
"mappings": "AAAA,KAAK,MAAMA,EAAC,IAAIC,EAAE,MAAE;EAAA,IAAAC,MAAA;EAAA,MAATC,CAAC,GAAAC,YAAA,CAAAC,KAAA,CAAAH,MAAA,EAAAF,EAAA;EACVM,eAAe,CAACH,CAAC,CAAC;AACpB,CAAC,QAAAI,CAAA;EAAA,IAAAC,MAAA,GAAAD,CAAA;EAAA,IAAAE,SAAA;AAAA;EAAAL,YAAA,CAAAM,OAAA,CAAAR,MAAA,EAAAM,MAAA,EAAAC,SAAA;AAAA"
}
@@ -0,0 +1,4 @@
{
"sourceMaps": true,
"plugins": ["proposal-explicit-resource-management"]
}
@@ -0,0 +1,4 @@
before;
using x = fn();
doSomethingWith(x);
after;

0 comments on commit b7489e7

Please sign in to comment.