@@ -26,12 +26,22 @@ class PrintAstConfiguration extends TPrintAstConfiguration {
2626 * By default it checks whether the `AstNode` `e` belongs to `Location` `l`.
2727 */
2828 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 ( ) }
2935}
3036
3137private predicate shouldPrint ( AstNode e , Location l ) {
3238 exists ( PrintAstConfiguration config | config .shouldPrint ( e , l ) )
3339}
3440
41+ private predicate shouldPrintYaml ( YamlNode y , Location l ) {
42+ exists ( PrintAstConfiguration config | config .shouldPrintYaml ( y , l ) )
43+ }
44+
3545/** Holds if the given element does not need to be rendered in the AST. */
3646private predicate isNotNeeded ( AstNode el ) {
3747 el .isArtificial ( )
@@ -55,8 +65,11 @@ private newtype TPrintAstNode =
5565 not list = any ( Module mod ) .getBody ( ) and
5666 not forall ( AstNode child | child = list .getAnItem ( ) | isNotNeeded ( child ) )
5767 } 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+ }
6073
6174/**
6275 * A node in the output tree.
0 commit comments