mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Breakpoints in the for in statement
This commit is contained in:
@@ -100,6 +100,9 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.ForStatement:
|
||||
return spanInForStatement(<ForStatement>node);
|
||||
|
||||
case SyntaxKind.ForInStatement:
|
||||
return spanInForInStatement(<ForInStatement>node);
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.PostfixOperator:
|
||||
case SyntaxKind.PrefixOperator:
|
||||
@@ -142,6 +145,11 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInVariableDeclaration(variableDeclaration: VariableDeclaration): TypeScript.TextSpan {
|
||||
// If declaration of for in statement, just set the span in parent
|
||||
if (variableDeclaration.parent.kind === SyntaxKind.ForInStatement) {
|
||||
return spanInForInStatement(<ForInStatement>variableDeclaration.parent);
|
||||
}
|
||||
|
||||
var isParentVariableStatement = variableDeclaration.parent.kind === SyntaxKind.VariableStatement;
|
||||
var isDeclarationOfForStatement = variableDeclaration.parent.kind === SyntaxKind.ForStatement && contains((<ForStatement>variableDeclaration.parent).declarations, variableDeclaration);
|
||||
var declarations = isParentVariableStatement
|
||||
@@ -243,6 +251,7 @@ module ts.BreakpointResolver {
|
||||
// Set on parent if on same line otherwise on first statement
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
|
||||
|
||||
// Set span on previous token if it starts on same line otherwise on the first statement of the block
|
||||
@@ -304,6 +313,10 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
}
|
||||
|
||||
function spanInForInStatement(forInStatement: ForInStatement): TypeScript.TextSpan {
|
||||
return textSpan(forInStatement, findNextToken(forInStatement.expression, forInStatement));
|
||||
}
|
||||
|
||||
function spanInExpression(expression: Expression): TypeScript.TextSpan {
|
||||
//TODO (pick this up later) for now lets fix do-while baseline␍ if (node.parent.kind === SyntaxKind.DoStatement) {
|
||||
// Set span as if on while keyword
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
1 >for (var x in String) {
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (0 to 23) SpanInfo: {"start":0,"length":21}
|
||||
>for (var x in String)
|
||||
>:=> (line 1, col 0) to (line 1, col 21)
|
||||
--------------------------------
|
||||
2 > WScript.Echo(x);
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~ => Pos: (24 to 44) SpanInfo: {"start":28,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 2, col 4) to (line 2, col 19)
|
||||
--------------------------------
|
||||
3 >}
|
||||
|
||||
~~ => Pos: (45 to 46) SpanInfo: {"start":28,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 2, col 4) to (line 2, col 19)
|
||||
--------------------------------
|
||||
4 >for (x in String) {
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~ => Pos: (47 to 66) SpanInfo: {"start":47,"length":17}
|
||||
>for (x in String)
|
||||
>:=> (line 4, col 0) to (line 4, col 17)
|
||||
--------------------------------
|
||||
5 > WScript.Echo(x);
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~ => Pos: (67 to 87) SpanInfo: {"start":71,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 5, col 4) to (line 5, col 19)
|
||||
--------------------------------
|
||||
6 >}
|
||||
|
||||
~~ => Pos: (88 to 89) SpanInfo: {"start":71,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 5, col 4) to (line 5, col 19)
|
||||
--------------------------------
|
||||
7 >for (var x2 in String)
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (90 to 112) SpanInfo: {"start":90,"length":22}
|
||||
>for (var x2 in String)
|
||||
>:=> (line 7, col 0) to (line 7, col 22)
|
||||
--------------------------------
|
||||
8 >{
|
||||
|
||||
~~ => Pos: (113 to 114) SpanInfo: {"start":119,"length":16}
|
||||
>WScript.Echo(x2)
|
||||
>:=> (line 9, col 4) to (line 9, col 20)
|
||||
--------------------------------
|
||||
9 > WScript.Echo(x2);
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~ => Pos: (115 to 136) SpanInfo: {"start":119,"length":16}
|
||||
>WScript.Echo(x2)
|
||||
>:=> (line 9, col 4) to (line 9, col 20)
|
||||
--------------------------------
|
||||
10 >}
|
||||
|
||||
~~ => Pos: (137 to 138) SpanInfo: {"start":119,"length":16}
|
||||
>WScript.Echo(x2)
|
||||
>:=> (line 9, col 4) to (line 9, col 20)
|
||||
--------------------------------
|
||||
11 >for (x in String)
|
||||
|
||||
~~~~~~~~~~~~~~~~~~ => Pos: (139 to 156) SpanInfo: {"start":139,"length":17}
|
||||
>for (x in String)
|
||||
>:=> (line 11, col 0) to (line 11, col 17)
|
||||
--------------------------------
|
||||
12 >{
|
||||
|
||||
~~ => Pos: (157 to 158) SpanInfo: {"start":163,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 13, col 4) to (line 13, col 19)
|
||||
--------------------------------
|
||||
13 > WScript.Echo(x);
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~ => Pos: (159 to 179) SpanInfo: {"start":163,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 13, col 4) to (line 13, col 19)
|
||||
--------------------------------
|
||||
14 >}
|
||||
~ => Pos: (180 to 180) SpanInfo: {"start":163,"length":15}
|
||||
>WScript.Echo(x)
|
||||
>:=> (line 13, col 4) to (line 13, col 19)
|
||||
Reference in New Issue
Block a user