Commit b786066
authored
Modify RazorCSharpDocument to keep SourceMappings sorted by both original and generated document positions (#12772)
* Modify RazorCSharpDocument to keep sourcemappings sorted by both Original and Generated document indices
This class previously just kept an array that was sorted by generated positions. Many callers would benefit instead from an array sorted by original (html) posititions. This allows many loops to short-circuit once they've moved beyond any mappings that could be of interest to them.
This also renamed the original array to indicate it's sorted by generated positions, and to validate that upon it's input, as some callers were assuming that. By renaming this variable, it will hopefully make callers
1) Aware that the input is sorted and may be short-circuited or binary searched
2) Aware what it is sorted by (eg: formatting had some code that was assuming the array was sorted by original position)
* Be more resilient to bad input
* Use Debug.Fail
* Fix test to do different validation in debug/release1 parent 4abe6ad commit b786066
File tree
20 files changed
+176
-62
lines changed- src
- Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language
- Razor
- benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/LanguageServer
- src
- Microsoft.AspNetCore.Razor.ExternalAccess.LegacyEditor
- Microsoft.CodeAnalysis.Razor.Workspaces
- DocumentExcerpt
- DocumentMapping
- Extensions
- Formatting/Passes
- SemanticTokens
- Microsoft.CodeAnalysis.Remote.Razor/DocumentMapping
- Microsoft.VisualStudio.LanguageServices.Razor/DynamicFiles
- Microsoft.VisualStudio.RazorExtension/SyntaxVisualizer
- test
- Microsoft.AspNetCore.Razor.LanguageServer.Test
- Microsoft.VisualStudio.LanguageServices.Razor.Test
20 files changed
+176
-62
lines changedLines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
33 | 49 | | |
34 | 50 | | |
35 | 51 | | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
118 | 129 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
Lines changed: 14 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | 27 | | |
30 | 28 | | |
31 | 29 | | |
32 | 30 | | |
33 | | - | |
34 | | - | |
| 31 | + | |
35 | 32 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 33 | + | |
| 34 | + | |
40 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
Lines changed: 22 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 289 | + | |
289 | 290 | | |
290 | 291 | | |
291 | 292 | | |
| |||
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
337 | | - | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
364 | 370 | | |
365 | 371 | | |
366 | 372 | | |
| |||
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
| 443 | + | |
437 | 444 | | |
438 | 445 | | |
439 | 446 | | |
440 | 447 | | |
441 | | - | |
| 448 | + | |
442 | 449 | | |
443 | 450 | | |
444 | 451 | | |
445 | 452 | | |
446 | 453 | | |
447 | | - | |
| 454 | + | |
448 | 455 | | |
449 | 456 | | |
450 | 457 | | |
451 | 458 | | |
452 | 459 | | |
453 | | - | |
| 460 | + | |
454 | 461 | | |
455 | 462 | | |
456 | 463 | | |
| |||
503 | 510 | | |
504 | 511 | | |
505 | 512 | | |
| 513 | + | |
506 | 514 | | |
507 | | - | |
| 515 | + | |
508 | 516 | | |
509 | | - | |
| 517 | + | |
510 | 518 | | |
511 | 519 | | |
512 | 520 | | |
513 | 521 | | |
514 | 522 | | |
515 | 523 | | |
516 | | - | |
| 524 | + | |
517 | 525 | | |
518 | 526 | | |
519 | | - | |
| 527 | + | |
520 | 528 | | |
521 | 529 | | |
522 | 530 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
0 commit comments