Skip to content

Commit bf2ae98

Browse files
committed
Tree-sitter: Bump to 0.22.6
1 parent 9d21e2c commit bf2ae98

File tree

17 files changed

+231
-208
lines changed

17 files changed

+231
-208
lines changed

ql/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ql/buramu/tree-sitter-blame/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ include = [
2020
path = "bindings/rust/lib.rs"
2121

2222
[dependencies]
23-
tree-sitter = "~0.20.3"
23+
tree-sitter = ">= 0.22.6"
2424

2525
[build-dependencies]
2626
cc = "1.0"
27+
28+
[patch.crates-io]
29+
tree-sitter = {git = "https://github.com/redsun82/tree-sitter.git", rev = "1f5c1112ceaa8fc6aff61d1852690407670d2a96"}

ql/extractor/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
name = "codeql-extractor-ql"
33
version = "0.1.0"
44
authors = ["GitHub"]
5-
edition = "2018"
5+
edition = "2021"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
tree-sitter = ">= 0.20, < 0.21"
11-
tree-sitter-ql = { git = "https://github.com/tree-sitter/tree-sitter-ql.git", rev = "d08db734f8dc52f6bc04db53a966603122bc6985"}
12-
tree-sitter-ql-dbscheme = { git = "https://github.com/erik-krogh/tree-sitter-ql-dbscheme.git", rev = "63e1344353f63931e88bfbc2faa2e78e1421b213"}
10+
tree-sitter = ">= 0.22.6"
11+
tree-sitter-ql = { git = "https://github.com/tree-sitter/tree-sitter-ql.git", rev = "fa5c3821dd2161f5c8528a8cbdb258daa6dc4de6"}
12+
tree-sitter-ql-dbscheme = { git = "https://github.com/tree-sitter/tree-sitter-ql-dbscheme.git", rev = "5f770f57fa415607ff50e3d237d47c8f11440eb3"}
1313
tree-sitter-blame = {path = "../buramu/tree-sitter-blame"}
14-
tree-sitter-json = {git = "https://github.com/tausbn/tree-sitter-json.git", rev = "745663ee997f1576fe1e7187e6347e0db36ec7a9"}
14+
tree-sitter-json = {git = "https://github.com/tree-sitter/tree-sitter-json.git", rev = "94f5c527b2965465956c2000ed6134dd24daf2a7"}
1515
clap = { version = "4.2", features = ["derive"] }
1616
tracing = "0.1"
1717
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
1818
rayon = "1.9.0"
1919
regex = "1.10.4"
2020
codeql-extractor = { path = "../../shared/tree-sitter-extractor" }
21+
22+
[patch.crates-io]
23+
tree-sitter = {git = "https://github.com/redsun82/tree-sitter.git", rev = "1f5c1112ceaa8fc6aff61d1852690407670d2a96"}

ql/ql/src/codeql_ql/StructuredLogs.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,25 @@ private Predicate getPredicateFromPosition(string s) {
3131
)
3232
}
3333

