tree_sitter 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +0 -16
- data/ext/tree_sitter/Cargo.toml +2 -2
- data/ext/tree_sitter/src/node.rs +7 -3
- data/ext/tree_sitter/src/parser.rs +8 -2
- data/ext/tree_sitter/src/point.rs +4 -1
- data/ext/tree_sitter/src/query.rs +7 -13
- data/lib/tree_sitter/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0b2d772b22f19f99081336a659fd814d8021ed1fbbfc724ed48cee5dd113dd50
|
|
4
|
+
data.tar.gz: 9ac58d1b10265bfd78a0ccab002459809ff90bd43fd05d215db72034385dc8b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d603f69492c5c8f2a4bd5c08dd768f39accba6ccf78c78ef591dcff3c11afee6f20399571027134ea45915c4df036b7854bc10370b30642188aa5b0092b10186
|
|
7
|
+
data.tar.gz: a619faa2eaf9f2f6fc89589a54ef952d0e3eb2448909c8af54d65392bda32ed6f8e45ef17b6ce3625911a5dd6adf9cbc5c68dd4025425aaf36d18ca342c559e2
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# [v0.1.0] - 13-01-2026
|
|
2
|
+
## What's Changed
|
|
3
|
+
* Bump libloading from 0.8.9 to 0.9.0 by @dependabot[bot] in https://github.com/gjtorikian/tree_sitter/pull/2
|
|
4
|
+
* Bump tree-sitter from 0.25.10 to 0.26.3 by @dependabot[bot] in https://github.com/gjtorikian/tree_sitter/pull/3
|
|
5
|
+
* Bump actions/checkout from 4 to 6 by @dependabot[bot] in https://github.com/gjtorikian/tree_sitter/pull/1
|
|
6
|
+
* Test build bump by @gjtorikian in https://github.com/gjtorikian/tree_sitter/pull/4
|
|
7
|
+
|
|
8
|
+
## New Contributors
|
|
9
|
+
* @dependabot[bot] made their first contribution in https://github.com/gjtorikian/tree_sitter/pull/2
|
|
10
|
+
* @gjtorikian made their first contribution in https://github.com/gjtorikian/tree_sitter/pull/4
|
|
11
|
+
|
|
12
|
+
**Full Changelog**: https://github.com/gjtorikian/tree_sitter/commits/v0.1.0
|
data/README.md
CHANGED
|
@@ -422,22 +422,6 @@ make ruby python # Ruby and Python
|
|
|
422
422
|
|
|
423
423
|
**You can use this Makefile as a reference for your own project! The gem does NOT ship with any grammars!**
|
|
424
424
|
|
|
425
|
-
### Using ts-grammar-action
|
|
426
|
-
|
|
427
|
-
For GitHub Actions, use [kettle-rb/ts-grammar-action](https://github.com/kettle-rb/ts-grammar-action):
|
|
428
|
-
|
|
429
|
-
```yaml
|
|
430
|
-
- uses: kettle-rb/ts-grammar-action@v1
|
|
431
|
-
with:
|
|
432
|
-
grammars: |
|
|
433
|
-
rust
|
|
434
|
-
ruby
|
|
435
|
-
python
|
|
436
|
-
javascript
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
This sets environment variables like `TREE_SITTER_RUST_PATH` pointing to the installed grammars.
|
|
440
|
-
|
|
441
425
|
### Custom Grammar Paths
|
|
442
426
|
|
|
443
427
|
You can override grammar locations with environment variables:
|
data/ext/tree_sitter/Cargo.toml
CHANGED
|
@@ -11,8 +11,8 @@ crate-type = ["cdylib"]
|
|
|
11
11
|
[dependencies]
|
|
12
12
|
magnus = "0.8"
|
|
13
13
|
rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
|
|
14
|
-
tree-sitter = "0.
|
|
14
|
+
tree-sitter = "0.26"
|
|
15
15
|
tree-sitter-language = "0.1"
|
|
16
|
-
libloading = "0.
|
|
16
|
+
libloading = "0.9"
|
|
17
17
|
once_cell = "1.19"
|
|
18
18
|
streaming-iterator = "0.1"
|
data/ext/tree_sitter/src/node.rs
CHANGED
|
@@ -35,7 +35,11 @@ pub struct Node {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
impl Node {
|
|
38
|
-
pub fn new(
|
|
38
|
+
pub fn new(
|
|
39
|
+
ts_node: tree_sitter::Node,
|
|
40
|
+
source: Arc<String>,
|
|
41
|
+
tree: Arc<tree_sitter::Tree>,
|
|
42
|
+
) -> Self {
|
|
39
43
|
Self {
|
|
40
44
|
tree,
|
|
41
45
|
source,
|
|
@@ -81,7 +85,7 @@ impl Node {
|
|
|
81
85
|
pub fn child(&self, index: usize) -> Option<Node> {
|
|
82
86
|
let ts_node = self.get_ts_node()?;
|
|
83
87
|
ts_node
|
|
84
|
-
.child(index)
|
|
88
|
+
.child(index as u32)
|
|
85
89
|
.map(|n| Node::new(n, self.source.clone(), self.tree.clone()))
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -92,7 +96,7 @@ impl Node {
|
|
|
92
96
|
pub fn named_child(&self, index: usize) -> Option<Node> {
|
|
93
97
|
let ts_node = self.get_ts_node()?;
|
|
94
98
|
ts_node
|
|
95
|
-
.named_child(index)
|
|
99
|
+
.named_child(index as u32)
|
|
96
100
|
.map(|n| Node::new(n, self.source.clone(), self.tree.clone()))
|
|
97
101
|
}
|
|
98
102
|
|
|
@@ -2,6 +2,7 @@ use crate::language::{get_language_internal, Language};
|
|
|
2
2
|
use crate::tree::Tree;
|
|
3
3
|
use magnus::{prelude::*, Error, RString, Ruby, TryConvert, Value};
|
|
4
4
|
use std::cell::RefCell;
|
|
5
|
+
use std::ops::ControlFlow;
|
|
5
6
|
use std::time::Instant;
|
|
6
7
|
|
|
7
8
|
#[magnus::wrap(class = "TreeSitter::Parser")]
|
|
@@ -90,8 +91,13 @@ impl Parser {
|
|
|
90
91
|
let result = if timeout > 0 {
|
|
91
92
|
let start = Instant::now();
|
|
92
93
|
let source_bytes = source.as_bytes();
|
|
93
|
-
let mut progress_callback =
|
|
94
|
-
|
|
94
|
+
let mut progress_callback = |_: &tree_sitter::ParseState| {
|
|
95
|
+
if start.elapsed().as_micros() < timeout as u128 {
|
|
96
|
+
ControlFlow::Continue(())
|
|
97
|
+
} else {
|
|
98
|
+
ControlFlow::Break(())
|
|
99
|
+
}
|
|
100
|
+
};
|
|
95
101
|
let options =
|
|
96
102
|
tree_sitter::ParseOptions::new().progress_callback(&mut progress_callback);
|
|
97
103
|
let mut source_callback = |offset: usize, _: tree_sitter::Point| {
|
|
@@ -36,7 +36,10 @@ impl Point {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
pub fn inspect(&self) -> String {
|
|
39
|
-
format!(
|
|
39
|
+
format!(
|
|
40
|
+
"#<TreeSitter::Point row={} column={}>",
|
|
41
|
+
self.row, self.column
|
|
42
|
+
)
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
pub fn eq(&self, other: &Point) -> bool {
|
|
@@ -21,7 +21,11 @@ impl Query {
|
|
|
21
21
|
)
|
|
22
22
|
})?;
|
|
23
23
|
|
|
24
|
-
let capture_names = query
|
|
24
|
+
let capture_names = query
|
|
25
|
+
.capture_names()
|
|
26
|
+
.iter()
|
|
27
|
+
.map(|s| s.to_string())
|
|
28
|
+
.collect();
|
|
25
29
|
|
|
26
30
|
Ok(Self {
|
|
27
31
|
inner: query,
|
|
@@ -55,12 +59,7 @@ impl QueryCursor {
|
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
pub fn matches(
|
|
59
|
-
&self,
|
|
60
|
-
query: &Query,
|
|
61
|
-
node: &Node,
|
|
62
|
-
source: String,
|
|
63
|
-
) -> RArray {
|
|
62
|
+
pub fn matches(&self, query: &Query, node: &Node, source: String) -> RArray {
|
|
64
63
|
let ruby = Ruby::get().unwrap();
|
|
65
64
|
let array = ruby.ary_new();
|
|
66
65
|
let Some(ts_node) = node.get_ts_node_pub() else {
|
|
@@ -92,12 +91,7 @@ impl QueryCursor {
|
|
|
92
91
|
array
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
pub fn captures(
|
|
96
|
-
&self,
|
|
97
|
-
query: &Query,
|
|
98
|
-
node: &Node,
|
|
99
|
-
source: String,
|
|
100
|
-
) -> RArray {
|
|
94
|
+
pub fn captures(&self, query: &Query, node: &Node, source: String) -> RArray {
|
|
101
95
|
let ruby = Ruby::get().unwrap();
|
|
102
96
|
let array = ruby.ary_new();
|
|
103
97
|
let Some(ts_node) = node.get_ts_node_pub() else {
|
data/lib/tree_sitter/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tree_sitter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen J. Torikian
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rb_sys
|
|
@@ -60,6 +60,7 @@ extensions:
|
|
|
60
60
|
- ext/tree_sitter/extconf.rb
|
|
61
61
|
extra_rdoc_files: []
|
|
62
62
|
files:
|
|
63
|
+
- CHANGELOG.md
|
|
63
64
|
- LICENSE.txt
|
|
64
65
|
- Makefile
|
|
65
66
|
- README.md
|
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
106
107
|
- !ruby/object:Gem::Version
|
|
107
108
|
version: '3.4'
|
|
108
109
|
requirements: []
|
|
109
|
-
rubygems_version:
|
|
110
|
+
rubygems_version: 4.0.3
|
|
110
111
|
specification_version: 4
|
|
111
112
|
summary: Ruby bindings for tree-sitter with code transformation and refactoring capabilities.
|
|
112
113
|
Written in Rust, wrapped in Ruby.
|