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