mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Breakpoint span in the doStatement
This commit is contained in:
parent
abb0acc639
commit
a047d205ef
@ -65,6 +65,9 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.FunctionBlock:
|
||||
return spanInFirstStatementOfBlock(<Block>node);
|
||||
|
||||
case SyntaxKind.Block:
|
||||
return spanInBlock(<Block>node);
|
||||
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return spanInExpressionStatement(<ExpressionStatement>node);
|
||||
|
||||
@ -74,6 +77,9 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.WhileStatement:
|
||||
return spanInWhileStatement(<WhileStatement>node);
|
||||
|
||||
case SyntaxKind.DoStatement:
|
||||
return spanInDoStatement(<DoStatement>node);
|
||||
|
||||
// Tokens:
|
||||
case SyntaxKind.SemicolonToken:
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
@ -88,12 +94,27 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
return spanInCloseBraceToken(node);
|
||||
|
||||
case SyntaxKind.OpenParenToken:
|
||||
return spanInOpenParenToken(node);
|
||||
|
||||
case SyntaxKind.CloseParenToken:
|
||||
return spanInCloseParenToken(node);
|
||||
|
||||
case SyntaxKind.ColonToken:
|
||||
return spanInColonToken(node);
|
||||
|
||||
// Keywords:
|
||||
case SyntaxKind.WhileKeyword:
|
||||
return spanInWhileKeyword(node);
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
//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
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
// Default action for now
|
||||
|
||||
default:
|
||||
// Default go to parent to set the breakpoint
|
||||
return spanInNode(node.parent);
|
||||
@ -210,6 +231,10 @@ module ts.BreakpointResolver {
|
||||
return textSpan(whileStatement, findNextToken(whileStatement.expression, whileStatement));
|
||||
}
|
||||
|
||||
function spanInDoStatement(doStatement: DoStatement): TypeScript.TextSpan {
|
||||
return spanInNode(doStatement.statement);
|
||||
}
|
||||
|
||||
// Tokens:
|
||||
function spanInCommaToken(node: Node): TypeScript.TextSpan {
|
||||
switch (node.parent.kind) {
|
||||
@ -253,11 +278,33 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
}
|
||||
|
||||
function spanInOpenParenToken(node: Node): TypeScript.TextSpan {
|
||||
if (node.parent.kind === SyntaxKind.DoStatement) {
|
||||
// Go to while keyword and do action instead
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
|
||||
// Default to parent node
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
|
||||
function spanInCloseParenToken(node: Node): TypeScript.TextSpan {
|
||||
// Is this close paren token of parameter list, set span in previous token
|
||||
if (isAnyFunction(node.parent) ||
|
||||
node.parent.kind === SyntaxKind.WhileStatement) {
|
||||
return spanInPreviousNode(node);
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.DoStatement:
|
||||
return spanInPreviousNode(node);
|
||||
|
||||
// Default to parent node
|
||||
default:
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
|
||||
// Default to parent node
|
||||
@ -272,6 +319,16 @@ module ts.BreakpointResolver {
|
||||
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
|
||||
function spanInWhileKeyword(node: Node): TypeScript.TextSpan {
|
||||
if (node.parent.kind === SyntaxKind.DoStatement) {
|
||||
// Set span on while expression
|
||||
return textSpan(node, findNextToken((<DoStatement>node.parent).expression, node.parent));
|
||||
}
|
||||
|
||||
// Default to parent node
|
||||
return spanInNode(node.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
81
tests/baselines/reference/bpSpan_do.baseline
Normal file
81
tests/baselines/reference/bpSpan_do.baseline
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
1 >var i = 0;
|
||||
|
||||
~~~~~~~~~~~ => Pos: (0 to 10) SpanInfo: {"start":0,"length":9}
|
||||
>var i = 0
|
||||
>:=> (line 1, col 0) to (line 1, col 9)
|
||||
--------------------------------
|
||||
2 >do
|
||||
|
||||
~~~ => Pos: (11 to 13) SpanInfo: {"start":20,"length":3}
|
||||
>i++
|
||||
>:=> (line 4, col 4) to (line 4, col 7)
|
||||
--------------------------------
|
||||
3 >{
|
||||
|
||||
~~ => Pos: (14 to 15) SpanInfo: {"start":20,"length":3}
|
||||
>i++
|
||||
>:=> (line 4, col 4) to (line 4, col 7)
|
||||
--------------------------------
|
||||
4 > i++;
|
||||
|
||||
~~~~~~~~~ => Pos: (16 to 24) SpanInfo: {"start":20,"length":3}
|
||||
>i++
|
||||
>:=> (line 4, col 4) to (line 4, col 7)
|
||||
--------------------------------
|
||||
5 >} while (i < 10);
|
||||
|
||||
~ => Pos: (25 to 25) SpanInfo: {"start":20,"length":3}
|
||||
>i++
|
||||
>:=> (line 4, col 4) to (line 4, col 7)
|
||||
5 >} while (i < 10);
|
||||
|
||||
~~~~~~~~~~~~~~~~~ => Pos: (26 to 42) SpanInfo: {"start":27,"length":14}
|
||||
>while (i < 10)
|
||||
>:=> (line 5, col 2) to (line 5, col 16)
|
||||
--------------------------------
|
||||
6 >do {
|
||||
|
||||
~~~~~ => Pos: (43 to 47) SpanInfo: {"start":52,"length":3}
|
||||
>i++
|
||||
>:=> (line 7, col 4) to (line 7, col 7)
|
||||
--------------------------------
|
||||
7 > i++;
|
||||
|
||||
~~~~~~~~~ => Pos: (48 to 56) SpanInfo: {"start":52,"length":3}
|
||||
>i++
|
||||
>:=> (line 7, col 4) to (line 7, col 7)
|
||||
--------------------------------
|
||||
8 >} while (i < 20);
|
||||
|
||||
~ => Pos: (57 to 57) SpanInfo: {"start":52,"length":3}
|
||||
>i++
|
||||
>:=> (line 7, col 4) to (line 7, col 7)
|
||||
8 >} while (i < 20);
|
||||
|
||||
~~~~~~~~~~~~~~~~~ => Pos: (58 to 74) SpanInfo: {"start":59,"length":14}
|
||||
>while (i < 20)
|
||||
>:=> (line 8, col 2) to (line 8, col 16)
|
||||
--------------------------------
|
||||
9 >do {
|
||||
|
||||
~~~~~ => Pos: (75 to 79) SpanInfo: {"start":84,"length":3}
|
||||
>i++
|
||||
>:=> (line 10, col 4) to (line 10, col 7)
|
||||
--------------------------------
|
||||
10 > i++;
|
||||
|
||||
~~~~~~~~~ => Pos: (80 to 88) SpanInfo: {"start":84,"length":3}
|
||||
>i++
|
||||
>:=> (line 10, col 4) to (line 10, col 7)
|
||||
--------------------------------
|
||||
11 >}
|
||||
|
||||
~~~ => Pos: (89 to 91) SpanInfo: {"start":84,"length":3}
|
||||
>i++
|
||||
>:=> (line 10, col 4) to (line 10, col 7)
|
||||
--------------------------------
|
||||
12 >while (i < 30);
|
||||
~~~~~~~~~~~~~~~ => Pos: (92 to 106) SpanInfo: {"start":92,"length":14}
|
||||
>while (i < 30)
|
||||
>:=> (line 12, col 0) to (line 12, col 14)
|
||||
@ -10,5 +10,8 @@
|
||||
////do {
|
||||
//// i++;
|
||||
////} while (i < 20);
|
||||
|
||||
////do {
|
||||
//// i++;
|
||||
////}
|
||||
////while (i < 30);
|
||||
verify.baselineCurrentFileBreakpointLocations();
|
||||
Loading…
x
Reference in New Issue
Block a user