From b533b31add3953f851baba12983a4bccf1c1d47d Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Wed, 15 May 2024 12:04:21 +0200 Subject: [PATCH 1/2] Always enable both TS & TSX in CLI --- .../rust/bin.rs | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/languages/tree-sitter-stack-graphs-typescript/rust/bin.rs b/languages/tree-sitter-stack-graphs-typescript/rust/bin.rs index 797e8cea7..ea7713595 100644 --- a/languages/tree-sitter-stack-graphs-typescript/rust/bin.rs +++ b/languages/tree-sitter-stack-graphs-typescript/rust/bin.rs @@ -6,56 +6,34 @@ // ------------------------------------------------------------------------------------------------ use anyhow::anyhow; -use clap::{Parser, ValueEnum}; +use clap::Parser; use tree_sitter_stack_graphs::cli::database::default_user_database_path_for_crate; use tree_sitter_stack_graphs::cli::provided_languages::Subcommands; -use tree_sitter_stack_graphs::loader::{LanguageConfiguration, LoadError}; use tree_sitter_stack_graphs::NoCancellation; -/// Flag to select the dialect of the language -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] -pub enum Dialect { - Typescript, - TSX, -} - fn main() -> anyhow::Result<()> { let cli = Cli::parse(); - let lc = match language_configuration(cli.dialect) { - Ok(lc) => lc, - Err(err) => { - eprintln!("{}", err.display_pretty()); - return Err(anyhow!("Language configuration error")); - } - }; - let default_db_path = default_user_database_path_for_crate(env!("CARGO_PKG_NAME"))?; - cli.subcommand.run(default_db_path, vec![lc]) -} - -fn language_configuration<'a>(dialect: Dialect) -> Result> { - match dialect { - Dialect::Typescript => { - tree_sitter_stack_graphs_typescript::try_language_configuration_typescript( - &NoCancellation, - ) - } - Dialect::TSX => { - tree_sitter_stack_graphs_typescript::try_language_configuration_tsx(&NoCancellation) - } + let mut lcs = Vec::new(); + for r in [ + tree_sitter_stack_graphs_typescript::try_language_configuration_typescript(&NoCancellation), + tree_sitter_stack_graphs_typescript::try_language_configuration_tsx(&NoCancellation), + ] { + let lc = match r { + Ok(lc) => lc, + Err(err) => { + eprintln!("{}", err.display_pretty()); + return Err(anyhow!("Language configuration error")); + } + }; + lcs.push(lc); } + let default_db_path = default_user_database_path_for_crate(env!("CARGO_PKG_NAME"))?; + cli.subcommand.run(default_db_path, lcs) } #[derive(Parser)] #[clap(about, version)] pub struct Cli { - #[clap( - short, - long, - value_enum, - default_value_t = Dialect::Typescript, - )] - dialect: Dialect, - #[clap(subcommand)] subcommand: Subcommands, } From 36f83ea6b262ee871bf4f7b64a9dcbabfd98e3f7 Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Wed, 15 May 2024 12:14:44 +0200 Subject: [PATCH 2/2] Update version and changelog --- languages/tree-sitter-stack-graphs-typescript/CHANGELOG.md | 6 ++++++ languages/tree-sitter-stack-graphs-typescript/Cargo.toml | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/languages/tree-sitter-stack-graphs-typescript/CHANGELOG.md b/languages/tree-sitter-stack-graphs-typescript/CHANGELOG.md index a23db2f0e..b4260b2a6 100644 --- a/languages/tree-sitter-stack-graphs-typescript/CHANGELOG.md +++ b/languages/tree-sitter-stack-graphs-typescript/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v0.3.0 -- unreleased + +### Added + +- Support for TSX. A new language configuration for TSX is available, and TSX is enabled in the CLI next to TypeScript. + ## v0.2.0 -- 2024-03-06 The `tree-sitter-stack-graphs` is updated to `v0.8`. diff --git a/languages/tree-sitter-stack-graphs-typescript/Cargo.toml b/languages/tree-sitter-stack-graphs-typescript/Cargo.toml index 46360f19c..e40c12625 100644 --- a/languages/tree-sitter-stack-graphs-typescript/Cargo.toml +++ b/languages/tree-sitter-stack-graphs-typescript/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "tree-sitter-stack-graphs-typescript" -version = "0.2.0" -description = "Stack graphs definition for TypeScript using tree-sitter-typescript" +version = "0.3.0" +description = "Stack graphs definition for TypeScript & TSX using tree-sitter-typescript" readme = "README.md" -keywords = ["tree-sitter", "stack-graphs", "typescript"] +keywords = ["tree-sitter", "stack-graphs", "typescript", "tsx"] authors = ["Hendrik van Antwerpen "] license = "MIT OR Apache-2.0" edition = "2018"