@@ -28,7 +28,6 @@ class PrintAstConfiguration extends string {
2828 * The ordering is location based and pretty arbitary.
2929 */
3030AstNode getAstChild ( PrintAstNode parent , int i ) {
31- parent .shouldPrint ( ) and
3231 result =
3332 rank [ i ] ( AstNode child , Location l |
3433 child .getParent ( ) = parent and
@@ -44,33 +43,25 @@ AstNode getAstChild(PrintAstNode parent, int i) {
4443 * A node in the output tree.
4544 */
4645class PrintAstNode extends AstNode {
46+ PrintAstNode ( ) { shouldPrintNode ( this ) }
47+
4748 string getProperty ( string key ) {
48- this .shouldPrint ( ) and
49- (
50- key = "semmle.label" and
51- result = "[" + concat ( this .getAPrimaryQlClass ( ) , ", " ) + "] " + this .toString ( )
52- or
53- key = "semmle.order" and
54- result =
55- any ( int i |
56- this =
57- rank [ i ] ( AstNode p , Location l , File f |
58- l = p .getLocation ( ) and
59- f = l .getFile ( )
60- |
61- p order by f .getBaseName ( ) , f .getAbsolutePath ( ) , l .getStartLine ( ) , l .getStartColumn ( )
62- )
63- ) .toString ( )
64- )
49+ key = "semmle.label" and
50+ result = "[" + concat ( this .getAPrimaryQlClass ( ) , ", " ) + "] " + this .toString ( )
51+ or
52+ key = "semmle.order" and
53+ result =
54+ any ( int i |
55+ this =
56+ rank [ i ] ( AstNode p , Location l , File f |
57+ l = p .getLocation ( ) and
58+ f = l .getFile ( )
59+ |
60+ p order by f .getBaseName ( ) , f .getAbsolutePath ( ) , l .getStartLine ( ) , l .getStartColumn ( )
61+ )
62+ ) .toString ( )
6563 }
6664
67- /**
68- * Holds if this node should be printed in the output. By default, all nodes
69- * are printed, but the query can override
70- * `PrintAstConfiguration.shouldPrintNode` to filter the output.
71- */
72- predicate shouldPrint ( ) { shouldPrintNode ( this ) }
73-
7465 /**
7566 * Gets the child node that is accessed using the predicate `edgeName`.
7667 */
@@ -85,18 +76,13 @@ private predicate shouldPrintNode(AstNode n) {
8576 * Holds if `node` belongs to the output tree, and its property `key` has the
8677 * given `value`.
8778 */
88- query predicate nodes ( PrintAstNode node , string key , string value ) {
89- node .shouldPrint ( ) and
90- value = node .getProperty ( key )
91- }
79+ query predicate nodes ( PrintAstNode node , string key , string value ) { value = node .getProperty ( key ) }
9280
9381/**
9482 * Holds if `target` is a child of `source` in the AST, and property `key` of
9583 * the edge has the given `value`.
9684 */
9785query predicate edges ( PrintAstNode source , PrintAstNode target , string key , string value ) {
98- source .shouldPrint ( ) and
99- target .shouldPrint ( ) and
10086 target = source .getChild ( _) and
10187 (
10288 key = "semmle.label" and
0 commit comments