Commit 3dbeb42
Intern comments in computed property keys
Summary:
Interns leading and trailing comments for computed object property keys. Comments preceding the opening brace will be attached as leading comments, and comments succeeding the closing brace will be attached as trailing comments. Comments within the braces will be attached to the inner expression.
```
{ /* L computed */ [ /* L expr */ expr /* T expr */ ] /* T computed */ : value }
```
Both object expressions and patterns can have computed keys of the same form, so I created a new shared `ComputedKey` node in the AST to share logic between computd object keys and computed expression keys. This `ComputedKey` module contains a new record type so that both the coments and inner expression can be stored. The new `ComputedKey` node also keeps track of the loc for the overall computed key (beginning at the opening brace and ending at the closing brace), which is needed in the ast differ and the printer.
Reviewed By: pieterv
Differential Revision: D20350642
fbshipit-source-id: bff29e48e62e11e3456efec4fdfd13b82daae78b1 parent dfb5b41 commit 3dbeb42
File tree
15 files changed
+386
-121
lines changed- src
- parser_utils
- output
- parser
- test/flow/comment_interning
- typing
15 files changed
+386
-121
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
851 | | - | |
| 851 | + | |
852 | 852 | | |
853 | 853 | | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
858 | 859 | | |
859 | 860 | | |
860 | 861 | | |
| |||
865 | 866 | | |
866 | 867 | | |
867 | 868 | | |
| 869 | + | |
868 | 870 | | |
869 | 871 | | |
870 | 872 | | |
| |||
899 | 901 | | |
900 | 902 | | |
901 | 903 | | |
902 | | - | |
| 904 | + | |
903 | 905 | | |
904 | | - | |
905 | | - | |
| 906 | + | |
| 907 | + | |
906 | 908 | | |
907 | 909 | | |
908 | | - | |
| 910 | + | |
| 911 | + | |
909 | 912 | | |
910 | 913 | | |
911 | 914 | | |
| |||
928 | 931 | | |
929 | 932 | | |
930 | 933 | | |
931 | | - | |
| 934 | + | |
932 | 935 | | |
933 | 936 | | |
934 | 937 | | |
| |||
1067 | 1070 | | |
1068 | 1071 | | |
1069 | 1072 | | |
1070 | | - | |
| 1073 | + | |
1071 | 1074 | | |
1072 | | - | |
1073 | | - | |
| 1075 | + | |
| 1076 | + | |
1074 | 1077 | | |
1075 | | - | |
| 1078 | + | |
| 1079 | + | |
1076 | 1080 | | |
1077 | 1081 | | |
| 1082 | + | |
1078 | 1083 | | |
1079 | 1084 | | |
1080 | 1085 | | |
| |||
1091 | 1096 | | |
1092 | 1097 | | |
1093 | 1098 | | |
1094 | | - | |
| 1099 | + | |
1095 | 1100 | | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1099 | 1105 | | |
1100 | 1106 | | |
1101 | 1107 | | |
| |||
1105 | 1111 | | |
1106 | 1112 | | |
1107 | 1113 | | |
| 1114 | + | |
1108 | 1115 | | |
1109 | 1116 | | |
1110 | 1117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
105 | 116 | | |
106 | 117 | | |
107 | 118 | | |
| |||
889 | 900 | | |
890 | 901 | | |
891 | 902 | | |
892 | | - | |
| 903 | + | |
893 | 904 | | |
894 | 905 | | |
895 | 906 | | |
| |||
1367 | 1378 | | |
1368 | 1379 | | |
1369 | 1380 | | |
1370 | | - | |
| 1381 | + | |
1371 | 1382 | | |
1372 | 1383 | | |
1373 | 1384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
| |||
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | | - | |
| 195 | + | |
188 | 196 | | |
189 | 197 | | |
190 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments