Skip to content

Commit f30ba3b

Browse files
Merge pull request #1164 from decaffeinate/fix/debugger
fix: support parsing `debugger` statements
2 parents c8bd89c + df9ae74 commit f30ba3b

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed

src/mappers/mapLiteral.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
Bool,
1717
Break,
1818
Continue,
19+
Debugger,
1920
Float,
2021
Identifier,
2122
Int,
@@ -87,6 +88,8 @@ export default function mapLiteral(context: ParseContext, node: Literal): Node {
8788
return new Break(line, column, start, end, raw);
8889
} else if (node.value === 'continue') {
8990
return new Continue(line, column, start, end, raw);
91+
} else if (node.value === 'debugger') {
92+
return new Debugger(line, column, start, end, raw);
9093
}
9194
}
9295

src/nodes.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,22 @@ export class Continue extends Node {
964964
}
965965
}
966966

967+
export class Debugger extends Node {
968+
constructor(
969+
line: number,
970+
column: number,
971+
start: number,
972+
end: number,
973+
raw: string
974+
) {
975+
super('Debugger', line, column, start, end, raw);
976+
}
977+
978+
getChildNames(): Array<keyof this & string> {
979+
return [];
980+
}
981+
}
982+
967983
export class Spread extends Node {
968984
constructor(
969985
line: number,

test/__snapshots__/examples.test.ts.snap

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,6 +5983,36 @@ Program {
59835983
}
59845984
`;
59855985

5986+
exports[`CS1: debugger 1`] = `
5987+
Program {
5988+
"body": Block {
5989+
"column": 1,
5990+
"end": 8,
5991+
"inline": false,
5992+
"line": 1,
5993+
"raw": "debugger",
5994+
"start": 0,
5995+
"statements": Array [
5996+
Debugger {
5997+
"column": 1,
5998+
"end": 8,
5999+
"line": 1,
6000+
"raw": "debugger",
6001+
"start": 0,
6002+
"type": "Debugger",
6003+
},
6004+
],
6005+
"type": "Block",
6006+
},
6007+
"column": 1,
6008+
"end": 8,
6009+
"line": 1,
6010+
"raw": "debugger",
6011+
"start": 0,
6012+
"type": "Program",
6013+
}
6014+
`;
6015+
59866016
exports[`CS1: delete 1`] = `
59876017
Program {
59886018
"body": Block {
@@ -26808,6 +26838,36 @@ Program {
2680826838
}
2680926839
`;
2681026840

26841+
exports[`CS2: debugger 1`] = `
26842+
Program {
26843+
"body": Block {
26844+
"column": 1,
26845+
"end": 8,
26846+
"inline": false,
26847+
"line": 1,
26848+
"raw": "debugger",
26849+
"start": 0,
26850+
"statements": Array [
26851+
Debugger {
26852+
"column": 1,
26853+
"end": 8,
26854+
"line": 1,
26855+
"raw": "debugger",
26856+
"start": 0,
26857+
"type": "Debugger",
26858+
},
26859+
],
26860+
"type": "Block",
26861+
},
26862+
"column": 1,
26863+
"end": 8,
26864+
"line": 1,
26865+
"raw": "debugger",
26866+
"start": 0,
26867+
"type": "Program",
26868+
}
26869+
`;
26870+
2681126871
exports[`CS2: delete 1`] = `
2681226872
Program {
2681326873
"body": Block {

test/examples/debugger.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
debugger

0 commit comments

Comments
 (0)