1 module treevisitor;
2 
3 import std.traits : Unqual;
4 import ast;
5 import visitor;
6 import tokenmodule;
7 
8 class TreeVisitor : Visitor {
9 	import std.stdio : write, writeln;
10 
11 	alias accept = Visitor.accept;
12 
13 	int depth;
14 
15 	this(int d) {
16 		this.depth = d;
17 	}
18 
19 	void genIndent() {
20 		foreach(i; 0 .. this.depth) {
21 			write("    ");
22 		}
23 	}
24 
25 	override void accept(const(Document) obj) {
26 		this.genIndent();
27 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
28 		++this.depth;
29 		super.accept(obj);
30 		--this.depth;
31 	}
32 
33 	override void accept(const(Definitions) obj) {
34 		this.genIndent();
35 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
36 		++this.depth;
37 		super.accept(obj);
38 		--this.depth;
39 	}
40 
41 	override void accept(const(Definition) obj) {
42 		this.genIndent();
43 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
44 		++this.depth;
45 		super.accept(obj);
46 		--this.depth;
47 	}
48 
49 	override void accept(const(OperationDefinition) obj) {
50 		this.genIndent();
51 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
52 		++this.depth;
53 		super.accept(obj);
54 		--this.depth;
55 	}
56 
57 	override void accept(const(SelectionSet) obj) {
58 		this.genIndent();
59 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
60 		++this.depth;
61 		super.accept(obj);
62 		--this.depth;
63 	}
64 
65 	override void accept(const(OperationType) obj) {
66 		this.genIndent();
67 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
68 		++this.depth;
69 		super.accept(obj);
70 		--this.depth;
71 	}
72 
73 	override void accept(const(Selections) obj) {
74 		this.genIndent();
75 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
76 		++this.depth;
77 		super.accept(obj);
78 		--this.depth;
79 	}
80 
81 	override void accept(const(Selection) obj) {
82 		this.genIndent();
83 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
84 		++this.depth;
85 		super.accept(obj);
86 		--this.depth;
87 	}
88 
89 	override void accept(const(FragmentSpread) obj) {
90 		this.genIndent();
91 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
92 		++this.depth;
93 		super.accept(obj);
94 		--this.depth;
95 	}
96 
97 	override void accept(const(InlineFragment) obj) {
98 		this.genIndent();
99 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
100 		++this.depth;
101 		super.accept(obj);
102 		--this.depth;
103 	}
104 
105 	override void accept(const(Field) obj) {
106 		this.genIndent();
107 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
108 		++this.depth;
109 		super.accept(obj);
110 		--this.depth;
111 	}
112 
113 	override void accept(const(FieldName) obj) {
114 		this.genIndent();
115 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
116 		++this.depth;
117 		super.accept(obj);
118 		--this.depth;
119 	}
120 
121 	override void accept(const(Arguments) obj) {
122 		this.genIndent();
123 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
124 		++this.depth;
125 		super.accept(obj);
126 		--this.depth;
127 	}
128 
129 	override void accept(const(ArgumentList) obj) {
130 		this.genIndent();
131 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
132 		++this.depth;
133 		super.accept(obj);
134 		--this.depth;
135 	}
136 
137 	override void accept(const(Argument) obj) {
138 		this.genIndent();
139 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
140 		++this.depth;
141 		super.accept(obj);
142 		--this.depth;
143 	}
144 
145 	override void accept(const(FragmentDefinition) obj) {
146 		this.genIndent();
147 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
148 		++this.depth;
149 		super.accept(obj);
150 		--this.depth;
151 	}
152 
153 	override void accept(const(Directives) obj) {
154 		this.genIndent();
155 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
156 		++this.depth;
157 		super.accept(obj);
158 		--this.depth;
159 	}
160 
161 	override void accept(const(Directive) obj) {
162 		this.genIndent();
163 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
164 		++this.depth;
165 		super.accept(obj);
166 		--this.depth;
167 	}
168 
169 	override void accept(const(VariableDefinitions) obj) {
170 		this.genIndent();
171 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
172 		++this.depth;
173 		super.accept(obj);
174 		--this.depth;
175 	}
176 
177 	override void accept(const(VariableDefinitionList) obj) {
178 		this.genIndent();
179 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
180 		++this.depth;
181 		super.accept(obj);
182 		--this.depth;
183 	}
184 
185 	override void accept(const(VariableDefinition) obj) {
186 		this.genIndent();
187 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
188 		++this.depth;
189 		super.accept(obj);
190 		--this.depth;
191 	}
192 
193 	override void accept(const(Variable) obj) {
194 		this.genIndent();
195 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
196 		++this.depth;
197 		super.accept(obj);
198 		--this.depth;
199 	}
200 
201 	override void accept(const(DefaultValue) obj) {
202 		this.genIndent();
203 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
204 		++this.depth;
205 		super.accept(obj);
206 		--this.depth;
207 	}
208 
209 	override void accept(const(ValueOrVariable) obj) {
210 		this.genIndent();
211 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
212 		++this.depth;
213 		super.accept(obj);
214 		--this.depth;
215 	}
216 
217 	override void accept(const(Value) obj) {
218 		this.genIndent();
219 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
220 		++this.depth;
221 		super.accept(obj);
222 		--this.depth;
223 	}
224 
225 	override void accept(const(Type) obj) {
226 		this.genIndent();
227 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
228 		++this.depth;
229 		super.accept(obj);
230 		--this.depth;
231 	}
232 
233 	override void accept(const(ListType) obj) {
234 		this.genIndent();
235 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
236 		++this.depth;
237 		super.accept(obj);
238 		--this.depth;
239 	}
240 
241 	override void accept(const(Values) obj) {
242 		this.genIndent();
243 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
244 		++this.depth;
245 		super.accept(obj);
246 		--this.depth;
247 	}
248 
249 	override void accept(const(Array) obj) {
250 		this.genIndent();
251 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
252 		++this.depth;
253 		super.accept(obj);
254 		--this.depth;
255 	}
256 
257 	override void accept(const(ObjectValues) obj) {
258 		this.genIndent();
259 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
260 		++this.depth;
261 		super.accept(obj);
262 		--this.depth;
263 	}
264 
265 	override void accept(const(ObjectValue) obj) {
266 		this.genIndent();
267 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
268 		++this.depth;
269 		super.accept(obj);
270 		--this.depth;
271 	}
272 
273 	override void accept(const(ObjectType) obj) {
274 		this.genIndent();
275 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
276 		++this.depth;
277 		super.accept(obj);
278 		--this.depth;
279 	}
280 
281 	override void accept(const(TypeSystemDefinition) obj) {
282 		this.genIndent();
283 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
284 		++this.depth;
285 		super.accept(obj);
286 		--this.depth;
287 	}
288 
289 	override void accept(const(TypeDefinition) obj) {
290 		this.genIndent();
291 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
292 		++this.depth;
293 		super.accept(obj);
294 		--this.depth;
295 	}
296 
297 	override void accept(const(SchemaDefinition) obj) {
298 		this.genIndent();
299 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
300 		++this.depth;
301 		super.accept(obj);
302 		--this.depth;
303 	}
304 
305 	override void accept(const(OperationTypeDefinitions) obj) {
306 		this.genIndent();
307 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
308 		++this.depth;
309 		super.accept(obj);
310 		--this.depth;
311 	}
312 
313 	override void accept(const(OperationTypeDefinition) obj) {
314 		this.genIndent();
315 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
316 		++this.depth;
317 		super.accept(obj);
318 		--this.depth;
319 	}
320 
321 	override void accept(const(ScalarTypeDefinition) obj) {
322 		this.genIndent();
323 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
324 		++this.depth;
325 		super.accept(obj);
326 		--this.depth;
327 	}
328 
329 	override void accept(const(ObjectTypeDefinition) obj) {
330 		this.genIndent();
331 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
332 		++this.depth;
333 		super.accept(obj);
334 		--this.depth;
335 	}
336 
337 	override void accept(const(FieldDefinitions) obj) {
338 		this.genIndent();
339 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
340 		++this.depth;
341 		super.accept(obj);
342 		--this.depth;
343 	}
344 
345 	override void accept(const(FieldDefinition) obj) {
346 		this.genIndent();
347 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
348 		++this.depth;
349 		super.accept(obj);
350 		--this.depth;
351 	}
352 
353 	override void accept(const(ImplementsInterfaces) obj) {
354 		this.genIndent();
355 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
356 		++this.depth;
357 		super.accept(obj);
358 		--this.depth;
359 	}
360 
361 	override void accept(const(NamedTypes) obj) {
362 		this.genIndent();
363 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
364 		++this.depth;
365 		super.accept(obj);
366 		--this.depth;
367 	}
368 
369 	override void accept(const(ArgumentsDefinition) obj) {
370 		this.genIndent();
371 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
372 		++this.depth;
373 		super.accept(obj);
374 		--this.depth;
375 	}
376 
377 	override void accept(const(InputValueDefinitions) obj) {
378 		this.genIndent();
379 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
380 		++this.depth;
381 		super.accept(obj);
382 		--this.depth;
383 	}
384 
385 	override void accept(const(InputValueDefinition) obj) {
386 		this.genIndent();
387 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
388 		++this.depth;
389 		super.accept(obj);
390 		--this.depth;
391 	}
392 
393 	override void accept(const(InterfaceTypeDefinition) obj) {
394 		this.genIndent();
395 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
396 		++this.depth;
397 		super.accept(obj);
398 		--this.depth;
399 	}
400 
401 	override void accept(const(UnionTypeDefinition) obj) {
402 		this.genIndent();
403 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
404 		++this.depth;
405 		super.accept(obj);
406 		--this.depth;
407 	}
408 
409 	override void accept(const(UnionMembers) obj) {
410 		this.genIndent();
411 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
412 		++this.depth;
413 		super.accept(obj);
414 		--this.depth;
415 	}
416 
417 	override void accept(const(EnumTypeDefinition) obj) {
418 		this.genIndent();
419 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
420 		++this.depth;
421 		super.accept(obj);
422 		--this.depth;
423 	}
424 
425 	override void accept(const(EnumValueDefinitions) obj) {
426 		this.genIndent();
427 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
428 		++this.depth;
429 		super.accept(obj);
430 		--this.depth;
431 	}
432 
433 	override void accept(const(EnumValueDefinition) obj) {
434 		this.genIndent();
435 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
436 		++this.depth;
437 		super.accept(obj);
438 		--this.depth;
439 	}
440 
441 	override void accept(const(InputTypeDefinition) obj) {
442 		this.genIndent();
443 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
444 		++this.depth;
445 		super.accept(obj);
446 		--this.depth;
447 	}
448 
449 	override void accept(const(TypeExtensionDefinition) obj) {
450 		this.genIndent();
451 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
452 		++this.depth;
453 		super.accept(obj);
454 		--this.depth;
455 	}
456 
457 	override void accept(const(DirectiveDefinition) obj) {
458 		this.genIndent();
459 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
460 		++this.depth;
461 		super.accept(obj);
462 		--this.depth;
463 	}
464 
465 	override void accept(const(DirectiveLocations) obj) {
466 		this.genIndent();
467 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
468 		++this.depth;
469 		super.accept(obj);
470 		--this.depth;
471 	}
472 
473 	override void accept(const(InputObjectTypeDefinition) obj) {
474 		this.genIndent();
475 		writeln(Unqual!(typeof(obj)).stringof,":", obj.ruleSelection);
476 		++this.depth;
477 		super.accept(obj);
478 		--this.depth;
479 	}
480 }