34+
pragma[nomagic]
35+
private string getJsonStringComponent(JSON::String s, int i) {
36+
result = s.getChild(i).(JSON::Token).getValue()
37+
}
38+
39+
pragma[nomagic]
40+
private string getJsonString(JSON::String s) {
41+
result = concat(string c, int i | c = getJsonStringComponent(s, i) | c order by i)
42+
}
43+
3444
class Object extends JSON::Object {
35-
JSON::Value getValue(string key) {
45+
JSON::UnderscoreValue getValue(string key) {
3646
exists(JSON::Pair p | p = this.getChild(_) |
37-
key = p.getKey().(JSON::String).getChild().getValue() and
47+
key = getJsonString(p.getKey()) and
3848
result = p.getValue()
3949
)
4050
}
4151

42-
string getString(string key) { result = this.getValue(key).(JSON::String).getChild().getValue() }
52+
string getString(string key) { result = getJsonString(this.getValue(key)) }
4353

4454
int getNumber(string key) { result = this.getValue(key).(JSON::Number).getValue().toInt() }
4555

@@ -61,7 +71,7 @@ class Object extends JSON::Object {
6171
class Array extends JSON::Array {
6272
Object getObject(int i) { result = this.getChild(i) }
6373

64-
string getString(int i) { result = this.getChild(i).(JSON::String).getChild().getValue() }
74+
string getString(int i) { result = getJsonString(this.getChild(i)) }
6575

6676
int getNumber(int i) { result = this.getChild(i).(JSON::Number).getValue().toInt() }
6777

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,13 +1767,15 @@ module JSON {
17671767
final override string getAPrimaryQlClass() { result = "ReservedWord" }
17681768
}
17691769

1770+
class UnderscoreValue extends @json_underscore_value, AstNode { }
1771+
17701772
/** A class representing `array` nodes. */
17711773
class Array extends @json_array, AstNode {
17721774
/** Gets the name of the primary QL class for this element. */
17731775
final override string getAPrimaryQlClass() { result = "Array" }
17741776

17751777
/** Gets the `i`th child of this node. */
1776-
final Value getChild(int i) { json_array_child(this, i, result) }
1778+
final UnderscoreValue getChild(int i) { json_array_child(this, i, result) }
17771779

17781780
/** Gets a field or child node of this node. */
17791781
final override AstNode getAFieldOrChild() { json_array_child(this, _, result) }
@@ -1791,12 +1793,18 @@ module JSON {
17911793
final override string getAPrimaryQlClass() { result = "Document" }
17921794

17931795
/** Gets the `i`th child of this node. */
1794-
final Value getChild(int i) { json_document_child(this, i, result) }
1796+
final UnderscoreValue getChild(int i) { json_document_child(this, i, result) }
17951797

17961798
/** Gets a field or child node of this node. */
17971799
final override AstNode getAFieldOrChild() { json_document_child(this, _, result) }
17981800
}
17991801

1802+
/** A class representing `escape_sequence` tokens. */
1803+
class EscapeSequence extends @json_token_escape_sequence, Token {
1804+
/** Gets the name of the primary QL class for this element. */
1805+
final override string getAPrimaryQlClass() { result = "EscapeSequence" }
1806+
}
1807+
18001808
/** A class representing `false` tokens. */
18011809
class False extends @json_token_false, Token {
18021810
/** Gets the name of the primary QL class for this element. */
@@ -1833,10 +1841,10 @@ module JSON {
18331841
final override string getAPrimaryQlClass() { result = "Pair" }
18341842

18351843
/** Gets the node corresponding to the field `key`. */
1836-
final AstNode getKey() { json_pair_def(this, result, _) }
1844+
final String getKey() { json_pair_def(this, result, _) }
18371845

18381846
/** Gets the node corresponding to the field `value`. */
1839-
final Value getValue() { json_pair_def(this, _, result) }
1847+
final UnderscoreValue getValue() { json_pair_def(this, _, result) }
18401848

18411849
/** Gets a field or child node of this node. */
18421850
final override AstNode getAFieldOrChild() {
@@ -1849,11 +1857,11 @@ module JSON {
18491857
/** Gets the name of the primary QL class for this element. */
18501858
final override string getAPrimaryQlClass() { result = "String" }
18511859

1852-
/** Gets the child of this node. */
1853-
final StringContent getChild() { json_string_child(this, result) }
1860+
/** Gets the `i`th child of this node. */
1861+
final AstNode getChild(int i) { json_string_child(this, i, result) }
18541862

18551863
/** Gets a field or child node of this node. */
1856-
final override AstNode getAFieldOrChild() { json_string_child(this, result) }
1864+
final override AstNode getAFieldOrChild() { json_string_child(this, _, result) }
18571865
}
18581866

18591867
/** A class representing `string_content` tokens. */
@@ -1867,6 +1875,4 @@ module JSON {
18671875
/** Gets the name of the primary QL class for this element. */
18681876
final override string getAPrimaryQlClass() { result = "True" }
18691877
}
1870-
1871-
class Value extends @json_value, AstNode { }
18721878
}

ql/ql/src/ql.dbscheme

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,11 +1239,13 @@ blame_ast_node_parent(
12391239
);
12401240

12411241
/*- JSON dbscheme -*/
1242+
@json_underscore_value = @json_array | @json_object | @json_string__ | @json_token_false | @json_token_null | @json_token_number | @json_token_true
1243+
12421244
#keyset[json_array, index]
12431245
json_array_child(
12441246
int json_array: @json_array ref,
12451247
int index: int ref,
1246-
unique int child: @json_value ref
1248+
unique int child: @json_underscore_value ref
12471249
);
12481250

12491251
json_array_def(
@@ -1254,7 +1256,7 @@ json_array_def(
12541256
json_document_child(
12551257
int json_document: @json_document ref,
12561258
int index: int ref,
1257-
unique int child: @json_value ref
1259+
unique int child: @json_underscore_value ref
12581260
);
12591261

12601262
json_document_def(
@@ -1272,25 +1274,25 @@ json_object_def(
12721274
unique int id: @json_object
12731275
);
12741276

1275-
@json_pair_key_type = @json_string__ | @json_token_number
1276-
12771277
json_pair_def(
12781278
unique int id: @json_pair,
1279-
int key__: @json_pair_key_type ref,
1280-
int value: @json_value ref
1279+
int key__: @json_string__ ref,
1280+
int value: @json_underscore_value ref
12811281
);
12821282

1283+
@json_string_child_type = @json_token_escape_sequence | @json_token_string_content
1284+
1285+
#keyset[json_string__, index]
12831286
json_string_child(
1284-
unique int json_string__: @json_string__ ref,
1285-
unique int child: @json_token_string_content ref
1287+
int json_string__: @json_string__ ref,
1288+
int index: int ref,
1289+
unique int child: @json_string_child_type ref
12861290
);
12871291

12881292
json_string_def(
12891293
unique int id: @json_string__
12901294
);
12911295

1292-
@json_value = @json_array | @json_object | @json_string__ | @json_token_false | @json_token_null | @json_token_number | @json_token_true
1293-
12941296
json_tokeninfo(
12951297
unique int id: @json_token,
12961298
int kind: int ref,
@@ -1300,11 +1302,12 @@ json_tokeninfo(
13001302
case @json_token.kind of
13011303
0 = @json_reserved_word
13021304
| 1 = @json_token_comment
1303-
| 2 = @json_token_false
1304-
| 3 = @json_token_null
1305-
| 4 = @json_token_number
1306-
| 5 = @json_token_string_content
1307-
| 6 = @json_token_true
1305+
| 2 = @json_token_escape_sequence
1306+
| 3 = @json_token_false
1307+
| 4 = @json_token_null
1308+
| 5 = @json_token_number
1309+
| 6 = @json_token_string_content
1310+
| 7 = @json_token_true
13081311
;
13091312

13101313

ql/rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# extractor. It is set to the lowest version of Rust we want to support.
33

44
[toolchain]
5-
channel = "1.68"
5+
channel = "1.70"
66
profile = "minimal"
7-
components = [ "rustfmt" ]
7+
components = [ "rustfmt" ]

0 commit comments

Comments
 (0)