aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/querycheck.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/querycheck.rs')
-rw-r--r--xtask/src/querycheck.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/xtask/src/querycheck.rs b/xtask/src/querycheck.rs
new file mode 100644
index 00000000..5595b8ec
--- /dev/null
+++ b/xtask/src/querycheck.rs
@@ -0,0 +1,39 @@
+use crate::DynError;
+
+pub fn query_check() -> Result<(), DynError> {
+ 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 let Ok(lang) = language {
+ if !query_text.is_empty() {
+ if let Err(reason) = Query::new(lang, &query_text) {
+ return Err(format!(
+ "Failed to parse {} queries for {}: {}",
+ query_file, language_name, reason
+ )
+ .into());
+ }
+ }
+ }
+ }
+ }
+
+ println!("Query check succeeded");
+
+ Ok(())
+}