Breakpoints for if else construct

This commit is contained in:
Sheetal Nandi 2014-10-17 15:45:17 -07:00
parent 71e96bea9b
commit 7425aedd59
3 changed files with 126 additions and 0 deletions

View File

@ -47,6 +47,10 @@ module ts.BreakpointResolver {
return spanInNode(findPrecedingToken(node.pos, sourceFile));
}
function spanInNextNode(node: Node): TypeScript.TextSpan {
return spanInNode(findNextToken(node, node.parent));
}
function spanInNode(node: Node): TypeScript.TextSpan {
if (node) {
switch (node.kind) {
@ -83,6 +87,9 @@ module ts.BreakpointResolver {
case SyntaxKind.DebuggerStatement:
return spanInDebuggerStatement(node);
case SyntaxKind.IfStatement:
return spanInIfStatement(<IfStatement>node);
// Tokens:
case SyntaxKind.SemicolonToken:
case SyntaxKind.EndOfFileToken:
@ -110,6 +117,9 @@ module ts.BreakpointResolver {
case SyntaxKind.WhileKeyword:
return spanInWhileKeyword(node);
case SyntaxKind.ElseKeyword:
return spanInNextNode(node);
case SyntaxKind.BinaryExpression:
//TODO (pick this up later) for now lets fix do-while baseline
if (node.parent.kind === SyntaxKind.DoStatement) {
@ -215,6 +225,7 @@ module ts.BreakpointResolver {
switch (block.parent.kind) {
// Set on parent if on same line otherwise on first statement
case SyntaxKind.WhileStatement:
case SyntaxKind.IfStatement:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
}
@ -243,6 +254,11 @@ module ts.BreakpointResolver {
return textSpan(node.getChildAt(0, sourceFile));
}
function spanInIfStatement(ifStatement: IfStatement): TypeScript.TextSpan {
// set on if(..) span
return textSpan(ifStatement, findNextToken(ifStatement.expression, ifStatement));
}
// Tokens:
function spanInCommaToken(node: Node): TypeScript.TextSpan {
switch (node.parent.kind) {

View File

@ -0,0 +1,110 @@
1 >var i = 10;
~~~~~~~~~~~~ => Pos: (0 to 11) SpanInfo: {"start":0,"length":10}
>var i = 10
>:=> (line 1, col 0) to (line 1, col 10)
--------------------------------
2 >if (i == 10) {
~~~~~~~~~~~~~~~ => Pos: (12 to 26) SpanInfo: {"start":12,"length":12}
>if (i == 10)
>:=> (line 2, col 0) to (line 2, col 12)
--------------------------------
3 > i++;
~~~~~~~~~ => Pos: (27 to 35) SpanInfo: {"start":31,"length":3}
>i++
>:=> (line 3, col 4) to (line 3, col 7)
--------------------------------
4 >} else
~ => Pos: (36 to 36) SpanInfo: {"start":31,"length":3}
>i++
>:=> (line 3, col 4) to (line 3, col 7)
4 >} else
~~~~~~ => Pos: (37 to 42) SpanInfo: undefined
--------------------------------
5 >{
~~ => Pos: (43 to 44) SpanInfo: undefined
--------------------------------
6 >}
~~ => Pos: (45 to 46) SpanInfo: undefined
--------------------------------
7 >if (i == 10)
~~~~~~~~~~~~~ => Pos: (47 to 59) SpanInfo: {"start":47,"length":12}
>if (i == 10)
>:=> (line 7, col 0) to (line 7, col 12)
--------------------------------
8 >{
~~ => Pos: (60 to 61) SpanInfo: {"start":66,"length":3}
>i++
>:=> (line 9, col 4) to (line 9, col 7)
--------------------------------
9 > i++;
~~~~~~~~~ => Pos: (62 to 70) SpanInfo: {"start":66,"length":3}
>i++
>:=> (line 9, col 4) to (line 9, col 7)
--------------------------------
10 >}
~~ => Pos: (71 to 72) SpanInfo: {"start":66,"length":3}
>i++
>:=> (line 9, col 4) to (line 9, col 7)
--------------------------------
11 >else if (i == 20) {
~~~~~~~~~~~~~~~~~~~~ => Pos: (73 to 92) SpanInfo: {"start":78,"length":12}
>if (i == 20)
>:=> (line 11, col 5) to (line 11, col 17)
--------------------------------
12 > i--;
~~~~~~~~~ => Pos: (93 to 101) SpanInfo: {"start":97,"length":3}
>i--
>:=> (line 12, col 4) to (line 12, col 7)
--------------------------------
13 >} else if (i == 30) {
~ => Pos: (102 to 102) SpanInfo: {"start":97,"length":3}
>i--
>:=> (line 12, col 4) to (line 12, col 7)
13 >} else if (i == 30) {
~~~~~~~~~~~~~~~~~~~~~ => Pos: (103 to 123) SpanInfo: {"start":109,"length":12}
>if (i == 30)
>:=> (line 13, col 7) to (line 13, col 19)
--------------------------------
14 > i += 70;
~~~~~~~~~~~~~ => Pos: (124 to 136) SpanInfo: {"start":128,"length":7}
>i += 70
>:=> (line 14, col 4) to (line 14, col 11)
--------------------------------
15 >} else {
~ => Pos: (137 to 137) SpanInfo: {"start":128,"length":7}
>i += 70
>:=> (line 14, col 4) to (line 14, col 11)
15 >} else {
~~~~~~~~ => Pos: (138 to 145) SpanInfo: {"start":150,"length":3}
>i--
>:=> (line 16, col 4) to (line 16, col 7)
--------------------------------
16 > i--;
~~~~~~~~~ => Pos: (146 to 154) SpanInfo: {"start":150,"length":3}
>i--
>:=> (line 16, col 4) to (line 16, col 7)
--------------------------------
17 >}
~ => Pos: (155 to 155) SpanInfo: {"start":150,"length":3}
>i--
>:=> (line 16, col 4) to (line 16, col 7)