@@ -65,6 +65,9 @@ module ts.BreakpointResolver {
6565 case SyntaxKind . FunctionBlock :
6666 return spanInFirstStatementOfBlock ( < Block > node ) ;
6767
68+ case SyntaxKind . Block :
69+ return spanInBlock ( < Block > node ) ;
70+
6871 case SyntaxKind . ExpressionStatement :
6972 return spanInExpressionStatement ( < ExpressionStatement > node ) ;
7073
@@ -74,6 +77,9 @@ module ts.BreakpointResolver {
7477 case SyntaxKind . WhileStatement :
7578 return spanInWhileStatement ( < WhileStatement > node ) ;
7679
80+ case SyntaxKind . DoStatement :
81+ return spanInDoStatement ( < DoStatement > node ) ;
82+
7783 // Tokens:
7884 case SyntaxKind . SemicolonToken :
7985 case SyntaxKind . EndOfFileToken :
@@ -88,12 +94,27 @@ module ts.BreakpointResolver {
8894 case SyntaxKind . CloseBraceToken :
8995 return spanInCloseBraceToken ( node ) ;
9096
97+ case SyntaxKind . OpenParenToken :
98+ return spanInOpenParenToken ( node ) ;
99+
91100 case SyntaxKind . CloseParenToken :
92101 return spanInCloseParenToken ( node ) ;
93102
94103 case SyntaxKind . ColonToken :
95104 return spanInColonToken ( node ) ;
96105
106+ // Keywords:
107+ case SyntaxKind . WhileKeyword :
108+ return spanInWhileKeyword ( node ) ;
109+
110+ case SyntaxKind . BinaryExpression :
111+ //TODO (pick this up later) for now lets fix do-while baseline
112+ if ( node . parent . kind === SyntaxKind . DoStatement ) {
113+ // Set span as if on while keyword
114+ return spanInPreviousNode ( node ) ;
115+ }
116+ // Default action for now
117+
97118 default :
98119 // Default go to parent to set the breakpoint
99120 return spanInNode ( node . parent ) ;
@@ -210,6 +231,10 @@ module ts.BreakpointResolver {
210231 return textSpan ( whileStatement , findNextToken ( whileStatement . expression , whileStatement ) ) ;
211232 }
212233
234+ function spanInDoStatement ( doStatement : DoStatement ) : TypeScript . TextSpan {
235+ return spanInNode ( doStatement . statement ) ;
236+ }
237+
213238 // Tokens:
214239 function spanInCommaToken ( node : Node ) : TypeScript . TextSpan {
215240 switch ( node . parent . kind ) {
@@ -253,11 +278,33 @@ module ts.BreakpointResolver {
253278 }
254279 }
255280
281+ function spanInOpenParenToken ( node : Node ) : TypeScript . TextSpan {
282+ if ( node . parent . kind === SyntaxKind . DoStatement ) {
283+ // Go to while keyword and do action instead
284+ return spanInPreviousNode ( node ) ;
285+ }
286+
287+ // Default to parent node
288+ return spanInNode ( node . parent ) ;
289+ }
290+
256291 function spanInCloseParenToken ( node : Node ) : TypeScript . TextSpan {
257292 // Is this close paren token of parameter list, set span in previous token
258- if ( isAnyFunction ( node . parent ) ||
259- node . parent . kind === SyntaxKind . WhileStatement ) {
260- return spanInPreviousNode ( node ) ;
293+ switch ( node . parent . kind ) {
294+ case SyntaxKind . FunctionExpression :
295+ case SyntaxKind . FunctionDeclaration :
296+ case SyntaxKind . ArrowFunction :
297+ case SyntaxKind . Method :
298+ case SyntaxKind . GetAccessor :
299+ case SyntaxKind . SetAccessor :
300+ case SyntaxKind . Constructor :
301+ case SyntaxKind . WhileStatement :
302+ case SyntaxKind . DoStatement :
303+ return spanInPreviousNode ( node ) ;
304+
305+ // Default to parent node
306+ default :
307+ return spanInNode ( node . parent ) ;
261308 }
262309
263310 // Default to parent node
@@ -272,6 +319,16 @@ module ts.BreakpointResolver {
272319
273320 return spanInNode ( node . parent ) ;
274321 }
322+
323+ function spanInWhileKeyword ( node : Node ) : TypeScript . TextSpan {
324+ if ( node . parent . kind === SyntaxKind . DoStatement ) {
325+ // Set span on while expression
326+ return textSpan ( node , findNextToken ( ( < DoStatement > node . parent ) . expression , node . parent ) ) ;
327+ }
328+
329+ // Default to parent node
330+ return spanInNode ( node . parent ) ;
331+ }
275332 }
276333 }
277334}
0 commit comments