|
|
@ -217,6 +217,41 @@ pub mod tasks {
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn query_check() -> Result<(), String> {
|
|
|
|
|
|
|
|
use crate::helpers::lang_config;
|
|
|
|
|
|
|
|
use helix_core::{syntax::read_query, tree_sitter::Query};
|
|
|
|
|
|
|
|
use helix_loader::grammar::get_language;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let query_files = [
|
|
|
|
|
|
|
|
"highlights.scm",
|
|
|
|
|
|
|
|
"locals.scm",
|
|
|
|
|
|
|
|
"injections.scm",
|
|
|
|
|
|
|
|
"textobjects.scm",
|
|
|
|
|
|
|
|
"indents.scm",
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for language in lang_config().language {
|
|
|
|
|
|
|
|
let language_name = language.language_id.to_ascii_lowercase();
|
|
|
|
|
|
|
|
let grammar_name = language.grammar.unwrap_or(language.language_id);
|
|
|
|
|
|
|
|
for query_file in query_files {
|
|
|
|
|
|
|
|
let language = get_language(&grammar_name);
|
|
|
|
|
|
|
|
let query_text = read_query(&language_name, query_file);
|
|
|
|
|
|
|
|
if !query_text.is_empty() && language.is_ok() {
|
|
|
|
|
|
|
|
if let Err(reason) = Query::new(language.unwrap(), &query_text) {
|
|
|
|
|
|
|
|
return Err(format!(
|
|
|
|
|
|
|
|
"Failed to parse {} queries for {}: {}",
|
|
|
|
|
|
|
|
query_file, language_name, reason
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("Query check succeeded");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn print_help() {
|
|
|
|
pub fn print_help() {
|
|
|
|
println!(
|
|
|
|
println!(
|
|
|
|
"
|
|
|
|
"
|
|
|
@ -224,6 +259,7 @@ Usage: Run with `cargo xtask <task>`, eg. `cargo xtask docgen`.
|
|
|
|
|
|
|
|
|
|
|
|
Tasks:
|
|
|
|
Tasks:
|
|
|
|
docgen: Generate files to be included in the mdbook output.
|
|
|
|
docgen: Generate files to be included in the mdbook output.
|
|
|
|
|
|
|
|
query-check: Check that tree-sitter queries are valid.
|
|
|
|
"
|
|
|
|
"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -235,6 +271,7 @@ fn main() -> Result<(), DynError> {
|
|
|
|
None => tasks::print_help(),
|
|
|
|
None => tasks::print_help(),
|
|
|
|
Some(t) => match t.as_str() {
|
|
|
|
Some(t) => match t.as_str() {
|
|
|
|
"docgen" => tasks::docgen()?,
|
|
|
|
"docgen" => tasks::docgen()?,
|
|
|
|
|
|
|
|
"query-check" => tasks::query_check()?,
|
|
|
|
invalid => return Err(format!("Invalid task name: {}", invalid).into()),
|
|
|
|
invalid => return Err(format!("Invalid task name: {}", invalid).into()),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|