Skip to content

Commit 83e569e

Browse files
committed
Breakpoints on the node with decorator should start at actual syntax and not from decorators
1 parent 858a99b commit 83e569e

2 files changed

Lines changed: 38 additions & 59 deletions

File tree

src/services/breakpoints.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ namespace ts.BreakpointResolver {
3939
return spanInNode(tokenAtLocation);
4040

4141
function textSpan(startNode: Node, endNode?: Node) {
42-
return createTextSpanFromBounds(startNode.getStart(sourceFile), (endNode || startNode).getEnd());
42+
const start = startNode.decorators ?
43+
skipTrivia(sourceFile.text, startNode.decorators.end) :
44+
startNode.getStart(sourceFile);
45+
return createTextSpanFromBounds(start, (endNode || startNode).getEnd());
4346
}
4447

4548
function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan {

tests/baselines/reference/bpSpan_decorators.baseline

Lines changed: 34 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
--------------------------------
3030
8 >@ClassDecorator1
3131

32-
~ => Pos: (594 to 594) SpanInfo: {"start":594,"length":952}
33-
>@ClassDecorator1
34-
>@ClassDecorator2(10)
32+
~ => Pos: (594 to 594) SpanInfo: {"start":632,"length":914}
3533
>class Greeter {
3634
> constructor(
3735
> @ParameterDecorator1
@@ -77,7 +75,7 @@
7775
> this.greeting = greetings;
7876
> }
7977
>}
80-
>:=> (line 8, col 0) to (line 54, col 1)
78+
>:=> (line 10, col 0) to (line 54, col 1)
8179
8 >@ClassDecorator1
8280

8381
~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36}
@@ -94,9 +92,7 @@
9492
--------------------------------
9593
10 >class Greeter {
9694

97-
~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":594,"length":952}
98-
>@ClassDecorator1
99-
>@ClassDecorator2(10)
95+
~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":632,"length":914}
10096
>class Greeter {
10197
> constructor(
10298
> @ParameterDecorator1
@@ -142,7 +138,7 @@
142138
> this.greeting = greetings;
143139
> }
144140
>}
145-
>:=> (line 8, col 0) to (line 54, col 1)
141+
>:=> (line 10, col 0) to (line 54, col 1)
146142
--------------------------------
147143
11 > constructor(
148144

@@ -152,11 +148,9 @@
152148
--------------------------------
153149
12 > @ParameterDecorator1
154150

155-
~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":673,"length":85}
156-
>@ParameterDecorator1
157-
> @ParameterDecorator2(20)
158-
> public greeting: string
159-
>:=> (line 12, col 8) to (line 14, col 31)
151+
~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":735,"length":23}
152+
>public greeting: string
153+
>:=> (line 14, col 8) to (line 14, col 31)
160154
12 > @ParameterDecorator1
161155

162156
~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52}
@@ -173,23 +167,19 @@
173167
--------------------------------
174168
14 > public greeting: string,
175169

176-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":673,"length":85}
177-
>@ParameterDecorator1
178-
> @ParameterDecorator2(20)
179-
> public greeting: string
180-
>:=> (line 12, col 8) to (line 14, col 31)
170+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":735,"length":23}
171+
>public greeting: string
172+
>:=> (line 14, col 8) to (line 14, col 31)
181173
--------------------------------
182174
15 >
183175

184176
~ => Pos: (760 to 760) SpanInfo: undefined
185177
--------------------------------
186178
16 > @ParameterDecorator1
187179

188-
~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":769,"length":80}
189-
>@ParameterDecorator1
190-
> @ParameterDecorator2(30)
191-
> ...b: string[]
192-
>:=> (line 16, col 8) to (line 18, col 26)
180+
~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":835,"length":14}
181+
>...b: string[]
182+
>:=> (line 18, col 12) to (line 18, col 26)
193183
16 > @ParameterDecorator1
194184

195185
~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52}
@@ -206,11 +196,9 @@
206196
--------------------------------
207197
18 > ...b: string[]) {
208198

209-
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":769,"length":80}
210-
>@ParameterDecorator1
211-
> @ParameterDecorator2(30)
212-
> ...b: string[]
213-
>:=> (line 16, col 8) to (line 18, col 26)
199+
~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":835,"length":14}
200+
>...b: string[]
201+
>:=> (line 18, col 12) to (line 18, col 26)
214202
18 > ...b: string[]) {
215203

216204
~~~ => Pos: (850 to 852) SpanInfo: {"start":857,"length":1}
@@ -229,13 +217,11 @@
229217
--------------------------------
230218
21 > @PropertyDecorator1
231219

232-
~~~~~ => Pos: (860 to 864) SpanInfo: {"start":864,"length":116}
233-
>@PropertyDecorator1
234-
> @PropertyDecorator2(40)
235-
> greet() {
220+
~~~~~ => Pos: (860 to 864) SpanInfo: {"start":916,"length":64}
221+
>greet() {
236222
> return "<h1>" + this.greeting + "</h1>";
237223
> }
238-
>:=> (line 21, col 4) to (line 25, col 5)
224+
>:=> (line 23, col 4) to (line 25, col 5)
239225
21 > @PropertyDecorator1
240226

241227
~~~~~~~~~~~~~~~~~~~ => Pos: (865 to 883) SpanInfo: {"start":865,"length":46}
@@ -252,13 +238,11 @@
252238
--------------------------------
253239
23 > greet() {
254240

255-
~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":864,"length":116}
256-
>@PropertyDecorator1
257-
> @PropertyDecorator2(40)
258-
> greet() {
241+
~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":916,"length":64}
242+
>greet() {
259243
> return "<h1>" + this.greeting + "</h1>";
260244
> }
261-
>:=> (line 21, col 4) to (line 25, col 5)
245+
>:=> (line 23, col 4) to (line 25, col 5)
262246
23 > greet() {
263247

264248
~~~ => Pos: (923 to 925) SpanInfo: {"start":934,"length":39}
@@ -308,11 +292,9 @@
308292
--------------------------------
309293
31 > @PropertyDecorator1
310294

311-
~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1062,"length":83}
312-
>@PropertyDecorator1
313-
> @PropertyDecorator2(60)
314-
> private static x1: number = 10;
315-
>:=> (line 31, col 4) to (line 33, col 35)
295+
~~~~~ => Pos: (1058 to 1062) SpanInfo: {"start":1114,"length":31}
296+
>private static x1: number = 10;
297+
>:=> (line 33, col 4) to (line 33, col 35)
316298
31 > @PropertyDecorator1
317299

318300
~~~~~~~~~~~~~~~~~~~ => Pos: (1063 to 1081) SpanInfo: {"start":1063,"length":46}
@@ -329,11 +311,9 @@
329311
--------------------------------
330312
33 > private static x1: number = 10;
331313

332-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1062,"length":83}
333-
>@PropertyDecorator1
334-
> @PropertyDecorator2(60)
335-
> private static x1: number = 10;
336-
>:=> (line 31, col 4) to (line 33, col 35)
314+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1114,"length":31}
315+
>private static x1: number = 10;
316+
>:=> (line 33, col 4) to (line 33, col 35)
337317
--------------------------------
338318
34 >
339319

@@ -393,13 +373,11 @@
393373
--------------------------------
394374
42 > @PropertyDecorator1
395375

396-
~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1287,"length":105}
397-
>@PropertyDecorator1
398-
> @PropertyDecorator2(80)
399-
> get greetings() {
376+
~~~~~ => Pos: (1283 to 1287) SpanInfo: {"start":1339,"length":53}
377+
>get greetings() {
400378
> return this.greeting;
401379
> }
402-
>:=> (line 42, col 4) to (line 46, col 5)
380+
>:=> (line 44, col 4) to (line 46, col 5)
403381
42 > @PropertyDecorator1
404382

405383
~~~~~~~~~~~~~~~~~~~ => Pos: (1288 to 1306) SpanInfo: {"start":1288,"length":46}
@@ -416,13 +394,11 @@
416394
--------------------------------
417395
44 > get greetings() {
418396

419-
~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1287,"length":105}
420-
>@PropertyDecorator1
421-
> @PropertyDecorator2(80)
422-
> get greetings() {
397+
~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1339,"length":53}
398+
>get greetings() {
423399
> return this.greeting;
424400
> }
425-
>:=> (line 42, col 4) to (line 46, col 5)
401+
>:=> (line 44, col 4) to (line 46, col 5)
426402
44 > get greetings() {
427403

428404
~~~ => Pos: (1354 to 1356) SpanInfo: {"start":1365,"length":20}

0 commit comments

Comments
 (0)