diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 65720f024d7..22b28cd3ffe 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -182,6 +182,7 @@ module ts.BreakpointResolver { return undefined; } + case SyntaxKind.ClassDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.EnumMember: case SyntaxKind.CallExpression: @@ -189,9 +190,6 @@ module ts.BreakpointResolver { // span on complete node return textSpan(node); - case SyntaxKind.ClassDeclaration: - return spanInClassDeclaration(node); - case SyntaxKind.WithStatement: // span in statement return spanInNode((node).statement); @@ -387,14 +385,6 @@ module ts.BreakpointResolver { } } - function spanInClassDeclaration(classDeclaration: ClassDeclaration): TypeScript.TextSpan { - if (classDeclaration.members.length) { - return spanInNode(classDeclaration.members[0]); - } - - return spanInNode(classDeclaration.getLastToken()); - } - // Tokens: function spanInOpenBraceToken(node: Node): TypeScript.TextSpan { switch (node.parent.kind) { @@ -402,6 +392,10 @@ module ts.BreakpointResolver { var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); + case SyntaxKind.ClassDeclaration: + var classDeclaration = node.parent; + return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); + case SyntaxKind.SwitchStatement: return spanInNodeIfStartsOnSameLine(node.parent, (node.parent).clauses[0]); } diff --git a/tests/baselines/reference/bpSpan_class.baseline b/tests/baselines/reference/bpSpan_class.baseline index a628510bb9e..816df2168fa 100644 --- a/tests/baselines/reference/bpSpan_class.baseline +++ b/tests/baselines/reference/bpSpan_class.baseline @@ -1,9 +1,26 @@ 1 >class Greeter { - ~~~~~~~~~~~~~~~~ => Pos: (0 to 15) SpanInfo: {"start":79,"length":1} + ~~~~~~~~~~~~~~~~ => Pos: (0 to 15) SpanInfo: {"start":0,"length":396} + >class Greeter { + > constructor(public greeting: string, ...b: string[]) { + > } + > greet() { + > return "

" + this.greeting + "

"; + > } + > private x: string; + > private x1: number = 10; + > private fn() { + > return this.greeting; + > } + > get greetings() { + > return this.greeting; + > } + > set greetings(greetings: string) { + > this.greeting = greetings; + > } >} - >:=> (line 3, col 4) to (line 3, col 5) + >:=> (line 1, col 0) to (line 18, col 1) -------------------------------- 2 > constructor(public greeting: string, ...b: string[]) { @@ -115,6 +132,214 @@ >:=> (line 17, col 4) to (line 17, col 5) -------------------------------- 18 >} - ~ => Pos: (395 to 395) SpanInfo: {"start":395,"length":1} + + ~~ => Pos: (395 to 396) SpanInfo: {"start":395,"length":1} >} - >:=> (line 18, col 0) to (line 18, col 1) \ No newline at end of file + >:=> (line 18, col 0) to (line 18, col 1) +-------------------------------- +19 >class Greeter2 { + + ~~~~~~~~~~~~~~~~~ => Pos: (397 to 413) SpanInfo: {"start":397,"length":18} + >class Greeter2 { + >} + >:=> (line 19, col 0) to (line 20, col 1) +-------------------------------- +20 >} + + ~~ => Pos: (414 to 415) SpanInfo: {"start":414,"length":1} + >} + >:=> (line 20, col 0) to (line 20, col 1) +-------------------------------- +21 >class Greeter1 + + ~~~~~~~~~~~~~~~~ => Pos: (416 to 431) SpanInfo: {"start":416,"length":419} + >class Greeter1 + >{ + > constructor(public greeting: string, ...b: string[]) + > { + > } + > greet() + > { + > return "

" + this.greeting + "

"; + > } + > private x: string; + > private x1: number = 10; + > private fn() + > { + > return this.greeting; + > } + > get greetings() + > { + > return this.greeting; + > } + > set greetings(greetings: string) + > { + > this.greeting = greetings; + > } + >} + >:=> (line 21, col 0) to (line 44, col 1) +-------------------------------- +22 >{ + + ~~ => Pos: (432 to 433) SpanInfo: {"start":501,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +-------------------------------- +23 > constructor(public greeting: string, ...b: string[]) + + ~~~~~~~~~~~~~~~~ => Pos: (434 to 449) SpanInfo: {"start":501,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +23 > constructor(public greeting: string, ...b: string[]) + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (450 to 473) SpanInfo: {"start":450,"length":23} + >public greeting: string + >:=> (line 23, col 16) to (line 23, col 39) +23 > constructor(public greeting: string, ...b: string[]) + + ~~~~~~~~~~~~~~~~~=> Pos: (474 to 490) SpanInfo: {"start":475,"length":14} + >...b: string[] + >:=> (line 23, col 41) to (line 23, col 55) +-------------------------------- +24 > { + + ~~~~~~ => Pos: (491 to 496) SpanInfo: {"start":501,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +-------------------------------- +25 > } + + ~~~~~~ => Pos: (497 to 502) SpanInfo: {"start":501,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +-------------------------------- +26 > greet() + + ~~~~~~~~~~~~ => Pos: (503 to 514) SpanInfo: {"start":529,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 28, col 8) to (line 28, col 47) +-------------------------------- +27 > { + + ~~~~~~ => Pos: (515 to 520) SpanInfo: {"start":529,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 28, col 8) to (line 28, col 47) +-------------------------------- +28 > return "

" + this.greeting + "

"; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (521 to 569) SpanInfo: {"start":529,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 28, col 8) to (line 28, col 47) +-------------------------------- +29 > } + + ~~~~~~ => Pos: (570 to 575) SpanInfo: {"start":574,"length":1} + >} + >:=> (line 29, col 4) to (line 29, col 5) +-------------------------------- +30 > private x: string; + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (576 to 598) SpanInfo: undefined +-------------------------------- +31 > private x1: number = 10; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (599 to 627) SpanInfo: {"start":603,"length":24} + >private x1: number = 10; + >:=> (line 31, col 4) to (line 31, col 28) +-------------------------------- +32 > private fn() + + ~~~~~~~~~~~~~~~~~ => Pos: (628 to 644) SpanInfo: {"start":659,"length":20} + >return this.greeting + >:=> (line 34, col 8) to (line 34, col 28) +-------------------------------- +33 > { + + ~~~~~~ => Pos: (645 to 650) SpanInfo: {"start":659,"length":20} + >return this.greeting + >:=> (line 34, col 8) to (line 34, col 28) +-------------------------------- +34 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (651 to 680) SpanInfo: {"start":659,"length":20} + >return this.greeting + >:=> (line 34, col 8) to (line 34, col 28) +-------------------------------- +35 > } + + ~~~~~~ => Pos: (681 to 686) SpanInfo: {"start":685,"length":1} + >} + >:=> (line 35, col 4) to (line 35, col 5) +-------------------------------- +36 > get greetings() + + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (687 to 707) SpanInfo: {"start":722,"length":20} + >return this.greeting + >:=> (line 38, col 8) to (line 38, col 28) +-------------------------------- +37 > { + + ~~~~~~ => Pos: (708 to 713) SpanInfo: {"start":722,"length":20} + >return this.greeting + >:=> (line 38, col 8) to (line 38, col 28) +-------------------------------- +38 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (714 to 743) SpanInfo: {"start":722,"length":20} + >return this.greeting + >:=> (line 38, col 8) to (line 38, col 28) +-------------------------------- +39 > } + + ~~~~~~ => Pos: (744 to 749) SpanInfo: {"start":748,"length":1} + >} + >:=> (line 39, col 4) to (line 39, col 5) +-------------------------------- +40 > set greetings(greetings: string) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (750 to 786) SpanInfo: {"start":801,"length":25} + >this.greeting = greetings + >:=> (line 42, col 8) to (line 42, col 33) +-------------------------------- +41 > { + + ~~~~~~ => Pos: (787 to 792) SpanInfo: {"start":801,"length":25} + >this.greeting = greetings + >:=> (line 42, col 8) to (line 42, col 33) +-------------------------------- +42 > this.greeting = greetings; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (793 to 827) SpanInfo: {"start":801,"length":25} + >this.greeting = greetings + >:=> (line 42, col 8) to (line 42, col 33) +-------------------------------- +43 > } + + ~~~~~~ => Pos: (828 to 833) SpanInfo: {"start":832,"length":1} + >} + >:=> (line 43, col 4) to (line 43, col 5) +-------------------------------- +44 >} + + ~~ => Pos: (834 to 835) SpanInfo: {"start":834,"length":1} + >} + >:=> (line 44, col 0) to (line 44, col 1) +-------------------------------- +45 >class Greeter12 + + ~~~~~~~~~~~~~~~~ => Pos: (836 to 851) SpanInfo: {"start":836,"length":19} + >class Greeter12 + >{ + >} + >:=> (line 45, col 0) to (line 47, col 1) +-------------------------------- +46 >{ + + ~~ => Pos: (852 to 853) SpanInfo: {"start":854,"length":1} + >} + >:=> (line 47, col 0) to (line 47, col 1) +-------------------------------- +47 >} + ~ => Pos: (854 to 854) SpanInfo: {"start":854,"length":1} + >} + >:=> (line 47, col 0) to (line 47, col 1) \ No newline at end of file diff --git a/tests/baselines/reference/bpSpan_classes.baseline b/tests/baselines/reference/bpSpan_classes.baseline index 90d99c85ee5..e9de5123d1c 100644 --- a/tests/baselines/reference/bpSpan_classes.baseline +++ b/tests/baselines/reference/bpSpan_classes.baseline @@ -92,9 +92,16 @@ -------------------------------- 4 > class Greeter { - ~~~~~~~~~~~~~~~~~~~~ => Pos: (36 to 55) SpanInfo: {"start":111,"length":1} - >} - >:=> (line 6, col 8) to (line 6, col 9) + ~~~~~~~~~~~~~~~~~~~~ => Pos: (36 to 55) SpanInfo: {"start":40,"length":160} + >class Greeter { + > constructor(public greeting: string) { + > } + > + > greet() { + > return "

" + this.greeting + "

"; + > } + > } + >:=> (line 4, col 4) to (line 11, col 5) -------------------------------- 5 > constructor(public greeting: string) { diff --git a/tests/baselines/reference/bpSpan_exportAssignment.baseline b/tests/baselines/reference/bpSpan_exportAssignment.baseline index 9086e218329..a9d635a929c 100644 --- a/tests/baselines/reference/bpSpan_exportAssignment.baseline +++ b/tests/baselines/reference/bpSpan_exportAssignment.baseline @@ -1,7 +1,11 @@ 1 >class a { - ~~~~~~~~~~ => Pos: (0 to 9) SpanInfo: undefined + ~~~~~~~~~~ => Pos: (0 to 9) SpanInfo: {"start":0,"length":25} + >class a { + > public c; + >} + >:=> (line 1, col 0) to (line 3, col 1) -------------------------------- 2 > public c; diff --git a/tests/baselines/reference/bpSpan_import.baseline b/tests/baselines/reference/bpSpan_import.baseline index 7c8e35125f5..26279b48f26 100644 --- a/tests/baselines/reference/bpSpan_import.baseline +++ b/tests/baselines/reference/bpSpan_import.baseline @@ -10,9 +10,10 @@ -------------------------------- 2 > class c { - ~~~~~~~~~~~~~~ => Pos: (11 to 24) SpanInfo: {"start":29,"length":1} - >} - >:=> (line 3, col 4) to (line 3, col 5) + ~~~~~~~~~~~~~~ => Pos: (11 to 24) SpanInfo: {"start":15,"length":15} + >class c { + > } + >:=> (line 2, col 4) to (line 3, col 5) -------------------------------- 3 > } diff --git a/tests/baselines/reference/bpSpan_parenCallOrNewExpressions.baseline b/tests/baselines/reference/bpSpan_parenCallOrNewExpressions.baseline index 80692f05178..47c932640f9 100644 --- a/tests/baselines/reference/bpSpan_parenCallOrNewExpressions.baseline +++ b/tests/baselines/reference/bpSpan_parenCallOrNewExpressions.baseline @@ -128,9 +128,12 @@ -------------------------------- 10 >class greeter { - ~~~~~~~~~~~~~~~~ => Pos: (146 to 161) SpanInfo: {"start":195,"length":1} + ~~~~~~~~~~~~~~~~ => Pos: (146 to 161) SpanInfo: {"start":146,"length":52} + >class greeter { + > constructor(a: number) { + > } >} - >:=> (line 12, col 4) to (line 12, col 5) + >:=> (line 10, col 0) to (line 13, col 1) -------------------------------- 11 > constructor(a: number) { diff --git a/tests/baselines/reference/bpSpan_typeAssertionExpressions.baseline b/tests/baselines/reference/bpSpan_typeAssertionExpressions.baseline index f73b47d8519..c04ddb8503b 100644 --- a/tests/baselines/reference/bpSpan_typeAssertionExpressions.baseline +++ b/tests/baselines/reference/bpSpan_typeAssertionExpressions.baseline @@ -1,9 +1,10 @@ 1 >class Greeter { - ~~~~~~~~~~~~~~~~ => Pos: (0 to 15) SpanInfo: {"start":16,"length":1} + ~~~~~~~~~~~~~~~~ => Pos: (0 to 15) SpanInfo: {"start":0,"length":17} + >class Greeter { >} - >:=> (line 2, col 0) to (line 2, col 1) + >:=> (line 1, col 0) to (line 2, col 1) -------------------------------- 2 >} diff --git a/tests/cases/fourslash/breakpointValidationClass.ts b/tests/cases/fourslash/breakpointValidationClass.ts index e9104bc6d27..99209c465b2 100644 --- a/tests/cases/fourslash/breakpointValidationClass.ts +++ b/tests/cases/fourslash/breakpointValidationClass.ts @@ -20,4 +20,34 @@ //// this.greeting = greetings; //// } ////} +////class Greeter2 { +////} +////class Greeter1 +////{ +//// constructor(public greeting: string, ...b: string[]) +//// { +//// } +//// greet() +//// { +//// return "

" + this.greeting + "

"; +//// } +//// private x: string; +//// private x1: number = 10; +//// private fn() +//// { +//// return this.greeting; +//// } +//// get greetings() +//// { +//// return this.greeting; +//// } +//// set greetings(greetings: string) +//// { +//// this.greeting = greetings; +//// } +////} +////class Greeter12 +////{ +////} + verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file