Skip to content

Commit 0cc8132

Browse files
author
Harlan
authored
[Syntax] Serialize top level decls as an array (#10405)
* Serialize TopLevelDecls as an array of raw syntax nodes, instead of one-after-another. * Add tests for multiple decls * Remove extra newlines from test inputs
1 parent bc73e43 commit 0cc8132

File tree

4 files changed

+407
-241
lines changed

4 files changed

+407
-241
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
[
2+
{
3+
"kind": "UnknownDecl",
4+
"layout": [
5+
{
6+
"tokenKind": {
7+
"kind": "kw_struct",
8+
"text": "struct"
9+
},
10+
"leadingTrivia": [
11+
{
12+
"kind": "LineComment",
13+
"value": "\/\/ RUN: %swift-syntax-test -input-source-filename %s -serialize-raw-tree > %t"
14+
},
15+
{
16+
"kind": "Newline",
17+
"value": 1
18+
},
19+
{
20+
"kind": "LineComment",
21+
"value": "\/\/ RUN: diff %t %S\/Inputs\/serialize_multiple_decls.json"
22+
},
23+
{
24+
"kind": "Newline",
25+
"value": 2
26+
}
27+
],
28+
"trailingTrivia": [
29+
{
30+
"kind": "Space",
31+
"value": 1
32+
}
33+
],
34+
"presence": "Present"
35+
},
36+
{
37+
"tokenKind": {
38+
"kind": "identifier",
39+
"text": "A"
40+
},
41+
"leadingTrivia": [
42+
43+
],
44+
"trailingTrivia": [
45+
{
46+
"kind": "Space",
47+
"value": 1
48+
}
49+
],
50+
"presence": "Present"
51+
},
52+
{
53+
"tokenKind": {
54+
"kind": "l_brace",
55+
"text": "{"
56+
},
57+
"leadingTrivia": [
58+
59+
],
60+
"trailingTrivia": [
61+
62+
],
63+
"presence": "Present"
64+
},
65+
{
66+
"tokenKind": {
67+
"kind": "r_brace",
68+
"text": "}"
69+
},
70+
"leadingTrivia": [
71+
{
72+
"kind": "Newline",
73+
"value": 1
74+
}
75+
],
76+
"trailingTrivia": [
77+
78+
],
79+
"presence": "Present"
80+
}
81+
],
82+
"presence": "Present"
83+
},
84+
{
85+
"kind": "UnknownDecl",
86+
"layout": [
87+
{
88+
"tokenKind": {
89+
"kind": "kw_struct",
90+
"text": "struct"
91+
},
92+
"leadingTrivia": [
93+
{
94+
"kind": "Newline",
95+
"value": 2
96+
}
97+
],
98+
"trailingTrivia": [
99+
{
100+
"kind": "Space",
101+
"value": 1
102+
}
103+
],
104+
"presence": "Present"
105+
},
106+
{
107+
"tokenKind": {
108+
"kind": "identifier",
109+
"text": "B"
110+
},
111+
"leadingTrivia": [
112+
113+
],
114+
"trailingTrivia": [
115+
{
116+
"kind": "Space",
117+
"value": 1
118+
}
119+
],
120+
"presence": "Present"
121+
},
122+
{
123+
"tokenKind": {
124+
"kind": "l_brace",
125+
"text": "{"
126+
},
127+
"leadingTrivia": [
128+
129+
],
130+
"trailingTrivia": [
131+
132+
],
133+
"presence": "Present"
134+
},
135+
{
136+
"tokenKind": {
137+
"kind": "r_brace",
138+
"text": "}"
139+
},
140+
"leadingTrivia": [
141+
{
142+
"kind": "Newline",
143+
"value": 1
144+
}
145+
],
146+
"trailingTrivia": [
147+
148+
],
149+
"presence": "Present"
150+
}
151+
],
152+
"presence": "Present"
153+
}
154+
]

0 commit comments

Comments
 (0)