diff --git a/Cargo.lock b/Cargo.lock index 62f1da345fe..d70d80f9439 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -589,7 +589,7 @@ dependencies = [ [[package]] name = "tree-sitter-ql" version = "0.19.0" -source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=dee83b7a1c159f2c71d8d3d3bce3ee1203ed653a#dee83b7a1c159f2c71d8d3d3bce3ee1203ed653a" +source = "git+https://github.com/tausbn/tree-sitter-ql.git?rev=4125f8b919f80889dec4b74842419d287ccf1782#4125f8b919f80889dec4b74842419d287ccf1782" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index 723b5b95ce1..44fb96c3cbb 100644 --- a/extractor/Cargo.toml +++ b/extractor/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" flate2 = "1.0" node-types = { path = "../node-types" } tree-sitter = "0.19" -tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "dee83b7a1c159f2c71d8d3d3bce3ee1203ed653a" } +tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "4125f8b919f80889dec4b74842419d287ccf1782" } clap = "2.33" tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 3eab976ab87..755353b7011 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -10,4 +10,4 @@ edition = "2018" node-types = { path = "../node-types" } tracing = "0.1" tracing-subscriber = { version = "0.2", features = ["env-filter"] } -tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "dee83b7a1c159f2c71d8d3d3bce3ee1203ed653a" } +tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "4125f8b919f80889dec4b74842419d287ccf1782" } diff --git a/ql/src/codeql_ql/ast/internal/TreeSitter.qll b/ql/src/codeql_ql/ast/internal/TreeSitter.qll index 768fe85f81e..a585096e7ea 100644 --- a/ql/src/codeql_ql/ast/internal/TreeSitter.qll +++ b/ql/src/codeql_ql/ast/internal/TreeSitter.qll @@ -180,11 +180,15 @@ module Generated { class Charpred extends @charpred, AstNode { override string getAPrimaryQlClass() { result = "Charpred" } - override Location getLocation() { charpred_def(this, result) } + override Location getLocation() { charpred_def(this, _, _, result) } - AstNode getChild(int i) { charpred_child(this, i, result) } + AstNode getBody() { charpred_def(this, result, _, _) } - override AstNode getAFieldOrChild() { charpred_child(this, _, result) } + ClassName getChild() { charpred_def(this, _, result, _) } + + override AstNode getAFieldOrChild() { + charpred_def(this, result, _, _) or charpred_def(this, _, result, _) + } } class ClassMember extends @class_member, AstNode { diff --git a/ql/src/ql.dbscheme b/ql/src/ql.dbscheme index e334a7a2fc4..9041b7801fc 100644 --- a/ql/src/ql.dbscheme +++ b/ql/src/ql.dbscheme @@ -176,17 +176,12 @@ call_or_unqual_agg_expr_def( int loc: @location ref ); -@charpred_child_type = @add_expr | @aggregate | @call_or_unqual_agg_expr | @comp_term | @conjunction | @disjunction | @expr_annotation | @if_term | @implication | @in_expr | @instance_of | @literal | @mul_expr | @negation | @par_expr | @prefix_cast | @qualified_expr | @quantified | @range | @set_literal | @special_call | @super_ref | @token_class_name | @unary_expr | @variable - -#keyset[charpred, index] -charpred_child( - int charpred: @charpred ref, - int index: int ref, - unique int child: @charpred_child_type ref -); +@charpred_body_type = @add_expr | @aggregate | @call_or_unqual_agg_expr | @comp_term | @conjunction | @disjunction | @expr_annotation | @if_term | @implication | @in_expr | @instance_of | @literal | @mul_expr | @negation | @par_expr | @prefix_cast | @qualified_expr | @quantified | @range | @set_literal | @special_call | @super_ref | @unary_expr | @variable charpred_def( unique int id: @charpred, + int body: @charpred_body_type ref, + int child: @token_class_name ref, int loc: @location ref );