Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c15783

Browse files
authored
Merge pull request #12 from github/crates-language
Use tree-sitter-ruby crate instead of vendoring it
2 parents 3e1c378 + a41c3e3 commit 0c15783

11 files changed

Lines changed: 21 additions & 50 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cargo.lock -diff -whitespace

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020

2121
steps:
2222
- uses: actions/checkout@v2
23-
with:
24-
submodules: true
2523
- name: Build
2624
run: cargo build --verbose
2725
- name: Run tests

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "tree-sitter-ruby"]
2-
path = tree-sitter-ruby
3-
url = https://github.com/tree-sitter/tree-sitter-ruby.git

Cargo.lock

Lines changed: 12 additions & 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ edition = "2018"
99
[dependencies]
1010
node-types = { path = "../node-types" }
1111
tree-sitter = "0.17.0"
12+
tree-sitter-ruby = "0.16"
1213
clap = "2.33"
1314
tracing = "0.1"
1415
tracing-subscriber = { version = "0.2", features = ["env-filter"] }
15-
[build-dependencies]
16-
cc="*"
17-

extractor/build.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

extractor/src/main.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@ use clap;
44
use std::fs;
55
use std::io::BufRead;
66
use std::path::{Path, PathBuf};
7-
use tree_sitter::Language;
8-
9-
const NODE_TYPES: &'static str = include_str!("../../tree-sitter-ruby/src/node-types.json");
107

118
fn main() -> std::io::Result<()> {
12-
extern "C" {
13-
fn tree_sitter_ruby() -> Language;
14-
}
15-
169
tracing_subscriber::fmt()
1710
.with_target(false)
1811
.without_time()
@@ -43,8 +36,8 @@ fn main() -> std::io::Result<()> {
4336
let file_list = matches.value_of("file-list").expect("missing --file-list");
4437
let file_list = fs::File::open(file_list)?;
4538

46-
let language = unsafe { tree_sitter_ruby() };
47-
let schema = node_types::read_node_types_str(NODE_TYPES)?;
39+
let language = tree_sitter_ruby::language();
40+
let schema = node_types::read_node_types_str(tree_sitter_ruby::NODE_TYPES)?;
4841
let mut extractor = extractor::create(language, schema);
4942
for line in std::io::BufReader::new(file_list).lines() {
5043
let path = PathBuf::from(line?);

generator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +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-ruby = "0.16"

generator/src/language.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ use std::path::PathBuf;
22

33
pub struct Language {
44
pub name: String,
5-
pub node_types_path: PathBuf,
5+
pub node_types: &'static str,
66
pub dbscheme_path: PathBuf,
77
}

generator/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ fn main() {
288288
// command line.
289289
let ruby = Language {
290290
name: "Ruby".to_string(),
291-
node_types_path: PathBuf::from("tree-sitter-ruby/src/node-types.json"),
291+
node_types: tree_sitter_ruby::NODE_TYPES,
292292
dbscheme_path: PathBuf::from("ruby.dbscheme"),
293293
};
294-
match node_types::read_node_types(&ruby.node_types_path) {
294+
match node_types::read_node_types_str(&ruby.node_types) {
295295
Err(e) => {
296-
error!("Failed to read '{}': {}", ruby.node_types_path.display(), e);
296+
error!("Failed to read node-types JSON for {}: {}", ruby.name, e);
297297
std::process::exit(1);
298298
}
299299
Ok(nodes) => {

0 commit comments

Comments
 (0)