@@ -26,12 +26,22 @@ class PrintAstConfiguration extends TPrintAstConfiguration {
26
26
* By default it checks whether the `AstNode` `e` belongs to `Location` `l`.
27
27
*/
28
28
predicate shouldPrint ( AstNode e , Location l ) { l = e .getLocation ( ) }
29
+
30
+ /**
31
+ * Controls whether the `YamlNode` should be considered for AST printing.
32
+ * By default it checks whether the `YamlNode` `y` belongs to `Location` `l`.
33
+ */
34
+ predicate shouldPrintYaml ( YamlNode y , Location l ) { l = y .getLocation ( ) }
29
35
}
30
36
31
37
private predicate shouldPrint ( AstNode e , Location l ) {
32
38
exists ( PrintAstConfiguration config | config .shouldPrint ( e , l ) )
33
39
}
34
40
41
+ private predicate shouldPrintYaml ( YamlNode y , Location l ) {
42
+ exists ( PrintAstConfiguration config | config .shouldPrintYaml ( y , l ) )
43
+ }
44
+
35
45
/** Holds if the given element does not need to be rendered in the AST. */
36
46
private predicate isNotNeeded ( AstNode el ) {
37
47
el .isArtificial ( )
@@ -55,8 +65,11 @@ private newtype TPrintAstNode =
55
65
not list = any ( Module mod ) .getBody ( ) and
56
66
not forall ( AstNode child | child = list .getAnItem ( ) | isNotNeeded ( child ) )
57
67
} or
58
- TYamlNode ( YamlNode node ) or
59
- TYamlMappingNode ( YamlMapping mapping , int i ) { exists ( mapping .getKeyNode ( i ) ) }
68
+ TYamlNode ( YamlNode node ) { shouldPrintYaml ( node , _) } or
69
+ TYamlMappingNode ( YamlMapping mapping , int i ) {
70
+ shouldPrintYaml ( mapping , _) and
71
+ exists ( mapping .getKeyNode ( i ) )
72
+ }
60
73
61
74
/**
62
75
* A node in the output tree.
0 commit comments