File tree Expand file tree Collapse file tree
test/library-tests/controlflow/graph Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ private import ast.internal.TreeSitter
1212 * A node in the abstract syntax tree. This class is the base class for all Ruby
1313 * program elements.
1414 */
15+ // TODO: Replace base class with an abstract range class once we have full coverage
1516class AstNode extends @ast_node {
1617 Generated:: AstNode generated ;
1718
Original file line number Diff line number Diff line change 11/** Provides classes representing the control flow graph. */
22
33private import codeql.Locations
4+ private import codeql_ruby.AST as AST
45private import codeql_ruby.ast.internal.TreeSitter:: Generated
56private import codeql_ruby.controlflow.BasicBlocks
67private import SuccessorTypes
@@ -133,9 +134,18 @@ module CfgNodes {
133134 final override AstNode getNode ( ) { result = n }
134135
135136 final override string toString ( ) {
136- result = "[" + this .getSplitsString ( ) + "] " + n .toString ( )
137- or
138- not exists ( this .getSplitsString ( ) ) and result = n .toString ( )
137+ exists ( string s |
138+ // TODO: Remove once the SSA implementation is based on the AST layer
139+ s = n .( AST:: AstNode ) .toString ( ) and
140+ s != "AstNode"
141+ or
142+ n .( AST:: AstNode ) .toString ( ) = "AstNode" and
143+ s = n .toString ( )
144+ |
145+ result = "[" + this .getSplitsString ( ) + "] " + s
146+ or
147+ not exists ( this .getSplitsString ( ) ) and result = s
148+ )
139149 }
140150
141151 /** Gets a comma-separated list of strings for each split in this node, if any. */
You can’t perform that action at this time.
0 commit comments