Skip to content

Commit c81c0bf

Browse files
committed
Breakpoints in break/continue statements
1 parent 6fbf0d6 commit c81c0bf

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

src/services/breakpoints.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ module ts.BreakpointResolver {
9393
case SyntaxKind.LabeledStatement:
9494
return spanInLabeledStatement(<LabeledStatement>node);
9595

96+
case SyntaxKind.BreakStatement:
97+
case SyntaxKind.ContinueStatement:
98+
return spanInBreakOrContinueStatement(<BreakOrContinueStatement>node);
99+
96100
// Tokens:
97101
case SyntaxKind.SemicolonToken:
98102
case SyntaxKind.EndOfFileToken:
@@ -265,6 +269,10 @@ module ts.BreakpointResolver {
265269
function spanInLabeledStatement(labeledStatement: LabeledStatement): TypeScript.TextSpan {
266270
return spanInNode(labeledStatement.statement);
267271
}
272+
273+
function spanInBreakOrContinueStatement(breakOrContinueStatement: BreakOrContinueStatement): TypeScript.TextSpan {
274+
return textSpan(breakOrContinueStatement, breakOrContinueStatement.label || breakOrContinueStatement.getChildAt(0));
275+
}
268276

269277
// Tokens:
270278
function spanInCommaToken(node: Node): TypeScript.TextSpan {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
1 >while (true) {
3+
4+
~~~~~~~~~~~~~~~ => Pos: (0 to 14) SpanInfo: {"start":0,"length":12}
5+
>while (true)
6+
>:=> (line 1, col 0) to (line 1, col 12)
7+
--------------------------------
8+
2 > break;
9+
10+
~~~~~~~~~~~ => Pos: (15 to 25) SpanInfo: {"start":19,"length":5}
11+
>break
12+
>:=> (line 2, col 4) to (line 2, col 9)
13+
--------------------------------
14+
3 >}
15+
16+
~~ => Pos: (26 to 27) SpanInfo: {"start":19,"length":5}
17+
>break
18+
>:=> (line 2, col 4) to (line 2, col 9)
19+
--------------------------------
20+
4 >y: while (true) {
21+
22+
~~~~~~~~~~~~~~~~~~ => Pos: (28 to 45) SpanInfo: {"start":31,"length":12}
23+
>while (true)
24+
>:=> (line 4, col 3) to (line 4, col 15)
25+
--------------------------------
26+
5 > break y;
27+
28+
~~~~~~~~~~~~~ => Pos: (46 to 58) SpanInfo: {"start":50,"length":7}
29+
>break y
30+
>:=> (line 5, col 4) to (line 5, col 11)
31+
--------------------------------
32+
6 >}
33+
34+
~~ => Pos: (59 to 60) SpanInfo: {"start":50,"length":7}
35+
>break y
36+
>:=> (line 5, col 4) to (line 5, col 11)
37+
--------------------------------
38+
7 >while (true) {
39+
40+
~~~~~~~~~~~~~~~ => Pos: (61 to 75) SpanInfo: {"start":61,"length":12}
41+
>while (true)
42+
>:=> (line 7, col 0) to (line 7, col 12)
43+
--------------------------------
44+
8 > continue;
45+
46+
~~~~~~~~~~~~~~ => Pos: (76 to 89) SpanInfo: {"start":80,"length":8}
47+
>continue
48+
>:=> (line 8, col 4) to (line 8, col 12)
49+
--------------------------------
50+
9 >}
51+
52+
~~ => Pos: (90 to 91) SpanInfo: {"start":80,"length":8}
53+
>continue
54+
>:=> (line 8, col 4) to (line 8, col 12)
55+
--------------------------------
56+
10 >z: while (true) {
57+
58+
~~~~~~~~~~~~~~~~~~ => Pos: (92 to 109) SpanInfo: {"start":95,"length":12}
59+
>while (true)
60+
>:=> (line 10, col 3) to (line 10, col 15)
61+
--------------------------------
62+
11 > continue z;
63+
64+
~~~~~~~~~~~~~~~~ => Pos: (110 to 125) SpanInfo: {"start":114,"length":10}
65+
>continue z
66+
>:=> (line 11, col 4) to (line 11, col 14)
67+
--------------------------------
68+
12 >}
69+
~ => Pos: (126 to 126) SpanInfo: {"start":114,"length":10}
70+
>continue z
71+
>:=> (line 11, col 4) to (line 11, col 14)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @BaselineFile: bpSpan_breakOrContinue.baseline
4+
// @Filename: bpSpan_breakOrContinue.ts
5+
////while (true) {
6+
//// break;
7+
////}
8+
////y: while (true) {
9+
//// break y;
10+
////}
11+
////while (true) {
12+
//// continue;
13+
////}
14+
////z: while (true) {
15+
//// continue z;
16+
////}
17+
verify.baselineCurrentFileBreakpointLocations();

0 commit comments

Comments
 (0)