Do not set breakpoints on the blank line or comment only line

This commit is contained in:
Sheetal Nandi
2014-10-20 23:01:06 -07:00
parent 0cb2e983aa
commit 4a8a8920a2
7 changed files with 67 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ module ts.BreakpointResolver {
export function spanInSourceFileAtLocation(sourceFile: SourceFile, position: number) {
// Cannot set breakpoint in dts file
if (sourceFile.flags & NodeFlags.DeclarationFile) {
return;
return undefined;
}
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
@@ -22,11 +22,16 @@ module ts.BreakpointResolver {
// token at position will return var keyword on second line as the token but we would like to use
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
// Its a blank line
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
return undefined;
}
}
// Cannot set breakpoint in ambient declarations
if (isInAmbientContext(tokenAtLocation)) {
return;
return undefined;
}
// Get the span in the node based on its syntax

View File

@@ -45,9 +45,7 @@
--------------------------------
7 >
~ => Pos: (113 to 113) SpanInfo: {"start":111,"length":1}
>}
>:=> (line 6, col 8) to (line 6, col 9)
~ => Pos: (113 to 113) SpanInfo: undefined
--------------------------------
8 > greet() {
@@ -75,15 +73,11 @@
--------------------------------
12 >
~ => Pos: (201 to 201) SpanInfo: {"start":199,"length":1}
>}
>:=> (line 11, col 4) to (line 11, col 5)
~ => Pos: (201 to 201) SpanInfo: undefined
--------------------------------
13 >
~ => Pos: (202 to 202) SpanInfo: {"start":199,"length":1}
>}
>:=> (line 11, col 4) to (line 11, col 5)
~ => Pos: (202 to 202) SpanInfo: undefined
--------------------------------
14 > function foo(greeting: string): Greeter {
@@ -110,9 +104,7 @@
--------------------------------
17 >
~ => Pos: (293 to 293) SpanInfo: {"start":291,"length":1}
>}
>:=> (line 16, col 4) to (line 16, col 5)
~ => Pos: (293 to 293) SpanInfo: undefined
--------------------------------
18 > var greeter = new Greeter("Hello, world!");
@@ -213,9 +205,7 @@
--------------------------------
27 >
~ => Pos: (695 to 695) SpanInfo: {"start":639,"length":44}
>greeters.push(new Greeter(restGreetings[i]))
>:=> (line 25, col 12) to (line 25, col 56)
~ => Pos: (695 to 695) SpanInfo: undefined
--------------------------------
28 > return greeters;
@@ -231,9 +221,7 @@
--------------------------------
30 >
~ => Pos: (727 to 727) SpanInfo: {"start":725,"length":1}
>}
>:=> (line 29, col 4) to (line 29, col 5)
~ => Pos: (727 to 727) SpanInfo: undefined
--------------------------------
31 > var b = foo2("Hello", "World", "!");

View File

@@ -0,0 +1,15 @@
1 >var x = 10;
~~~~~~~~~~~~ => Pos: (0 to 11) SpanInfo: {"start":0,"length":10}
>var x = 10
>:=> (line 1, col 0) to (line 1, col 10)
--------------------------------
2 >
~ => Pos: (12 to 12) SpanInfo: undefined
--------------------------------
3 >var y = 10;
~~~~~~~~~~~ => Pos: (13 to 23) SpanInfo: {"start":13,"length":10}
>var y = 10
>:=> (line 3, col 0) to (line 3, col 10)

View File

@@ -0,0 +1,19 @@
1 >/*comment here*/ var x = 10; /*comment here*/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (0 to 45) SpanInfo: {"start":17,"length":10}
>var x = 10
>:=> (line 1, col 17) to (line 1, col 27)
--------------------------------
2 >// comment only line
~~~~~~~~~~~~~~~~~~~~~ => Pos: (46 to 66) SpanInfo: undefined
--------------------------------
3 >/*multiline comment
~~~~~~~~~~~~~~~~~~~~ => Pos: (67 to 86) SpanInfo: undefined
--------------------------------
4 >another line of multiline comment */ var y = 10; // comment here
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (87 to 150) SpanInfo: {"start":124,"length":10}
>var y = 10
>:=> (line 4, col 37) to (line 4, col 47)

View File

@@ -49,9 +49,7 @@
--------------------------------
9 >
~ => Pos: (100 to 100) SpanInfo: {"start":98,"length":1}
>}
>:=> (line 8, col 4) to (line 8, col 5)
~ => Pos: (100 to 100) SpanInfo: undefined
--------------------------------
10 > export function foo() {

View File

@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_inBlankLine.baseline
// @Filename: bpSpan_inBlankLine.ts
////var x = 10;
////
////var y = 10;
verify.baselineCurrentFileBreakpointLocations();

View File

@@ -0,0 +1,10 @@
/// <reference path='fourslash.ts' />
// @BaselineFile: bpSpan_inComments.baseline
// @Filename: bpSpan_inComments.ts
/////*comment here*/ var x = 10; /*comment here*/
////// comment only line
/////*multiline comment
////another line of multiline comment */ var y = 10; // comment here
verify.baselineCurrentFileBreakpointLocations();