Commit b4c3326
authored
Remove SyntaxTrivia from the compiler (#11702)
Currently, the syntax tree produced by the Razor compiler _looks_ like
it might support trivia. It even has a `SyntaxTrivia` class, methods on
`SyntaxNode` and `SyntaxToken` to handle leading and trailing trivia,
and methods on `SyntaxVisitor`, `SyntaxRewriter` and `SyntaxWalker` to
visit trivia. There're even separate properties that look like they
might provide different values depending on trivia, such as `Width` and
`FullWIdth`.
None of that is real.
The Razor parser doesn't actually produce trivia. The leading and
trailing trivia for a `SyntaxToken` is always empty. The `FullWIdth` and
`Width` properties always return the same value, as do `FullSpan` and
`Span`. Since there's so much infrastructure to support trivia, it seems
like the Razor compiler _might_ have generated it at some point, though
I suspect it was just left over from an old copy-paste from Roslyn and
never cleaned up.'
Honestly, it would be a major endeavor if the Razor compiler were
updated to support trivia, and I personally don't believe the value is
worth the effort. So, this change removes all of the compiler
infrastructure in support of syntax trivia. The goal is to make steps
toward eventually converting `SyntaxToken` to a struct. Today,
`SyntaxToken` is defined as a class, which consistently shows up as a
major source of allocations in perf traces.
I was pretty meticulous with my commit history and recommend reviewing
commit-by-commit. Most of the changes are deletions. 😄File tree
46 files changed
+149
-1852
lines changed- src
- Compiler
- Microsoft.AspNetCore.Razor.Language
- legacyTest/Legacy
- test/Legacy
- Microsoft.CodeAnalysis.Razor.Compiler/src/Language
- Legacy
- Syntax
- InternalSyntax
- Razor
- src
- Microsoft.AspNetCore.Razor.LanguageServer
- MapCode
- WrapWithTag
- Microsoft.CodeAnalysis.Razor.Workspaces
- CodeActions/Razor
- Completion
- Diagnostics
- Extensions
- Formatting
- Hover
- Rename
- test/Microsoft.VisualStudio.LegacyEditor.Razor.Test/Parsing
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
46 files changed
+149
-1852
lines changedLines changed: 13 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
356 | 355 | | |
357 | 356 | | |
358 | 357 | | |
359 | | - | |
360 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
365 | | - | |
366 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
367 | 370 | | |
368 | | - | |
369 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
370 | 375 | | |
371 | 376 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1251 | 1251 | | |
1252 | 1252 | | |
1253 | 1253 | | |
1254 | | - | |
| 1254 | + | |
1255 | 1255 | | |
1256 | 1256 | | |
1257 | 1257 | | |
| |||
2223 | 2223 | | |
2224 | 2224 | | |
2225 | 2225 | | |
2226 | | - | |
| 2226 | + | |
2227 | 2227 | | |
2228 | 2228 | | |
2229 | 2229 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
1247 | | - | |
| 1247 | + | |
1248 | 1248 | | |
1249 | 1249 | | |
1250 | 1250 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1783 | 1783 | | |
1784 | 1784 | | |
1785 | 1785 | | |
1786 | | - | |
| 1786 | + | |
1787 | 1787 | | |
1788 | 1788 | | |
1789 | 1789 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
| 477 | + | |
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
0 commit comments