Add getParent(Index) to user-facing AstNode

This commit is contained in:
Nick Rolfe
2020-11-26 15:33:50 +00:00
parent c598dc6b5c
commit 399170fd58

View File

@@ -1,14 +1,17 @@
import codeql.Locations
import codeql_ruby.Method
import codeql_ruby.Parameter
private import codeql_ruby.Generated
class Location = Generated::Location;
/**
* A node in the abstract syntax tree. This class is the base class for all Ruby
* program elements.
*/
class AstNode extends @ast_node {
Generated::AstNode generated;
AstNode() { generated = this }
/**
* Gets the name of a primary CodeQL class to which this node belongs.
*
@@ -22,7 +25,18 @@ class AstNode extends @ast_node {
string toString() { result = "AstNode" }
/** Gets the location if this node. */
Location getLocation() { result = this.(Generated::AstNode).getLocation() }
Location getLocation() { result = generated.getLocation() }
/**
* Gets the parent of this node in the abstract syntax tree, if it has one.
*/
AstNode getParent() { result = generated.getParent() }
/**
* Gets the index (position) of this node in the parent node's list of
* children.
*/
int getParentIndex() { result = generated.getParentIndex() }
}
/**