+4
CHANGELOG.md
+4
CHANGELOG.md
···
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## v0.12.0 -- 2024-12-12
9
+
10
+
Upgraded the `tree-sitter` dependency to version 0.24.
11
+
8
12
## v0.11.3 -- 2024-05-29
9
13
10
14
### Library
+6
-6
Cargo.toml
+6
-6
Cargo.toml
···
1
1
[package]
2
2
name = "tree-sitter-graph"
3
-
version = "0.11.3"
3
+
version = "0.12.0"
4
4
description = "Construct graphs from parsed source code"
5
5
homepage = "https://github.com/tree-sitter/tree-sitter-graph/"
6
6
repository = "https://github.com/tree-sitter/tree-sitter-graph/"
···
33
33
serde = "1.0"
34
34
serde_json = "1.0"
35
35
smallvec = { version="1.6", features=["union"] }
36
-
string-interner = { version = "0.12", default-features = false, features = ["std", "inline-more", "backends"] }
36
+
streaming-iterator = "0.1.9"
37
37
thiserror = "1.0.7"
38
-
tree-sitter = "0.20.3"
39
-
tree-sitter-config = { version = "0.19", optional = true }
40
-
tree-sitter-loader = { version = "0.20", optional = true }
38
+
tree-sitter = "0.24"
39
+
tree-sitter-config = { version = "0.24", optional = true }
40
+
tree-sitter-loader = { version = "0.24", optional = true }
41
41
42
42
[dev-dependencies]
43
43
env_logger = "0.9"
44
44
indoc = "1.0"
45
-
tree-sitter-python = "0.20"
45
+
tree-sitter-python = "=0.23.5"
+1
-1
README.md
+1
-1
README.md
+3
-3
src/bin/tree-sitter-graph/main.rs
+3
-3
src/bin/tree-sitter-graph/main.rs
···
89
89
)?;
90
90
}
91
91
92
-
let config = Config::load()?;
92
+
let config = Config::load(None)?;
93
93
let mut loader = Loader::new()?;
94
94
let loader_config = config.get()?;
95
95
loader.find_all_languages(&loader_config)?;
···
98
98
let tsg = std::fs::read(tsg_path)
99
99
.with_context(|| format!("Cannot read TSG file {}", tsg_path.display()))?;
100
100
let tsg = String::from_utf8(tsg)?;
101
-
let file = match File::from_str(language, &tsg) {
101
+
let file = match File::from_str(language.clone(), &tsg) {
102
102
Ok(file) => file,
103
103
Err(err) => {
104
104
eprintln!("{}", err.display_pretty(tsg_path, &tsg));
···
110
110
.with_context(|| format!("Cannot read source file {}", source_path.display()))?;
111
111
let source = String::from_utf8(source)?;
112
112
let mut parser = Parser::new();
113
-
parser.set_language(language)?;
113
+
parser.set_language(&language)?;
114
114
let tree = parser
115
115
.parse(&source, None)
116
116
.ok_or_else(|| anyhow!("Cannot parse {}", source_path.display()))?;
+1
-1
src/checker.rs
+1
-1
src/checker.rs
···
188
188
.expect("capture should have index")
189
189
!= self.full_match_stanza_capture_index as u32
190
190
})
191
-
.map(|cn| Identifier::from(cn.as_str()))
191
+
.map(|cn| Identifier::from(*cn))
192
192
.collect::<HashSet<_>>();
193
193
let unused_captures = all_captures
194
194
.difference(&used_captures)
+10
-10
src/execution.rs
+10
-10
src/execution.rs
···
119
119
.iter()
120
120
.map(|name| {
121
121
let index = file_query
122
-
.capture_index_for_name(name)
122
+
.capture_index_for_name(*name)
123
123
.expect("missing index for capture");
124
124
let quantifier =
125
125
file_query.capture_quantifiers(mat.pattern_index)[index as usize];
126
-
(name, quantifier, index)
126
+
(*name, quantifier, index)
127
127
})
128
128
.filter(|c| c.2 != stanza.full_match_file_capture_index as u32)
129
129
.collect();
···
143
143
.map(|name| {
144
144
let index = stanza
145
145
.query
146
-
.capture_index_for_name(name)
146
+
.capture_index_for_name(*name)
147
147
.expect("missing index for capture");
148
148
let quantifier = stanza.query.capture_quantifiers(0)[index as usize];
149
-
(name, quantifier, index)
149
+
(*name, quantifier, index)
150
150
})
151
151
.filter(|c| c.2 != stanza.full_match_stanza_capture_index as u32)
152
152
.collect();
···
179
179
.map(|name| {
180
180
let index = self
181
181
.query
182
-
.capture_index_for_name(name)
182
+
.capture_index_for_name(*name)
183
183
.expect("missing index for capture");
184
184
let quantifier = self.query.capture_quantifiers(0)[index as usize];
185
-
(name, quantifier, index)
185
+
(*name, quantifier, index)
186
186
})
187
187
.filter(|c| c.2 != self.full_match_stanza_capture_index as u32)
188
188
.collect();
···
197
197
}
198
198
199
199
pub struct Match<'a, 'tree> {
200
-
mat: QueryMatch<'a, 'tree>,
200
+
mat: &'a QueryMatch<'a, 'tree>,
201
201
full_capture_index: u32,
202
-
named_captures: Vec<(&'a String, CaptureQuantifier, u32)>,
202
+
named_captures: Vec<(&'a str, CaptureQuantifier, u32)>,
203
203
query_location: Location,
204
204
}
205
205
···
217
217
&'s self,
218
218
) -> impl Iterator<
219
219
Item = (
220
-
&String,
220
+
&'a str,
221
221
CaptureQuantifier,
222
222
impl Iterator<Item = Node<'tree>> + 's,
223
223
),
···
239
239
}
240
240
241
241
/// Return an iterator over all capture names.
242
-
pub fn capture_names(&self) -> impl Iterator<Item = &String> {
242
+
pub fn capture_names(&self) -> impl Iterator<Item = &str> {
243
243
self.named_captures.iter().map(|c| c.0)
244
244
}
245
245
+5
-3
src/execution/lazy.rs
+5
-3
src/execution/lazy.rs
···
18
18
use tree_sitter::QueryMatch;
19
19
use tree_sitter::Tree;
20
20
21
+
use streaming_iterator::StreamingIterator;
22
+
21
23
use crate::ast;
22
24
use crate::execution::error::ExecutionError;
23
25
use crate::execution::error::ResultWithExecutionError;
···
116
118
mut visit: F,
117
119
) -> Result<(), E>
118
120
where
119
-
F: FnMut(&ast::Stanza, QueryMatch<'_, 'tree>) -> Result<(), E>,
121
+
F: FnMut(&ast::Stanza, &QueryMatch<'_, 'tree>) -> Result<(), E>,
120
122
{
121
123
let mut cursor = QueryCursor::new();
122
124
let query = self.query.as_ref().unwrap();
123
-
let matches = cursor.matches(query, tree.root_node(), source.as_bytes());
124
-
for mat in matches {
125
+
let mut matches = cursor.matches(query, tree.root_node(), source.as_bytes());
126
+
while let Some(mat) = matches.next() {
125
127
let stanza = &self.stanzas[mat.pattern_index];
126
128
visit(stanza, mat)?;
127
129
}
+5
-4
src/execution/strict.rs
+5
-4
src/execution/strict.rs
···
8
8
use std::collections::BTreeSet;
9
9
use std::collections::HashMap;
10
10
use std::collections::HashSet;
11
+
use streaming_iterator::StreamingIterator;
11
12
use tree_sitter::QueryCursor;
12
13
use tree_sitter::QueryMatch;
13
14
use tree_sitter::Tree;
···
115
116
mut visit: F,
116
117
) -> Result<(), E>
117
118
where
118
-
F: FnMut(&Stanza, QueryMatch<'_, 'tree>) -> Result<(), E>,
119
+
F: FnMut(&Stanza, &QueryMatch<'_, 'tree>) -> Result<(), E>,
119
120
{
120
121
for stanza in &self.stanzas {
121
122
stanza.try_visit_matches_strict(tree, source, |mat| visit(stanza, mat))?;
···
214
215
mut visit: F,
215
216
) -> Result<(), E>
216
217
where
217
-
F: FnMut(QueryMatch<'_, 'tree>) -> Result<(), E>,
218
+
F: FnMut(&QueryMatch<'_, 'tree>) -> Result<(), E>,
218
219
{
219
220
let mut cursor = QueryCursor::new();
220
-
let matches = cursor.matches(&self.query, tree.root_node(), source.as_bytes());
221
-
for mat in matches {
221
+
let mut matches = cursor.matches(&self.query, tree.root_node(), source.as_bytes());
222
+
while let Some(mat) = matches.next() {
222
223
visit(mat)?;
223
224
}
224
225
Ok(())
+1
-1
src/parse_error.rs
+1
-1
src/parse_error.rs
+4
-4
src/parser.rs
+4
-4
src/parser.rs
···
305
305
let name = self.parse_identifier("inherit")?;
306
306
file.inherited_variables.insert(name);
307
307
} else {
308
-
let stanza = self.parse_stanza(file.language)?;
308
+
let stanza = self.parse_stanza(&file.language)?;
309
309
file.stanzas.push(stanza);
310
310
}
311
311
self.consume_whitespace();
312
312
}
313
313
// we can unwrap here because all queries have already been parsed before
314
-
file.query = Some(Query::new(file.language, &self.query_source).unwrap());
314
+
file.query = Some(Query::new(&file.language, &self.query_source).unwrap());
315
315
Ok(())
316
316
}
317
317
···
369
369
Ok(quantifier)
370
370
}
371
371
372
-
fn parse_stanza(&mut self, language: Language) -> Result<ast::Stanza, ParseError> {
372
+
fn parse_stanza(&mut self, language: &Language) -> Result<ast::Stanza, ParseError> {
373
373
let start = self.location;
374
374
let (query, full_match_stanza_capture_index) = self.parse_query(language)?;
375
375
self.consume_whitespace();
···
385
385
})
386
386
}
387
387
388
-
fn parse_query(&mut self, language: Language) -> Result<(Query, usize), ParseError> {
388
+
fn parse_query(&mut self, language: &Language) -> Result<(Query, usize), ParseError> {
389
389
let location = self.location;
390
390
let query_start = self.offset;
391
391
self.skip_query()?;
+4
-2
tests/it/execution.rs
+4
-2
tests/it/execution.rs
···
27
27
fn execute(python_source: &str, dsl_source: &str) -> Result<String, ExecutionError> {
28
28
init_log();
29
29
let mut parser = Parser::new();
30
-
parser.set_language(tree_sitter_python::language()).unwrap();
30
+
parser
31
+
.set_language(&tree_sitter_python::LANGUAGE.into())
32
+
.unwrap();
31
33
let tree = parser.parse(python_source, None).unwrap();
32
34
let file =
33
-
File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file");
35
+
File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file");
34
36
let functions = Functions::stdlib();
35
37
let mut globals = Variables::new();
36
38
globals
+4
-2
tests/it/functions.rs
+4
-2
tests/it/functions.rs
···
27
27
fn execute(python_source: &str, dsl_source: &str) -> Result<String, ExecutionError> {
28
28
init_log();
29
29
let mut parser = Parser::new();
30
-
parser.set_language(tree_sitter_python::language()).unwrap();
30
+
parser
31
+
.set_language(&tree_sitter_python::LANGUAGE.into())
32
+
.unwrap();
31
33
let tree = parser.parse(python_source, None).unwrap();
32
34
let file =
33
-
File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file");
35
+
File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file");
34
36
let functions = Functions::stdlib();
35
37
let mut globals = Variables::new();
36
38
globals
+3
-1
tests/it/graph.rs
+3
-1
tests/it/graph.rs
···
51
51
fn can_display_graph() {
52
52
let python_source = "pass";
53
53
let mut parser = Parser::new();
54
-
parser.set_language(tree_sitter_python::language()).unwrap();
54
+
parser
55
+
.set_language(&tree_sitter_python::LANGUAGE.into())
56
+
.unwrap();
55
57
let tree = parser.parse(python_source, None).unwrap();
56
58
57
59
let mut graph = Graph::new();
+4
-2
tests/it/lazy_execution.rs
+4
-2
tests/it/lazy_execution.rs
···
26
26
fn execute(python_source: &str, dsl_source: &str) -> Result<String, ExecutionError> {
27
27
init_log();
28
28
let mut parser = Parser::new();
29
-
parser.set_language(tree_sitter_python::language()).unwrap();
29
+
parser
30
+
.set_language(&tree_sitter_python::LANGUAGE.into())
31
+
.unwrap();
30
32
let tree = parser.parse(python_source, None).unwrap();
31
33
let file =
32
-
File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file");
34
+
File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file");
33
35
let functions = Functions::stdlib();
34
36
let mut globals = Variables::new();
35
37
globals
+3
-1
tests/it/parse_errors.rs
+3
-1
tests/it/parse_errors.rs
···
23
23
fn parse(python_source: &str) -> Tree {
24
24
init_log();
25
25
let mut parser = Parser::new();
26
-
parser.set_language(tree_sitter_python::language()).unwrap();
26
+
parser
27
+
.set_language(&tree_sitter_python::LANGUAGE.into())
28
+
.unwrap();
27
29
parser.parse(python_source, None).unwrap()
28
30
}
29
31
+64
-39
tests/it/parser.rs
+64
-39
tests/it/parser.rs
···
27
27
set @cap2.var1 = loc1
28
28
}
29
29
"#;
30
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
30
+
let file =
31
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
31
32
32
33
let loc1 = Identifier::from("loc1");
33
34
let precedence = Identifier::from("precedence");
···
228
229
let t = #true
229
230
}
230
231
"#;
231
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
232
+
let file =
233
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
232
234
233
235
let f = Identifier::from("f");
234
236
let n = Identifier::from("n");
···
284
286
let loc1 = "\"abc,\ndef\\"
285
287
}
286
288
"#;
287
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
289
+
let file =
290
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
288
291
289
292
let loc1 = Identifier::from("loc1");
290
293
···
318
321
let list3 = ["hello", "world",]
319
322
}
320
323
"#;
321
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
324
+
let file =
325
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
322
326
323
327
let list1 = Identifier::from("list1");
324
328
let list2 = Identifier::from("list2");
···
395
399
let set3 = {"hello", "world",}
396
400
}
397
401
"#;
398
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
402
+
let file =
403
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
399
404
400
405
let set1 = Identifier::from("set1");
401
406
let set2 = Identifier::from("set2");
···
470
475
print "x =", 5
471
476
}
472
477
"#;
473
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
478
+
let file =
479
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
474
480
475
481
let statements = file
476
482
.stanzas
···
505
511
node n
506
512
}
507
513
"#;
508
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
514
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
509
515
panic!("Parse succeeded unexpectedly");
510
516
}
511
517
}
···
518
524
print @stmts
519
525
}
520
526
"#;
521
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
527
+
let file =
528
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
522
529
523
530
let stmts = Identifier::from("stmts");
524
531
···
553
560
print @stmts
554
561
}
555
562
"#;
556
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
563
+
let file =
564
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
557
565
558
566
let stmt = Identifier::from("stmt");
559
567
let stmts = Identifier::from("stmts");
···
602
610
print @stmts
603
611
}
604
612
"#;
605
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
613
+
let file =
614
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
606
615
607
616
let stmts = Identifier::from("stmts");
608
617
···
636
645
print @stmt
637
646
}
638
647
"#;
639
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
648
+
let file =
649
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
640
650
641
651
let stmt = Identifier::from("stmt");
642
652
···
670
680
print @stmt
671
681
}
672
682
"#;
673
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
683
+
let file =
684
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
674
685
675
686
let stmt = Identifier::from("stmt");
676
687
···
704
715
print @stmt
705
716
}
706
717
"#;
707
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
718
+
let file =
719
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
708
720
709
721
let stmt = Identifier::from("stmt");
710
722
···
738
750
print @stmt
739
751
}
740
752
"#;
741
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
753
+
let file =
754
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
742
755
743
756
let stmt = Identifier::from("stmt");
744
757
···
774
787
}
775
788
}
776
789
"#;
777
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
790
+
let file =
791
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
778
792
779
793
let x = Identifier::from("x");
780
794
···
826
840
}
827
841
}
828
842
"#;
829
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
843
+
let file =
844
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
830
845
831
846
let x = Identifier::from("x");
832
847
···
903
918
}
904
919
}
905
920
"#;
906
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
921
+
let file =
922
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
907
923
908
924
let x = Identifier::from("x");
909
925
···
967
983
}
968
984
}
969
985
"#;
970
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
986
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
971
987
panic!("Parse succeeded unexpectedly");
972
988
}
973
989
}
···
982
998
}
983
999
}
984
1000
"#;
985
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1001
+
let file =
1002
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
986
1003
987
1004
let xs = Identifier::from("xs");
988
1005
let x = Identifier::from("x");
···
1032
1049
}
1033
1050
}
1034
1051
"#;
1035
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1052
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1036
1053
panic!("Parse succeeded unexpectedly");
1037
1054
}
1038
1055
}
···
1051
1068
}
1052
1069
}
1053
1070
"#;
1054
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1071
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1055
1072
panic!("Parse succeeded unexpectedly");
1056
1073
}
1057
1074
}
···
1071
1088
}
1072
1089
}
1073
1090
"#;
1074
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1091
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1075
1092
panic!("Parse succeeded unexpectedly");
1076
1093
}
1077
1094
}
···
1084
1101
print [ (named-child-index x) for x in @xs ]
1085
1102
}
1086
1103
"#;
1087
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1104
+
let file =
1105
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1088
1106
1089
1107
let statements = file
1090
1108
.stanzas
···
1137
1155
print { (named-child-index x) for x in @xs }
1138
1156
}
1139
1157
"#;
1140
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1158
+
let file =
1159
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1141
1160
1142
1161
let statements = file
1143
1162
.stanzas
···
1192
1211
edge n -> root
1193
1212
}
1194
1213
"#;
1195
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1214
+
let file =
1215
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1196
1216
1197
1217
assert_eq!(
1198
1218
file.globals,
···
1248
1268
print PKG_NAME
1249
1269
}
1250
1270
"#;
1251
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1271
+
let file =
1272
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1252
1273
1253
1274
assert_eq!(
1254
1275
file.globals,
···
1287
1308
edge n -> root
1288
1309
}
1289
1310
"#;
1290
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1311
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1291
1312
panic!("Parse succeeded unexpectedly");
1292
1313
}
1293
1314
}
···
1304
1325
}
1305
1326
}
1306
1327
"#;
1307
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1328
+
let file =
1329
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1308
1330
1309
1331
assert_eq!(
1310
1332
file.globals,
···
1377
1399
}
1378
1400
}
1379
1401
"#;
1380
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1402
+
let file =
1403
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1381
1404
1382
1405
assert_eq!(
1383
1406
file.globals,
···
1448
1471
node root
1449
1472
}
1450
1473
"#;
1451
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1474
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1452
1475
panic!("Parse succeeded unexpectedly");
1453
1476
}
1454
1477
}
···
1462
1485
node root
1463
1486
}
1464
1487
"#;
1465
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1488
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1466
1489
panic!("Parse succeeded unexpectedly");
1467
1490
}
1468
1491
}
···
1476
1499
set root = #null
1477
1500
}
1478
1501
"#;
1479
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1502
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1480
1503
panic!("Parse succeeded unexpectedly");
1481
1504
}
1482
1505
}
···
1490
1513
attr (n) sh = @name
1491
1514
}
1492
1515
"#;
1493
-
let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file");
1516
+
let file =
1517
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file");
1494
1518
1495
1519
let shorthands = file.shorthands.into_iter().collect::<Vec<_>>();
1496
1520
assert_eq!(
···
1536
1560
{
1537
1561
}
1538
1562
"#;
1539
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1563
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1540
1564
panic!("Parse succeeded unexpectedly");
1541
1565
}
1542
1566
}
···
1548
1572
(module (non_existing_node))
1549
1573
{}
1550
1574
"#;
1551
-
let err = match File::from_str(tree_sitter_python::language(), source) {
1575
+
let err = match File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1552
1576
Ok(_) => panic!("Parse succeeded unexpectedly"),
1553
1577
Err(ParseError::QueryError(e)) => e,
1554
1578
Err(e) => panic!("Unexpected error: {}", e),
···
1570
1594
]
1571
1595
{}
1572
1596
"#;
1573
-
let err = match File::from_str(tree_sitter_python::language(), source) {
1597
+
let err = match File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1574
1598
Ok(_) => panic!("Parse succeeded unexpectedly"),
1575
1599
Err(ParseError::QueryError(e)) => e,
1576
1600
Err(e) => panic!("Unexpected error: {}", e),
···
1586
1610
(function_definition name: (identifier) @name) {
1587
1611
}
1588
1612
"#;
1589
-
if let Ok(_) = File::from_str(tree_sitter_python::language(), source) {
1613
+
if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) {
1590
1614
panic!("Parse succeeded unexpectedly");
1591
1615
}
1592
1616
}
···
1597
1621
(function_definition name: (identifier) @_name) {
1598
1622
}
1599
1623
"#;
1600
-
File::from_str(tree_sitter_python::language(), source).expect("parse to succeed");
1624
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("parse to succeed");
1601
1625
}
1602
1626
1603
1627
#[test]
···
1605
1629
let source = r#"
1606
1630
inherit .scope
1607
1631
"#;
1608
-
let file = File::from_str(tree_sitter_python::language(), source).expect("parse to succeed");
1632
+
let file =
1633
+
File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("parse to succeed");
1609
1634
assert!(file.inherited_variables.contains("scope".into()));
1610
1635
}
+6
vscode/CHANGELOG.md
+6
vscode/CHANGELOG.md
···
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## 0.1.2 -- 2023-12-12
9
+
10
+
### Added
11
+
12
+
- Add missing `else` keyword
13
+
8
14
## 0.1.1 -- 2023-06-01
9
15
10
16
### Added