diff --git a/crates/lsp/src/language.rs b/crates/lsp/src/language.rs index a54f5d8c5..2e61c5e23 100644 --- a/crates/lsp/src/language.rs +++ b/crates/lsp/src/language.rs @@ -9,6 +9,7 @@ pub fn language_id_to_pattern_language(language_id: &str) -> Option Some(PatternLanguage::Css), "json" | "jsonc" => Some(PatternLanguage::Json), "java" => Some(PatternLanguage::Java), + "kotlin" => Some(PatternLanguage::Kotlin), "csharp" => Some(PatternLanguage::CSharp), "python" => Some(PatternLanguage::Python), "markdown" => Some(PatternLanguage::MarkdownInline), @@ -36,6 +37,7 @@ pub fn target_language_to_language_id(target_language: TargetLanguage) -> &'stat TargetLanguage::Css(_) => "css", TargetLanguage::Json(_) => "json", TargetLanguage::Java(_) => "java", + TargetLanguage::Kotlin(_) => "kotlin", TargetLanguage::CSharp(_) => "csharp", TargetLanguage::Python(_) => "python", TargetLanguage::MarkdownInline(_) => "markdown", diff --git a/crates/wasm-bindings/src/match_pattern.rs b/crates/wasm-bindings/src/match_pattern.rs index 9cdb4909d..4aa818b93 100644 --- a/crates/wasm-bindings/src/match_pattern.rs +++ b/crates/wasm-bindings/src/match_pattern.rs @@ -34,6 +34,7 @@ static HTML_LANGUAGE: OnceLock = OnceLock::new(); static CSS_LANGUAGE: OnceLock = OnceLock::new(); static JSON_LANGUAGE: OnceLock = OnceLock::new(); static JAVA_LANGUAGE: OnceLock = OnceLock::new(); +static KOTLIN_LANGUAGE: OnceLock = OnceLock::new(); static CSHARP_LANGUAGE: OnceLock = OnceLock::new(); static PYTHON_LANGUAGE: OnceLock = OnceLock::new(); static MARKDOWN_BLOCK_LANGUAGE: OnceLock = OnceLock::new(); @@ -468,6 +469,7 @@ fn pattern_language_to_path(lang: &PatternLanguage) -> anyhow::Result { PatternLanguage::Css => Ok("/tree-sitter-css.wasm"), PatternLanguage::Json => Ok("/tree-sitter-json.wasm"), PatternLanguage::Java => Ok("/tree-sitter-java.wasm"), + PatternLanguage::Kotlin => Ok("/tree-sitter-kotlin.wasm"), PatternLanguage::CSharp => Err(anyhow::anyhow!("CSharp wasm is not currently supported")), PatternLanguage::Python => Ok("/tree-sitter-python.wasm"), PatternLanguage::MarkdownBlock => Ok("/tree-sitter-markdown-block.wasm"), // def wrong @@ -513,6 +515,7 @@ fn get_lang_store(language: &PatternLanguage) -> anyhow::Result<&'static OnceLoc PatternLanguage::Css => Ok(&CSS_LANGUAGE), PatternLanguage::Json => Ok(&JSON_LANGUAGE), PatternLanguage::Java => Ok(&JAVA_LANGUAGE), + PatternLanguage::Kotlin => Ok(&KOTLIN_LANGUAGE), PatternLanguage::CSharp => Ok(&CSHARP_LANGUAGE), PatternLanguage::Python => Ok(&PYTHON_LANGUAGE), PatternLanguage::MarkdownBlock => Ok(&MARKDOWN_BLOCK_LANGUAGE), diff --git a/resources/add_language.py b/resources/add_language.py index 33481d1ca..b4bfbeeeb 100644 --- a/resources/add_language.py +++ b/resources/add_language.py @@ -117,6 +117,7 @@ def main(args: Namespace): """Automate the process of adding a new language to the gritql metavariable-grammars.""" language = args.language.lower() + language_upper_case = language.upper() language_title_case = language.title() language_rs = LANGUAGE_TEMPLATE_RS.format( language=language, language_title_case=language_title_case @@ -172,8 +173,10 @@ def main(args: Namespace): 2. add `tree-sitter-{language}` to crates/language/Cargo.toml [dependencies] and [features.builtin-parser] 3. add `pub mod {language};` to crates/language/src/lib.rs 4. add `use crate::{language}::{language_title_case}` to crates/language/src/target_language.rs and add it to all enums and match statements - 5. add {language} to the `PatternsDirectory` struct in crates/gritmodule/src/patterns_directory.rs add it to all match statements - 6. add test cases for {language} in crates/core/src/test.rs + 5. add {language} to the `PatternsDirectory` struct in crates/gritmodule/src/patterns_directory.rs and add it to all match statements + 6. add {language_title_case} to all match statements in crates/lsp/src/language.rs + 7. add {language_upper_case}_LANGUAGE as a static in crates/wasm-bindings/src/match_pattern.rs and add it to all match statements + 8. add test cases for {language} in crates/core/src/test.rs """)