Skip to content

Commit 4694ab4

Browse files
authored
QL: Support instanceof
Stills needs to be hooked up correctly to the AST.
1 parent ca21f58 commit 4694ab4

5 files changed

Lines changed: 32 additions & 5 deletions

File tree

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.

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 = "e08901378e2fd5c33f1e88bbb59716fd36f094f7" }
13+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "a9348d405de3b2dde0e6d7e59d476ae91516b7af" }
1414
clap = "2.33"
1515
tracing = "0.1"
1616
tracing-subscriber = { version = "0.2", features = ["env-filter"] }

generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ edition = "2018"
1010
node-types = { path = "../node-types" }
1111
tracing = "0.1"
1212
tracing-subscriber = { version = "0.2", features = ["env-filter"] }
13-
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "e08901378e2fd5c33f1e88bbb59716fd36f094f7" }
13+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "a9348d405de3b2dde0e6d7e59d476ae91516b7af" }

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ module Generated {
389389
/** Gets the location of this element. */
390390
override Location getLocation() { dataclass_def(this, _, result) }
391391

392+
/** Gets the node corresponding to the field `extends`. */
393+
AstNode getExtends(int i) { dataclass_extends(this, i, result) }
394+
395+
/** Gets the node corresponding to the field `instanceof`. */
396+
AstNode getInstanceof(int i) { dataclass_instanceof(this, i, result) }
397+
392398
/** Gets the node corresponding to the field `name`. */
393399
ClassName getName() { dataclass_def(this, result, _) }
394400

@@ -397,7 +403,10 @@ module Generated {
397403

398404
/** Gets a field or child node of this node. */
399405
override AstNode getAFieldOrChild() {
400-
dataclass_def(this, result, _) or dataclass_child(this, _, result)
406+
dataclass_extends(this, _, result) or
407+
dataclass_instanceof(this, _, result) or
408+
dataclass_def(this, result, _) or
409+
dataclass_child(this, _, result)
401410
}
402411
}
403412

ql/src/ql.dbscheme

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,25 @@ conjunction_def(
240240
int loc: @location ref
241241
);
242242

243-
@dataclass_child_type = @class_member | @type_alias_body | @type_expr | @type_union_body
243+
@dataclass_extends_type = @reserved_word | @type_expr
244+
245+
#keyset[dataclass, index]
246+
dataclass_extends(
247+
int dataclass: @dataclass ref,
248+
int index: int ref,
249+
unique int extends: @dataclass_extends_type ref
250+
);
251+
252+
@dataclass_instanceof_type = @reserved_word | @type_expr
253+
254+
#keyset[dataclass, index]
255+
dataclass_instanceof(
256+
int dataclass: @dataclass ref,
257+
int index: int ref,
258+
unique int instanceof: @dataclass_instanceof_type ref
259+
);
260+
261+
@dataclass_child_type = @class_member | @type_alias_body | @type_union_body
244262

245263
#keyset[dataclass, index]
246264
dataclass_child(

0 commit comments

Comments
 (0)