Skip to content

Commit 5d306c9

Browse files
authored
QL: Refactor SignatureExpr
1 parent ba6a4c6 commit 5d306c9

File tree

6 files changed

+31
-27
lines changed

6 files changed

+31
-27
lines changed

ql/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ql/extractor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
flate2 = "1.0"
1111
node-types = { path = "../node-types" }
1212
tree-sitter = "0.19"
13-
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "f073fca8875e9320142c171caa722544cd531b9d" }
13+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "99f3bc30fa772b07ad19a23799fe7433dc15f765" }
1414
clap = "2.33"
1515
tracing = "0.1"
1616
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }

ql/generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ clap = "2.33"
1111
node-types = { path = "../node-types" }
1212
tracing = "0.1"
1313
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
14-
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "f073fca8875e9320142c171caa722544cd531b9d" }
14+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "99f3bc30fa772b07ad19a23799fe7433dc15f765" }

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ class TypeExpr extends TType, AstNode {
673673
* Gets the module of the type, if it exists.
674674
* E.g. `DataFlow` in `DataFlow::Node`.
675675
*/
676-
ModuleExpr getModule() { toQL(result) = type.getChild() }
676+
ModuleExpr getModule() { toQL(result) = type.getQualifier() }
677677

678678
/**
679679
* Gets the type that this type reference refers to.

ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ module QL {
137137
/** Gets the node corresponding to the field `name`. */
138138
final LiteralId getName() { ql_arityless_predicate_expr_def(this, result) }
139139

140-
/** Gets the child of this node. */
141-
final ModuleExpr getChild() { ql_arityless_predicate_expr_child(this, result) }
140+
/** Gets the node corresponding to the field `qualifier`. */
141+
final ModuleExpr getQualifier() { ql_arityless_predicate_expr_qualifier(this, result) }
142142

143143
/** Gets a field or child node of this node. */
144144
final override AstNode getAFieldOrChild() {
145145
ql_arityless_predicate_expr_def(this, result) or
146-
ql_arityless_predicate_expr_child(this, result)
146+
ql_arityless_predicate_expr_qualifier(this, result)
147147
}
148148
}
149149

@@ -1320,20 +1320,15 @@ module QL {
13201320
/** Gets the name of the primary QL class for this element. */
13211321
final override string getAPrimaryQlClass() { result = "SignatureExpr" }
13221322

1323-
/** Gets the node corresponding to the field `arity`. */
1324-
final Integer getArity() { ql_signature_expr_arity(this, result) }
1323+
/** Gets the node corresponding to the field `predicate`. */
1324+
final PredicateExpr getPredicate() { ql_signature_expr_predicate(this, result) }
13251325

1326-
/** Gets the node corresponding to the field `name`. */
1327-
final SimpleId getName() { ql_signature_expr_def(this, result) }
1328-
1329-
/** Gets the node corresponding to the field `qualifier`. */
1330-
final ModuleExpr getQualifier() { ql_signature_expr_qualifier(this, result) }
1326+
/** Gets the node corresponding to the field `type_expr`. */
1327+
final TypeExpr getTypeExpr() { ql_signature_expr_type_expr(this, result) }
13311328

13321329
/** Gets a field or child node of this node. */
13331330
final override AstNode getAFieldOrChild() {
1334-
ql_signature_expr_arity(this, result) or
1335-
ql_signature_expr_def(this, result) or
1336-
ql_signature_expr_qualifier(this, result)
1331+
ql_signature_expr_predicate(this, result) or ql_signature_expr_type_expr(this, result)
13371332
}
13381333
}
13391334

@@ -1417,12 +1412,17 @@ module QL {
14171412
/** Gets the node corresponding to the field `name`. */
14181413
final ClassName getName() { ql_type_expr_name(this, result) }
14191414

1415+
/** Gets the node corresponding to the field `qualifier`. */
1416+
final ModuleExpr getQualifier() { ql_type_expr_qualifier(this, result) }
1417+
14201418
/** Gets the child of this node. */
14211419
final AstNode getChild() { ql_type_expr_child(this, result) }
14221420

14231421
/** Gets a field or child node of this node. */
14241422
final override AstNode getAFieldOrChild() {
1425-
ql_type_expr_name(this, result) or ql_type_expr_child(this, result)
1423+
ql_type_expr_name(this, result) or
1424+
ql_type_expr_qualifier(this, result) or
1425+
ql_type_expr_child(this, result)
14261426
}
14271427
}
14281428

ql/ql/src/ql.dbscheme

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ ql_annotation_def(
9595
int name: @ql_token_annot_name ref
9696
);
9797

98-
ql_arityless_predicate_expr_child(
98+
ql_arityless_predicate_expr_qualifier(
9999
unique int ql_arityless_predicate_expr: @ql_arityless_predicate_expr ref,
100-
unique int child: @ql_module_expr ref
100+
unique int qualifier: @ql_module_expr ref
101101
);
102102

103103
ql_arityless_predicate_expr_def(
@@ -886,19 +886,18 @@ ql_set_literal_def(
886886
unique int id: @ql_set_literal
887887
);
888888

889-
ql_signature_expr_arity(
889+
ql_signature_expr_predicate(
890890
unique int ql_signature_expr: @ql_signature_expr ref,
891-
unique int arity: @ql_token_integer ref
891+
unique int predicate: @ql_predicate_expr ref
892892
);
893893

894-
ql_signature_expr_qualifier(
894+
ql_signature_expr_type_expr(
895895
unique int ql_signature_expr: @ql_signature_expr ref,
896-
unique int qualifier: @ql_module_expr ref
896+
unique int type_expr: @ql_type_expr ref
897897
);
898898

899899
ql_signature_expr_def(
900-
unique int id: @ql_signature_expr,
901-
int name: @ql_token_simple_id ref
900+
unique int id: @ql_signature_expr
902901
);
903902

904903
ql_special_call_def(
@@ -929,7 +928,12 @@ ql_type_expr_name(
929928
unique int name: @ql_token_class_name ref
930929
);
931930

932-
@ql_typeExpr_child_type = @ql_module_expr | @ql_token_dbtype | @ql_token_primitive_type
931+
ql_type_expr_qualifier(
932+
unique int ql_type_expr: @ql_type_expr ref,
933+
unique int qualifier: @ql_module_expr ref
934+
);
935+
936+
@ql_typeExpr_child_type = @ql_token_dbtype | @ql_token_primitive_type
933937

934938
ql_type_expr_child(
935939
unique int ql_type_expr: @ql_type_expr ref,

0 commit comments

Comments
 (0)