Skip to content

Commit 777cbf6

Browse files
committed
fix clippy take 2
1 parent 4b6ecb5 commit 777cbf6

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

registry_lib/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ impl RegistryHelper {
2525
/// # Arguments
2626
///
2727
/// * `config` - The string with registry configuration information.
28+
///
29+
/// # Errors
30+
///
31+
/// * `RegistryError` - The error that occurred.
2832
pub fn new(config: &str) -> Result<Self, RegistryError> {
2933
let registry: Registry = match serde_json::from_str(config) {
3034
Ok(config) => config,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fn main() {
2+
let src_dir = std::path::Path::new("src");
3+
4+
let mut c_config = cc::Build::new();
5+
c_config.std("c11").include(src_dir);
6+
7+
#[cfg(target_env = "msvc")]
8+
c_config.flag("-utf-8");
9+
10+
let parser_path = src_dir.join("parser.c");
11+
c_config.file(&parser_path);
12+
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
13+
14+
let scanner_path = src_dir.join("scanner.c");
15+
if scanner_path.exists() {
16+
c_config.file(&scanner_path);
17+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
18+
}
19+
20+
c_config.compile("tree-sitter-sshd-config");
21+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//! This crate provides sshd_config language support for the [tree-sitter][] parsing library.
2+
//!
3+
//! Typically, you will use the [LANGUAGE][] constant to add this language to a
4+
//! tree-sitter [Parser][], and then use the parser to parse some code:
5+
//!
6+
//! ```
7+
//! let code = r#"
8+
//! "#;
9+
//! let mut parser = tree_sitter::Parser::new();
10+
//! let language = tree_sitter_sshd_config::LANGUAGE;
11+
//! parser
12+
//! .set_language(&language.into())
13+
//! .expect("Error loading SshdConfig parser");
14+
//! let tree = parser.parse(code, None).unwrap();
15+
//! assert!(!tree.root_node().has_error());
16+
//! ```
17+
//!
18+
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
19+
//! [tree-sitter]: https://tree-sitter.github.io/
20+
21+
use tree_sitter_language::LanguageFn;
22+
23+
extern "C" {
24+
fn tree_sitter_sshd_config() -> *const ();
25+
}
26+
27+
/// The tree-sitter [`LanguageFn`][LanguageFn] for this grammar.
28+
///
29+
/// [LanguageFn]: https://docs.rs/tree-sitter-language/*/tree_sitter_language/struct.LanguageFn.html
30+
pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_sshd_config) };
31+
32+
/// The content of the [`node-types.json`][] file for this grammar.
33+
///
34+
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types
35+
pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
36+
37+
// NOTE: uncomment these to include any queries that this grammar contains:
38+
39+
// pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/highlights.scm");
40+
// pub const INJECTIONS_QUERY: &str = include_str!("../../queries/injections.scm");
41+
// pub const LOCALS_QUERY: &str = include_str!("../../queries/locals.scm");
42+
// pub const TAGS_QUERY: &str = include_str!("../../queries/tags.scm");
43+
44+
#[cfg(test)]
45+
mod tests {
46+
#[test]
47+
fn test_can_load_grammar() {
48+
let mut parser = tree_sitter::Parser::new();
49+
parser
50+
.set_language(&super::LANGUAGE.into())
51+
.expect("Error loading SshdConfig parser");
52+
}
53+
}

0 commit comments

Comments
 (0)