diff --git a/Cargo.lock b/Cargo.lock index 8ad8fef01..7f0be321a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2191,16 +2191,34 @@ dependencies = [ ] [[package]] -name = "pg_analyse" +name = "pg_query" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b43f9990f5c9816195cb45b5fce403bd032ab1590d0df3525095ee267f0edc20" +dependencies = [ + "bindgen", + "cc", + "fs_extra", + "glob", + "itertools", + "prost", + "prost-build", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "pglt_analyse" version = "0.0.0" dependencies = [ "biome_deserialize", "biome_deserialize_macros", "enumflags2", - "pg_console", - "pg_diagnostics", - "pg_query_ext", - "pg_schema_cache", + "pglt_console", + "pglt_diagnostics", + "pglt_query_ext", + "pglt_schema_cache", "rustc-hash 2.1.0", "schemars", "serde", @@ -2208,27 +2226,27 @@ dependencies = [ ] [[package]] -name = "pg_analyser" +name = "pglt_analyser" version = "0.0.0" dependencies = [ - "pg_analyse", - "pg_console", - "pg_query_ext", + "pglt_analyse", + "pglt_console", + "pglt_query_ext", "serde", ] [[package]] -name = "pg_base_db" +name = "pglt_base_db" version = "0.0.0" dependencies = [ "line_index", - "pg_fs", - "pg_statement_splitter", + "pglt_fs", + "pglt_statement_splitter", "text-size", ] [[package]] -name = "pg_cli" +name = "pglt_cli" version = "0.0.0" dependencies = [ "anyhow", @@ -2241,15 +2259,15 @@ dependencies = [ "libc", "mimalloc", "path-absolutize", - "pg_analyse", - "pg_configuration", - "pg_console", - "pg_diagnostics", - "pg_flags", - "pg_fs", - "pg_lsp", - "pg_text_edit", - "pg_workspace", + "pglt_analyse", + "pglt_configuration", + "pglt_console", + "pglt_diagnostics", + "pglt_flags", + "pglt_fs", + "pglt_lsp", + "pglt_text_edit", + "pglt_workspace", "quick-junit", "rayon", "rustc-hash 2.1.0", @@ -2264,7 +2282,7 @@ dependencies = [ ] [[package]] -name = "pg_commands" +name = "pglt_commands" version = "0.0.0" dependencies = [ "anyhow", @@ -2274,13 +2292,13 @@ dependencies = [ ] [[package]] -name = "pg_completions" +name = "pglt_completions" version = "0.0.0" dependencies = [ "async-std", - "pg_schema_cache", - "pg_test_utils", - "pg_treesitter_queries", + "pglt_schema_cache", + "pglt_test_utils", + "pglt_treesitter_queries", "serde", "serde_json", "sqlx", @@ -2291,16 +2309,16 @@ dependencies = [ ] [[package]] -name = "pg_configuration" +name = "pglt_configuration" version = "0.0.0" dependencies = [ "biome_deserialize", "biome_deserialize_macros", "bpaf", - "pg_analyse", - "pg_analyser", - "pg_console", - "pg_diagnostics", + "pglt_analyse", + "pglt_analyser", + "pglt_console", + "pglt_diagnostics", "rustc-hash 2.1.0", "schemars", "serde", @@ -2310,10 +2328,10 @@ dependencies = [ ] [[package]] -name = "pg_console" +name = "pglt_console" version = "0.0.0" dependencies = [ - "pg_markup", + "pglt_markup", "schemars", "serde", "termcolor", @@ -2324,16 +2342,16 @@ dependencies = [ ] [[package]] -name = "pg_diagnostics" +name = "pglt_diagnostics" version = "0.0.0" dependencies = [ "backtrace", "bpaf", "enumflags2", - "pg_console", - "pg_diagnostics_categories", - "pg_diagnostics_macros", - "pg_text_edit", + "pglt_console", + "pglt_diagnostics_categories", + "pglt_diagnostics_macros", + "pglt_text_edit", "schemars", "serde", "serde_json", @@ -2343,7 +2361,7 @@ dependencies = [ ] [[package]] -name = "pg_diagnostics_categories" +name = "pglt_diagnostics_categories" version = "0.0.0" dependencies = [ "quote", @@ -2352,7 +2370,7 @@ dependencies = [ ] [[package]] -name = "pg_diagnostics_macros" +name = "pglt_diagnostics_macros" version = "0.0.0" dependencies = [ "proc-macro-error", @@ -2362,21 +2380,21 @@ dependencies = [ ] [[package]] -name = "pg_flags" +name = "pglt_flags" version = "0.0.0" dependencies = [ - "pg_console", + "pglt_console", ] [[package]] -name = "pg_fs" +name = "pglt_fs" version = "0.0.0" dependencies = [ "crossbeam", "directories", "enumflags2", "parking_lot", - "pg_diagnostics", + "pglt_diagnostics", "rayon", "rustc-hash 2.1.0", "schemars", @@ -2386,42 +2404,42 @@ dependencies = [ ] [[package]] -name = "pg_lexer" +name = "pglt_lexer" version = "0.0.0" dependencies = [ "cstree", "insta", - "pg_lexer_codegen", "pg_query", + "pglt_lexer_codegen", "regex", "text-size", ] [[package]] -name = "pg_lexer_codegen" +name = "pglt_lexer_codegen" version = "0.0.0" dependencies = [ - "pg_query_proto_parser", + "pglt_query_proto_parser", "proc-macro2", "quote", ] [[package]] -name = "pg_lsp" +name = "pglt_lsp" version = "0.0.0" dependencies = [ "anyhow", "biome_deserialize", "futures", - "pg_analyse", - "pg_completions", - "pg_configuration", - "pg_console", - "pg_diagnostics", - "pg_fs", - "pg_lsp_converters", - "pg_text_edit", - "pg_workspace", + "pglt_analyse", + "pglt_completions", + "pglt_configuration", + "pglt_console", + "pglt_diagnostics", + "pglt_fs", + "pglt_lsp_converters", + "pglt_text_edit", + "pglt_workspace", "rustc-hash 2.1.0", "serde", "serde_json", @@ -2432,7 +2450,7 @@ dependencies = [ ] [[package]] -name = "pg_lsp_converters" +name = "pglt_lsp_converters" version = "0.0.0" dependencies = [ "anyhow", @@ -2442,7 +2460,7 @@ dependencies = [ ] [[package]] -name = "pg_markup" +name = "pglt_markup" version = "0.0.0" dependencies = [ "proc-macro-error", @@ -2451,46 +2469,28 @@ dependencies = [ ] [[package]] -name = "pg_query" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b43f9990f5c9816195cb45b5fce403bd032ab1590d0df3525095ee267f0edc20" -dependencies = [ - "bindgen", - "cc", - "fs_extra", - "glob", - "itertools", - "prost", - "prost-build", - "serde", - "serde_json", - "thiserror 1.0.69", -] - -[[package]] -name = "pg_query_ext" +name = "pglt_query_ext" version = "0.0.0" dependencies = [ "petgraph", - "pg_diagnostics", - "pg_lexer", "pg_query", - "pg_query_ext_codegen", + "pglt_diagnostics", + "pglt_lexer", + "pglt_query_ext_codegen", "text-size", ] [[package]] -name = "pg_query_ext_codegen" +name = "pglt_query_ext_codegen" version = "0.0.0" dependencies = [ - "pg_query_proto_parser", + "pglt_query_proto_parser", "proc-macro2", "quote", ] [[package]] -name = "pg_query_proto_parser" +name = "pglt_query_proto_parser" version = "0.0.0" dependencies = [ "convert_case", @@ -2499,15 +2499,15 @@ dependencies = [ ] [[package]] -name = "pg_schema_cache" +name = "pglt_schema_cache" version = "0.0.0" dependencies = [ "anyhow", "async-std", "futures-util", - "pg_console", - "pg_diagnostics", - "pg_test_utils", + "pglt_console", + "pglt_diagnostics", + "pglt_test_utils", "serde", "serde_json", "sqlx", @@ -2515,17 +2515,17 @@ dependencies = [ ] [[package]] -name = "pg_statement_splitter" +name = "pglt_statement_splitter" version = "0.0.0" dependencies = [ "ntest", - "pg_lexer", "pg_query", + "pglt_lexer", "text-size", ] [[package]] -name = "pg_test_utils" +name = "pglt_test_utils" version = "0.0.0" dependencies = [ "anyhow", @@ -2538,7 +2538,7 @@ dependencies = [ ] [[package]] -name = "pg_text_edit" +name = "pglt_text_edit" version = "0.0.0" dependencies = [ "schemars", @@ -2548,7 +2548,7 @@ dependencies = [ ] [[package]] -name = "pg_treesitter_queries" +name = "pglt_treesitter_queries" version = "0.0.0" dependencies = [ "clap", @@ -2557,23 +2557,23 @@ dependencies = [ ] [[package]] -name = "pg_type_resolver" +name = "pglt_type_resolver" version = "0.0.0" dependencies = [ - "pg_query_ext", - "pg_schema_cache", + "pglt_query_ext", + "pglt_schema_cache", ] [[package]] -name = "pg_typecheck" +name = "pglt_typecheck" version = "0.0.0" dependencies = [ "insta", - "pg_console", - "pg_diagnostics", - "pg_query_ext", - "pg_schema_cache", - "pg_test_utils", + "pglt_console", + "pglt_diagnostics", + "pglt_query_ext", + "pglt_schema_cache", + "pglt_test_utils", "sqlx", "text-size", "tokio", @@ -2582,24 +2582,24 @@ dependencies = [ ] [[package]] -name = "pg_workspace" +name = "pglt_workspace" version = "0.0.0" dependencies = [ "biome_deserialize", "dashmap 5.5.3", "futures", "ignore", - "pg_analyse", - "pg_analyser", - "pg_completions", - "pg_configuration", - "pg_console", - "pg_diagnostics", - "pg_fs", - "pg_query_ext", - "pg_schema_cache", - "pg_statement_splitter", - "pg_typecheck", + "pglt_analyse", + "pglt_analyser", + "pglt_completions", + "pglt_configuration", + "pglt_console", + "pglt_diagnostics", + "pglt_fs", + "pglt_query_ext", + "pglt_schema_cache", + "pglt_statement_splitter", + "pglt_typecheck", "rustc-hash 2.1.0", "serde", "serde_json", @@ -3077,13 +3077,13 @@ name = "rules_check" version = "0.0.0" dependencies = [ "anyhow", - "pg_analyse", - "pg_analyser", - "pg_console", - "pg_diagnostics", - "pg_query_ext", - "pg_statement_splitter", - "pg_workspace", + "pglt_analyse", + "pglt_analyser", + "pglt_console", + "pglt_diagnostics", + "pglt_query_ext", + "pglt_statement_splitter", + "pglt_workspace", "pulldown-cmark", ] @@ -4703,8 +4703,8 @@ dependencies = [ "anyhow", "biome_string_case", "bpaf", - "pg_analyse", - "pg_analyser", + "pglt_analyse", + "pglt_analyser", "proc-macro2", "pulldown-cmark", "quote", diff --git a/Cargo.toml b/Cargo.toml index b73642a36..902ef8902 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,37 +48,37 @@ tree_sitter_sql = { path = "./lib/tree_sitter_sql", version = "0.0.0" } unicode-width = "0.1.12" # postgres specific crates -pg_analyse = { path = "./crates/pg_analyse", version = "0.0.0" } -pg_analyser = { path = "./crates/pg_analyser", version = "0.0.0" } -pg_base_db = { path = "./crates/pg_base_db", version = "0.0.0" } -pg_cli = { path = "./crates/pg_cli", version = "0.0.0" } -pg_commands = { path = "./crates/pg_commands", version = "0.0.0" } -pg_completions = { path = "./crates/pg_completions", version = "0.0.0" } -pg_configuration = { path = "./crates/pg_configuration", version = "0.0.0" } -pg_console = { path = "./crates/pg_console", version = "0.0.0" } -pg_diagnostics = { path = "./crates/pg_diagnostics", version = "0.0.0" } -pg_diagnostics_categories = { path = "./crates/pg_diagnostics_categories", version = "0.0.0" } -pg_diagnostics_macros = { path = "./crates/pg_diagnostics_macros", version = "0.0.0" } -pg_flags = { path = "./crates/pg_flags", version = "0.0.0" } -pg_fs = { path = "./crates/pg_fs", version = "0.0.0" } -pg_lexer = { path = "./crates/pg_lexer", version = "0.0.0" } -pg_lexer_codegen = { path = "./crates/pg_lexer_codegen", version = "0.0.0" } -pg_lint = { path = "./crates/pg_lint", version = "0.0.0" } -pg_lsp = { path = "./crates/pg_lsp", version = "0.0.0" } -pg_lsp_converters = { path = "./crates/pg_lsp_converters", version = "0.0.0" } -pg_markup = { path = "./crates/pg_markup", version = "0.0.0" } -pg_query_ext = { path = "./crates/pg_query_ext", version = "0.0.0" } -pg_query_ext_codegen = { path = "./crates/pg_query_ext_codegen", version = "0.0.0" } -pg_query_proto_parser = { path = "./crates/pg_query_proto_parser", version = "0.0.0" } -pg_schema_cache = { path = "./crates/pg_schema_cache", version = "0.0.0" } -pg_statement_splitter = { path = "./crates/pg_statement_splitter", version = "0.0.0" } -pg_text_edit = { path = "./crates/pg_text_edit", version = "0.0.0" } -pg_treesitter_queries = { path = "./crates/pg_treesitter_queries", version = "0.0.0" } -pg_type_resolver = { path = "./crates/pg_type_resolver", version = "0.0.0" } -pg_typecheck = { path = "./crates/pg_typecheck", version = "0.0.0" } -pg_workspace = { path = "./crates/pg_workspace", version = "0.0.0" } +pglt_analyse = { path = "./crates/pglt_analyse", version = "0.0.0" } +pglt_analyser = { path = "./crates/pglt_analyser", version = "0.0.0" } +pglt_base_db = { path = "./crates/pglt_base_db", version = "0.0.0" } +pglt_cli = { path = "./crates/pglt_cli", version = "0.0.0" } +pglt_commands = { path = "./crates/pglt_commands", version = "0.0.0" } +pglt_completions = { path = "./crates/pglt_completions", version = "0.0.0" } +pglt_configuration = { path = "./crates/pglt_configuration", version = "0.0.0" } +pglt_console = { path = "./crates/pglt_console", version = "0.0.0" } +pglt_diagnostics = { path = "./crates/pglt_diagnostics", version = "0.0.0" } +pglt_diagnostics_categories = { path = "./crates/pglt_diagnostics_categories", version = "0.0.0" } +pglt_diagnostics_macros = { path = "./crates/pglt_diagnostics_macros", version = "0.0.0" } +pglt_flags = { path = "./crates/pglt_flags", version = "0.0.0" } +pglt_fs = { path = "./crates/pglt_fs", version = "0.0.0" } +pglt_lexer = { path = "./crates/pglt_lexer", version = "0.0.0" } +pglt_lexer_codegen = { path = "./crates/pglt_lexer_codegen", version = "0.0.0" } +pglt_lint = { path = "./crates/pglt_lint", version = "0.0.0" } +pglt_lsp = { path = "./crates/pglt_lsp", version = "0.0.0" } +pglt_lsp_converters = { path = "./crates/pglt_lsp_converters", version = "0.0.0" } +pglt_markup = { path = "./crates/pglt_markup", version = "0.0.0" } +pglt_query_ext = { path = "./crates/pglt_query_ext", version = "0.0.0" } +pglt_query_ext_codegen = { path = "./crates/pglt_query_ext_codegen", version = "0.0.0" } +pglt_query_proto_parser = { path = "./crates/pglt_query_proto_parser", version = "0.0.0" } +pglt_schema_cache = { path = "./crates/pglt_schema_cache", version = "0.0.0" } +pglt_statement_splitter = { path = "./crates/pglt_statement_splitter", version = "0.0.0" } +pglt_text_edit = { path = "./crates/pglt_text_edit", version = "0.0.0" } +pglt_treesitter_queries = { path = "./crates/pglt_treesitter_queries", version = "0.0.0" } +pglt_type_resolver = { path = "./crates/pglt_type_resolver", version = "0.0.0" } +pglt_typecheck = { path = "./crates/pglt_typecheck", version = "0.0.0" } +pglt_workspace = { path = "./crates/pglt_workspace", version = "0.0.0" } -pg_test_utils = { path = "./crates/pg_test_utils" } +pglt_test_utils = { path = "./crates/pglt_test_utils" } # parser = { path = "./crates/parser", version = "0.0.0" } # sql_parser = { path = "./crates/sql_parser", version = "0.0.0" } # sql_parser_codegen = { path = "./crates/sql_parser_codegen", version = "0.0.0" } diff --git a/crates/pg_analyser/src/lint.rs b/crates/pg_analyser/src/lint.rs deleted file mode 100644 index 0a2344ca2..000000000 --- a/crates/pg_analyser/src/lint.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Generated file, do not edit by hand, see `xtask/codegen` - -pub mod safety; -::pg_analyse::declare_category! { pub Lint { kind : Lint , groups : [self :: safety :: Safety ,] } } diff --git a/crates/pg_analyser/src/options.rs b/crates/pg_analyser/src/options.rs deleted file mode 100644 index 3bce44940..000000000 --- a/crates/pg_analyser/src/options.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! Generated file, do not edit by hand, see `xtask/codegen` - -use crate::lint; -pub type BanDropColumn = - ::Options; -pub type BanDropNotNull = - ::Options; diff --git a/crates/pg_console/tests/markup/open_element_unfinished_1.stderr b/crates/pg_console/tests/markup/open_element_unfinished_1.stderr deleted file mode 100644 index 8bbd3f187..000000000 --- a/crates/pg_console/tests/markup/open_element_unfinished_1.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: unexpected end of input - --> tests/markup/open_element_unfinished_1.rs:2:5 - | -2 | / pg_console::markup! { -3 | | < -4 | | } - | |_____^ - | - = note: this error originates in the macro `pg_console::markup` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/pg_console/tests/markup/open_element_unfinished_2.stderr b/crates/pg_console/tests/markup/open_element_unfinished_2.stderr deleted file mode 100644 index a6b9429fa..000000000 --- a/crates/pg_console/tests/markup/open_element_unfinished_2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: unexpected end of input - --> tests/markup/open_element_unfinished_2.rs:2:5 - | -2 | / pg_console::markup! { -3 | | tests/markup/open_element_unfinished_3.rs:2:5 - | -2 | / pg_console::markup! { -3 | | tests/markup/open_element_unfinished_4.rs:2:5 - | -2 | / pg_console::markup! { -3 | | tests/markup/open_element_unfinished_5.rs:2:5 - | -2 | / pg_console::markup! { -3 | | tests/markup/open_element_unfinished_6.rs:2:5 - | -2 | / pg_console::markup! { -3 | | tests/markup/open_element_unfinished_7.rs:2:5 - | -2 | / pg_console::markup! { -3 | | String { - match &node.node { - Some(pg_query_ext::NodeEnum::String(s)) => s.sval.to_string(), - _ => "".to_string(), - } -} diff --git a/crates/pg_typecheck/Cargo.toml b/crates/pg_typecheck/Cargo.toml deleted file mode 100644 index 1845636d3..000000000 --- a/crates/pg_typecheck/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -authors.workspace = true -categories.workspace = true -description = "" -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -license.workspace = true -name = "pg_typecheck" -repository.workspace = true -version = "0.0.0" - - -[dependencies] -insta = "1.31.0" -pg_console.workspace = true -pg_diagnostics.workspace = true -pg_query_ext.workspace = true -pg_schema_cache.workspace = true -sqlx.workspace = true -text-size.workspace = true -tokio.workspace = true -tree-sitter.workspace = true -tree_sitter_sql.workspace = true - -[dev-dependencies] -pg_test_utils.workspace = true - -[lib] -doctest = false - -[features] diff --git a/crates/pg_analyse/Cargo.toml b/crates/pglt_analyse/Cargo.toml similarity index 76% rename from crates/pg_analyse/Cargo.toml rename to crates/pglt_analyse/Cargo.toml index 464d5c506..e0b8f943d 100644 --- a/crates/pg_analyse/Cargo.toml +++ b/crates/pglt_analyse/Cargo.toml @@ -7,17 +7,17 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_analyse" +name = "pglt_analyse" repository.workspace = true version = "0.0.0" [dependencies] -pg_console.workspace = true -pg_diagnostics.workspace = true -pg_query_ext.workspace = true -pg_schema_cache.workspace = true -rustc-hash = { workspace = true } +pglt_console.workspace = true +pglt_diagnostics.workspace = true +pglt_query_ext.workspace = true +pglt_schema_cache.workspace = true +rustc-hash = { workspace = true } biome_deserialize = { workspace = true, optional = true } biome_deserialize_macros = { workspace = true, optional = true } diff --git a/crates/pg_analyse/src/categories.rs b/crates/pglt_analyse/src/categories.rs similarity index 98% rename from crates/pg_analyse/src/categories.rs rename to crates/pglt_analyse/src/categories.rs index 11117e25a..184205a7b 100644 --- a/crates/pg_analyse/src/categories.rs +++ b/crates/pglt_analyse/src/categories.rs @@ -55,7 +55,7 @@ impl ActionCategory { /// /// ``` /// use std::borrow::Cow; - /// use pg_analyse::{ActionCategory, RefactorKind}; + /// use pglt_analyse::{ActionCategory, RefactorKind}; /// /// assert!(ActionCategory::QuickFix(Cow::from("quickfix")).matches("quickfix")); /// @@ -301,7 +301,7 @@ impl schemars::JsonSchema for RuleCategories { /// A convenient type create a [RuleCategories] type /// /// ``` -/// use pg_analyse::{RuleCategoriesBuilder, RuleCategory}; +/// use pglt_analyse::{RuleCategoriesBuilder, RuleCategory}; /// let mut categories = RuleCategoriesBuilder::default().with_lint().build(); /// /// assert!(categories.contains(RuleCategory::Lint)); diff --git a/crates/pg_analyse/src/context.rs b/crates/pglt_analyse/src/context.rs similarity index 91% rename from crates/pg_analyse/src/context.rs rename to crates/pglt_analyse/src/context.rs index 4e43b1dfd..f6038bc7e 100644 --- a/crates/pg_analyse/src/context.rs +++ b/crates/pglt_analyse/src/context.rs @@ -4,7 +4,7 @@ use crate::{ }; pub struct RuleContext<'a, R: Rule> { - stmt: &'a pg_query_ext::NodeEnum, + stmt: &'a pglt_query_ext::NodeEnum, options: &'a R::Options, } @@ -13,7 +13,7 @@ where R: Rule + Sized + 'static, { #[allow(clippy::too_many_arguments)] - pub fn new(stmt: &'a pg_query_ext::NodeEnum, options: &'a R::Options) -> Self { + pub fn new(stmt: &'a pglt_query_ext::NodeEnum, options: &'a R::Options) -> Self { Self { stmt, options } } @@ -28,7 +28,7 @@ where } /// Returns the AST root - pub fn stmt(&self) -> &pg_query_ext::NodeEnum { + pub fn stmt(&self) -> &pglt_query_ext::NodeEnum { self.stmt } diff --git a/crates/pg_analyse/src/filter.rs b/crates/pglt_analyse/src/filter.rs similarity index 97% rename from crates/pg_analyse/src/filter.rs rename to crates/pglt_analyse/src/filter.rs index 045f5f517..0b63c845e 100644 --- a/crates/pg_analyse/src/filter.rs +++ b/crates/pglt_analyse/src/filter.rs @@ -113,8 +113,8 @@ impl Display for RuleFilter<'_> { } } -impl pg_console::fmt::Display for RuleFilter<'_> { - fn fmt(&self, fmt: &mut pg_console::fmt::Formatter) -> std::io::Result<()> { +impl pglt_console::fmt::Display for RuleFilter<'_> { + fn fmt(&self, fmt: &mut pglt_console::fmt::Formatter) -> std::io::Result<()> { match self { RuleFilter::Group(group) => { write!(fmt, "{group}") diff --git a/crates/pg_analyse/src/lib.rs b/crates/pglt_analyse/src/lib.rs similarity index 94% rename from crates/pg_analyse/src/lib.rs rename to crates/pglt_analyse/src/lib.rs index ccaf82b7d..95098e1dd 100644 --- a/crates/pg_analyse/src/lib.rs +++ b/crates/pglt_analyse/src/lib.rs @@ -7,7 +7,7 @@ mod registry; mod rule; // Re-exported for use in the `declare_group` macro -pub use pg_diagnostics::category_concat; +pub use pglt_diagnostics::category_concat; pub use crate::categories::{ ActionCategory, RefactorKind, RuleCategories, RuleCategoriesBuilder, RuleCategory, diff --git a/crates/pg_analyse/src/macros.rs b/crates/pglt_analyse/src/macros.rs similarity index 98% rename from crates/pg_analyse/src/macros.rs rename to crates/pglt_analyse/src/macros.rs index d97639a9f..ea847a2a1 100644 --- a/crates/pg_analyse/src/macros.rs +++ b/crates/pglt_analyse/src/macros.rs @@ -5,7 +5,7 @@ /// The macro itself expect the following syntax: /// /// ```rust,ignore -///use pg_analyse::declare_rule; +///use pglt_analyse::declare_rule; /// /// declare_lint_rule! { /// /// Documentation @@ -27,7 +27,7 @@ macro_rules! declare_lint_rule { $( $key:ident: $value:expr, )* } ) => { - pg_analyse::declare_rule!( + pglt_analyse::declare_rule!( $( #[doc = $doc] )* $vis $id { version: $version, diff --git a/crates/pg_analyse/src/options.rs b/crates/pglt_analyse/src/options.rs similarity index 100% rename from crates/pg_analyse/src/options.rs rename to crates/pglt_analyse/src/options.rs diff --git a/crates/pg_analyse/src/registry.rs b/crates/pglt_analyse/src/registry.rs similarity index 99% rename from crates/pg_analyse/src/registry.rs rename to crates/pglt_analyse/src/registry.rs index b80de1cb4..7a23b6edb 100644 --- a/crates/pg_analyse/src/registry.rs +++ b/crates/pglt_analyse/src/registry.rs @@ -156,7 +156,7 @@ impl RuleRegistry { } pub struct RegistryRuleParams<'a> { - pub root: &'a pg_query_ext::NodeEnum, + pub root: &'a pglt_query_ext::NodeEnum, pub options: &'a AnalyserOptions, } diff --git a/crates/pg_analyse/src/rule.rs b/crates/pglt_analyse/src/rule.rs similarity index 98% rename from crates/pg_analyse/src/rule.rs rename to crates/pglt_analyse/src/rule.rs index f159861db..ce91affef 100644 --- a/crates/pg_analyse/src/rule.rs +++ b/crates/pglt_analyse/src/rule.rs @@ -1,7 +1,7 @@ -use pg_console::fmt::Display; -use pg_console::{markup, MarkupBuf}; -use pg_diagnostics::advice::CodeSuggestionAdvice; -use pg_diagnostics::{ +use pglt_console::fmt::Display; +use pglt_console::{markup, MarkupBuf}; +use pglt_diagnostics::advice::CodeSuggestionAdvice; +use pglt_diagnostics::{ Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory, MessageAndDescription, Visit, }; diff --git a/crates/pg_analyser/CONTRIBUTING.md b/crates/pglt_analyser/CONTRIBUTING.md similarity index 96% rename from crates/pg_analyser/CONTRIBUTING.md rename to crates/pglt_analyser/CONTRIBUTING.md index 05975adf1..501a49de9 100644 --- a/crates/pg_analyser/CONTRIBUTING.md +++ b/crates/pglt_analyser/CONTRIBUTING.md @@ -57,8 +57,8 @@ Let's say we want to create a new **lint** rule called `useMyRuleName`, follow t just new-lintrule safety useMyRuleName ``` - The script will generate a bunch of files inside the `pg_analyser` crate. - Among the other files, you'll find a file called `use_my_new_rule_name.rs` inside the `pg_analyser/lib/src/lint/safety` folder. You'll implement your rule in this file. + The script will generate a bunch of files inside the `pglt_analyser` crate. + Among the other files, you'll find a file called `use_my_new_rule_name.rs` inside the `pglt_analyser/lib/src/lint/safety` folder. You'll implement your rule in this file. 1. The `Options` type doesn't have to be used, so it can be considered optional. However, it has to be defined as `type Options = ()`. 1. Implement the `run` function: The function is called for every statement, and should return zero or more diagnostics. Follow the [pillars](#explain-a-rule-to-the-user) when writing the message of a diagnostic @@ -171,7 +171,7 @@ This macro is used to declare an analyzer rule type, and implement the [RuleMeta The macro itself expects the following syntax: ```rust -use pg_analyse::declare_lint_rule; +use pglt_analyse::declare_lint_rule; declare_lint_rule! { /// Documentation @@ -190,7 +190,7 @@ If a **lint** rule is inspired by an existing rule from other ecosystems (Squawk If you're implementing a lint rule that matches the behaviour of the Squawk rule `ban-drop-column`, you'll use the variant `::Squawk` and pass the name of the rule: ```rust -use pg_analyse::{declare_lint_rule, RuleSource}; +use pglt_analyse::{declare_lint_rule, RuleSource}; declare_lint_rule! { /// Documentation @@ -211,7 +211,7 @@ refer to the corresponding diagnostic category for this lint rule, if it has one. Using this macro instead of getting the category for a diagnostic by dynamically parsing its string name has the advantage of statically injecting the category at compile time and checking that it is correctly -registered to the `pg_diagnostics` library. +registered to the `pglt_diagnostics` library. ```rust declare_lint_rule! { @@ -296,7 +296,7 @@ Stage and commit your changes: ```shell > git add -A -> git commit -m 'feat(pg_analyser): myRuleName' +> git commit -m 'feat(pglt_analyser): myRuleName' ``` ### Deprecate a rule @@ -307,7 +307,7 @@ of deprecation can be multiple. In order to do, the macro allows adding additional field to add the reason for deprecation ````rust -use pg_analyse::declare_lint_rule; +use pglt_analyse::declare_lint_rule; declare_lint_rule! { /// Dropping a column may break existing clients. diff --git a/crates/pg_analyser/Cargo.toml b/crates/pglt_analyser/Cargo.toml similarity index 60% rename from crates/pg_analyser/Cargo.toml rename to crates/pglt_analyser/Cargo.toml index 6e3ce4c5e..f235bcc3a 100644 --- a/crates/pg_analyser/Cargo.toml +++ b/crates/pglt_analyser/Cargo.toml @@ -7,12 +7,12 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_analyser" +name = "pglt_analyser" repository.workspace = true version = "0.0.0" [dependencies] -pg_analyse = { workspace = true } -pg_console = { workspace = true } -pg_query_ext = { workspace = true } -serde = { workspace = true } +pglt_analyse = { workspace = true } +pglt_console = { workspace = true } +pglt_query_ext = { workspace = true } +serde = { workspace = true } diff --git a/crates/pg_analyser/src/lib.rs b/crates/pglt_analyser/src/lib.rs similarity index 96% rename from crates/pg_analyser/src/lib.rs rename to crates/pglt_analyser/src/lib.rs index d6c14d620..3eb360568 100644 --- a/crates/pg_analyser/src/lib.rs +++ b/crates/pglt_analyser/src/lib.rs @@ -1,6 +1,6 @@ use std::{ops::Deref, sync::LazyLock}; -use pg_analyse::{ +use pglt_analyse::{ AnalyserOptions, AnalysisFilter, MetadataRegistry, RegistryRuleParams, RuleDiagnostic, RuleRegistry, }; @@ -31,7 +31,7 @@ pub struct Analyser<'a> { } pub struct AnalyserContext<'a> { - pub root: &'a pg_query_ext::NodeEnum, + pub root: &'a pglt_query_ext::NodeEnum, } pub struct AnalyserConfig<'a> { diff --git a/crates/pglt_analyser/src/lint.rs b/crates/pglt_analyser/src/lint.rs new file mode 100644 index 000000000..0e9330379 --- /dev/null +++ b/crates/pglt_analyser/src/lint.rs @@ -0,0 +1,4 @@ +//! Generated file, do not edit by hand, see `xtask/codegen` + +pub mod safety; +::pglt_analyse::declare_category! { pub Lint { kind : Lint , groups : [self :: safety :: Safety ,] } } diff --git a/crates/pg_analyser/src/lint/safety.rs b/crates/pglt_analyser/src/lint/safety.rs similarity index 87% rename from crates/pg_analyser/src/lint/safety.rs rename to crates/pglt_analyser/src/lint/safety.rs index cb767ad2d..6beb4803d 100644 --- a/crates/pg_analyser/src/lint/safety.rs +++ b/crates/pglt_analyser/src/lint/safety.rs @@ -1,6 +1,6 @@ //! Generated file, do not edit by hand, see `xtask/codegen` -use pg_analyse::declare_lint_group; +use pglt_analyse::declare_lint_group; pub mod ban_drop_column; pub mod ban_drop_not_null; declare_lint_group! { pub Safety { name : "safety" , rules : [self :: ban_drop_column :: BanDropColumn , self :: ban_drop_not_null :: BanDropNotNull ,] } } diff --git a/crates/pg_analyser/src/lint/safety/ban_drop_column.rs b/crates/pglt_analyser/src/lint/safety/ban_drop_column.rs similarity index 77% rename from crates/pg_analyser/src/lint/safety/ban_drop_column.rs rename to crates/pglt_analyser/src/lint/safety/ban_drop_column.rs index d18ac19f1..4478bad91 100644 --- a/crates/pg_analyser/src/lint/safety/ban_drop_column.rs +++ b/crates/pglt_analyser/src/lint/safety/ban_drop_column.rs @@ -1,5 +1,5 @@ -use pg_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource}; -use pg_console::markup; +use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource}; +use pglt_console::markup; declare_lint_rule! { /// Dropping a column may break existing clients. @@ -30,10 +30,10 @@ impl Rule for BanDropColumn { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pg_query_ext::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pglt_query_ext::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pg_query_ext::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pg_query_ext::protobuf::AlterTableType::AtDropColumn { + if let Some(pglt_query_ext::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pglt_query_ext::protobuf::AlterTableType::AtDropColumn { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pg_analyser/src/lint/safety/ban_drop_not_null.rs b/crates/pglt_analyser/src/lint/safety/ban_drop_not_null.rs similarity index 81% rename from crates/pg_analyser/src/lint/safety/ban_drop_not_null.rs rename to crates/pglt_analyser/src/lint/safety/ban_drop_not_null.rs index 92c1a3728..80cc04b60 100644 --- a/crates/pg_analyser/src/lint/safety/ban_drop_not_null.rs +++ b/crates/pglt_analyser/src/lint/safety/ban_drop_not_null.rs @@ -1,5 +1,5 @@ -use pg_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource}; -use pg_console::markup; +use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource}; +use pglt_console::markup; declare_lint_rule! { /// Dropping a NOT NULL constraint may break existing clients. @@ -30,10 +30,10 @@ impl Rule for BanDropNotNull { fn run(ctx: &RuleContext) -> Vec { let mut diagnostics = Vec::new(); - if let pg_query_ext::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { + if let pglt_query_ext::NodeEnum::AlterTableStmt(stmt) = &ctx.stmt() { for cmd in &stmt.cmds { - if let Some(pg_query_ext::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { - if cmd.subtype() == pg_query_ext::protobuf::AlterTableType::AtDropNotNull { + if let Some(pglt_query_ext::NodeEnum::AlterTableCmd(cmd)) = &cmd.node { + if cmd.subtype() == pglt_query_ext::protobuf::AlterTableType::AtDropNotNull { diagnostics.push(RuleDiagnostic::new( rule_category!(), None, diff --git a/crates/pglt_analyser/src/options.rs b/crates/pglt_analyser/src/options.rs new file mode 100644 index 000000000..6f0ab007b --- /dev/null +++ b/crates/pglt_analyser/src/options.rs @@ -0,0 +1,7 @@ +//! Generated file, do not edit by hand, see `xtask/codegen` + +use crate::lint; +pub type BanDropColumn = + ::Options; +pub type BanDropNotNull = + ::Options; diff --git a/crates/pg_analyser/src/registry.rs b/crates/pglt_analyser/src/registry.rs similarity index 83% rename from crates/pg_analyser/src/registry.rs rename to crates/pglt_analyser/src/registry.rs index 27a5a4135..6d06eda6f 100644 --- a/crates/pg_analyser/src/registry.rs +++ b/crates/pglt_analyser/src/registry.rs @@ -1,6 +1,6 @@ //! Generated file, do not edit by hand, see `xtask/codegen` -use pg_analyse::RegistryVisitor; +use pglt_analyse::RegistryVisitor; pub fn visit_registry(registry: &mut V) { registry.record_category::(); } diff --git a/crates/pg_base_db/Cargo.toml b/crates/pglt_base_db/Cargo.toml similarity index 77% rename from crates/pg_base_db/Cargo.toml rename to crates/pglt_base_db/Cargo.toml index 1afa91c44..e3a1651c2 100644 --- a/crates/pg_base_db/Cargo.toml +++ b/crates/pglt_base_db/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_base_db" +name = "pglt_base_db" repository.workspace = true version = "0.0.0" @@ -15,8 +15,8 @@ version = "0.0.0" line_index.workspace = true text-size.workspace = true -pg_fs.workspace = true -pg_statement_splitter.workspace = true +pglt_fs.workspace = true +pglt_statement_splitter.workspace = true [dev-dependencies] diff --git a/crates/pg_base_db/src/change.rs b/crates/pglt_base_db/src/change.rs similarity index 98% rename from crates/pg_base_db/src/change.rs rename to crates/pglt_base_db/src/change.rs index e8fed443f..770af5e5d 100644 --- a/crates/pg_base_db/src/change.rs +++ b/crates/pglt_base_db/src/change.rs @@ -125,7 +125,7 @@ impl Change { .map(StatementChange::Deleted), ); // TODO also use errors returned by extract sql statement ranges - doc.statement_ranges = pg_statement_splitter::split(&self.text).ranges.to_vec(); + doc.statement_ranges = pglt_statement_splitter::split(&self.text).ranges.to_vec(); doc.text = self.text.clone(); doc.line_index = LineIndex::new(&doc.text); @@ -238,7 +238,7 @@ impl Change { + 1, ); - for range in pg_statement_splitter::split(extracted_text).ranges { + for range in pglt_statement_splitter::split(extracted_text).ranges { match doc .statement_ranges .binary_search_by(|r| r.start().cmp(&range.start())) @@ -292,7 +292,7 @@ mod tests { use text_size::{TextRange, TextSize}; use crate::{change::Change, document::StatementRef, Document, DocumentChange}; - use pg_fs::PgLspPath; + use pglt_fs::PgLspPath; #[test] fn test_document_apply_changes() { @@ -334,7 +334,7 @@ mod tests { assert_eq!("select id,test from users\nselect 1;", d.text); assert_eq!(d.statement_ranges.len(), 2); - for r in &pg_statement_splitter::split(&d.text).ranges { + for r in &pglt_statement_splitter::split(&d.text).ranges { assert!( d.statement_ranges.iter().any(|x| r == x), "should have stmt with range {:#?}", diff --git a/crates/pg_base_db/src/document.rs b/crates/pglt_base_db/src/document.rs similarity index 98% rename from crates/pg_base_db/src/document.rs rename to crates/pglt_base_db/src/document.rs index 7e40461fc..4446b6f37 100644 --- a/crates/pg_base_db/src/document.rs +++ b/crates/pglt_base_db/src/document.rs @@ -3,7 +3,7 @@ use std::{hash::Hash, hash::Hasher, ops::RangeBounds}; use line_index::LineIndex; use text_size::{TextRange, TextSize}; -use pg_fs::PgLspPath; +use pglt_fs::PgLspPath; extern crate test; @@ -47,7 +47,7 @@ impl Document { line_index: LineIndex::new(text.as_ref().unwrap_or(&"".to_string())), // TODO: use errors returned by split statement_ranges: text.as_ref().map_or_else(Vec::new, |f| { - pg_statement_splitter::split(f).ranges.to_vec() + pglt_statement_splitter::split(f).ranges.to_vec() }), text: text.unwrap_or("".to_string()), url, @@ -162,7 +162,7 @@ impl Document { #[cfg(test)] mod tests { - use pg_fs::PgLspPath; + use pglt_fs::PgLspPath; use text_size::{TextRange, TextSize}; use crate::Document; diff --git a/crates/pg_base_db/src/lib.rs b/crates/pglt_base_db/src/lib.rs similarity index 91% rename from crates/pg_base_db/src/lib.rs rename to crates/pglt_base_db/src/lib.rs index 51b22ed0f..16b7ab98a 100644 --- a/crates/pg_base_db/src/lib.rs +++ b/crates/pglt_base_db/src/lib.rs @@ -1,4 +1,4 @@ -//! # pg_base_db +//! # pglt_base_db //! //! This crate implements the basic data structures and implements efficient change management. The idea is to make sure we only recompute what is necessary when a change occurs, and this is done by cutting a sql source into statements, and then applying the changes to individual statements. This way, we can avoid re-parsing the entire sql source when a change occurs. //! @@ -9,7 +9,7 @@ //! - `StatementChange` and `ChangedStatement` are results of applying the change and represent references to the changed statements, including information about the changes that were applied. This is used to invalidate caches and recompute information about the changed statements in higher-level crates. //! //! I am not yet 100% happy with this, because when we create a `StatementRef`, the text is cloned from `Document` and included in the Hash. This must be improved by leaving the text in the `Document`, and making the `StatementRef` and actual reference to the text in the `Document`. This will make the `StatementRef` smaller and faster to compare. -//! Additionally, the errors returned by the `pg_statement_splitter::split` are not exposed yet. This must be done to show syntax errors to the user. +//! Additionally, the errors returned by the `pglt_statement_splitter::split` are not exposed yet. This must be done to show syntax errors to the user. #![feature(extract_if, test)] diff --git a/crates/pg_cli/Cargo.toml b/crates/pglt_cli/Cargo.toml similarity index 78% rename from crates/pg_cli/Cargo.toml rename to crates/pglt_cli/Cargo.toml index d04f88c5d..ccebecb6b 100644 --- a/crates/pg_cli/Cargo.toml +++ b/crates/pglt_cli/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_cli" +name = "pglt_cli" repository.workspace = true version = "0.0.0" @@ -20,15 +20,15 @@ crossbeam = { workspace = true } dashmap = "5.5.3" hdrhistogram = { version = "7.5.4", default-features = false } path-absolutize = { version = "3.1.1", optional = false, features = ["use_unix_paths_on_wasm"] } -pg_analyse = { workspace = true } -pg_configuration = { workspace = true } -pg_console = { workspace = true } -pg_diagnostics = { workspace = true } -pg_flags = { workspace = true } -pg_fs = { workspace = true } -pg_lsp = { workspace = true } -pg_text_edit = { workspace = true } -pg_workspace = { workspace = true } +pglt_analyse = { workspace = true } +pglt_configuration = { workspace = true } +pglt_console = { workspace = true } +pglt_diagnostics = { workspace = true } +pglt_flags = { workspace = true } +pglt_fs = { workspace = true } +pglt_lsp = { workspace = true } +pglt_text_edit = { workspace = true } +pglt_workspace = { workspace = true } quick-junit = "0.5.0" rayon = { workspace = true } rustc-hash = { workspace = true } diff --git a/crates/pg_cli/src/changed.rs b/crates/pglt_cli/src/changed.rs similarity index 92% rename from crates/pg_cli/src/changed.rs rename to crates/pglt_cli/src/changed.rs index 300e99b2c..ac1b1ecef 100644 --- a/crates/pg_cli/src/changed.rs +++ b/crates/pglt_cli/src/changed.rs @@ -1,7 +1,7 @@ use crate::CliDiagnostic; -use pg_configuration::PartialConfiguration; -use pg_fs::FileSystem; -use pg_workspace::DynRef; +use pglt_configuration::PartialConfiguration; +use pglt_fs::FileSystem; +use pglt_workspace::DynRef; use std::ffi::OsString; pub(crate) fn get_changed_files( diff --git a/crates/pg_cli/src/cli_options.rs b/crates/pglt_cli/src/cli_options.rs similarity index 98% rename from crates/pg_cli/src/cli_options.rs rename to crates/pglt_cli/src/cli_options.rs index 20e18c8c8..05e75b6a5 100644 --- a/crates/pg_cli/src/cli_options.rs +++ b/crates/pglt_cli/src/cli_options.rs @@ -1,8 +1,8 @@ use crate::logging::LoggingKind; use crate::LoggingLevel; use bpaf::Bpaf; -use pg_configuration::ConfigurationPathHint; -use pg_diagnostics::Severity; +use pglt_configuration::ConfigurationPathHint; +use pglt_diagnostics::Severity; use std::fmt::{Display, Formatter}; use std::path::PathBuf; use std::str::FromStr; diff --git a/crates/pg_cli/src/commands/check.rs b/crates/pglt_cli/src/commands/check.rs similarity index 91% rename from crates/pg_cli/src/commands/check.rs rename to crates/pglt_cli/src/commands/check.rs index ea6084af9..2018012dc 100644 --- a/crates/pg_cli/src/commands/check.rs +++ b/crates/pglt_cli/src/commands/check.rs @@ -1,10 +1,10 @@ use crate::cli_options::CliOptions; use crate::{CliDiagnostic, Execution, TraversalMode}; use biome_deserialize::Merge; -use pg_configuration::PartialConfiguration; -use pg_console::Console; -use pg_fs::FileSystem; -use pg_workspace::{configuration::LoadedConfiguration, DynRef, Workspace, WorkspaceError}; +use pglt_configuration::PartialConfiguration; +use pglt_console::Console; +use pglt_fs::FileSystem; +use pglt_workspace::{configuration::LoadedConfiguration, DynRef, Workspace, WorkspaceError}; use std::ffi::OsString; use super::{get_files_to_process_with_cli_options, CommandRunner}; diff --git a/crates/pg_cli/src/commands/clean.rs b/crates/pglt_cli/src/commands/clean.rs similarity index 94% rename from crates/pg_cli/src/commands/clean.rs rename to crates/pglt_cli/src/commands/clean.rs index dc2f5daba..1bf2c3070 100644 --- a/crates/pg_cli/src/commands/clean.rs +++ b/crates/pglt_cli/src/commands/clean.rs @@ -1,6 +1,6 @@ use crate::commands::daemon::default_pglsp_log_path; use crate::{CliDiagnostic, CliSession}; -use pg_flags::pglsp_env; +use pglt_flags::pglsp_env; use std::fs::{create_dir, remove_dir_all}; use std::path::PathBuf; diff --git a/crates/pg_cli/src/commands/daemon.rs b/crates/pglt_cli/src/commands/daemon.rs similarity index 96% rename from crates/pg_cli/src/commands/daemon.rs rename to crates/pglt_cli/src/commands/daemon.rs index 4ecf6d721..046afd769 100644 --- a/crates/pg_cli/src/commands/daemon.rs +++ b/crates/pglt_cli/src/commands/daemon.rs @@ -3,9 +3,9 @@ use crate::{ service::{self, ensure_daemon, open_socket, run_daemon}, CliDiagnostic, CliSession, }; -use pg_console::{markup, ConsoleExt}; -use pg_lsp::ServerFactory; -use pg_workspace::{workspace::WorkspaceClient, TransportError, WorkspaceError}; +use pglt_console::{markup, ConsoleExt}; +use pglt_lsp::ServerFactory; +use pglt_workspace::{workspace::WorkspaceClient, TransportError, WorkspaceError}; use std::{env, fs, path::PathBuf}; use tokio::io; use tokio::runtime::Runtime; @@ -206,7 +206,7 @@ pub(crate) fn read_most_recent_log_file( /// `pglsp-logs/server.log.yyyy-MM-dd-HH` files inside the system temporary /// directory) fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Option) { - let pglsp_log_path = log_path.unwrap_or(pg_fs::ensure_cache_dir().join("pglsp-logs")); + let pglsp_log_path = log_path.unwrap_or(pglt_fs::ensure_cache_dir().join("pglsp-logs")); let appender_builder = tracing_appender::rolling::RollingFileAppender::builder(); let file_appender = appender_builder .filename_prefix(log_file_name_prefix.unwrap_or(String::from("server.log"))) @@ -232,7 +232,7 @@ fn setup_tracing_subscriber(log_path: Option, log_file_name_prefix: Opt pub fn default_pglsp_log_path() -> PathBuf { match env::var_os("PGLSP_LOG_PATH") { Some(directory) => PathBuf::from(directory), - None => pg_fs::ensure_cache_dir().join("pglsp-logs"), + None => pglt_fs::ensure_cache_dir().join("pglsp-logs"), } } diff --git a/crates/pg_cli/src/commands/init.rs b/crates/pglt_cli/src/commands/init.rs similarity index 76% rename from crates/pg_cli/src/commands/init.rs rename to crates/pglt_cli/src/commands/init.rs index 32e9e0c59..fceaa0683 100644 --- a/crates/pg_cli/src/commands/init.rs +++ b/crates/pglt_cli/src/commands/init.rs @@ -1,8 +1,8 @@ use crate::{CliDiagnostic, CliSession}; -use pg_configuration::PartialConfiguration; -use pg_console::{markup, ConsoleExt}; -use pg_fs::ConfigName; -use pg_workspace::configuration::create_config; +use pglt_configuration::PartialConfiguration; +use pglt_console::{markup, ConsoleExt}; +use pglt_fs::ConfigName; +use pglt_workspace::configuration::create_config; pub(crate) fn init(mut session: CliSession) -> Result<(), CliDiagnostic> { let fs = &mut session.app.fs; diff --git a/crates/pg_cli/src/commands/mod.rs b/crates/pglt_cli/src/commands/mod.rs similarity index 92% rename from crates/pg_cli/src/commands/mod.rs rename to crates/pglt_cli/src/commands/mod.rs index 6fe3472dc..c9f5c67fd 100644 --- a/crates/pg_cli/src/commands/mod.rs +++ b/crates/pglt_cli/src/commands/mod.rs @@ -6,13 +6,13 @@ use crate::{ execute_mode, setup_cli_subscriber, CliDiagnostic, CliSession, Execution, LoggingLevel, VERSION, }; use bpaf::Bpaf; -use pg_configuration::{partial_configuration, PartialConfiguration}; -use pg_console::Console; -use pg_fs::FileSystem; -use pg_workspace::configuration::{load_configuration, LoadedConfiguration}; -use pg_workspace::settings::PartialConfigurationExt; -use pg_workspace::workspace::UpdateSettingsParams; -use pg_workspace::{DynRef, Workspace, WorkspaceError}; +use pglt_configuration::{partial_configuration, PartialConfiguration}; +use pglt_console::Console; +use pglt_fs::FileSystem; +use pglt_workspace::configuration::{load_configuration, LoadedConfiguration}; +use pglt_workspace::settings::PartialConfigurationExt; +use pglt_workspace::workspace::UpdateSettingsParams; +use pglt_workspace::{DynRef, Workspace, WorkspaceError}; use std::ffi::OsString; use std::path::PathBuf; @@ -25,7 +25,7 @@ pub(crate) mod version; #[derive(Debug, Clone, Bpaf)] #[bpaf(options, version(VERSION))] /// PgLsp official CLI. Use it to check the health of your project or run it to check single files. -pub enum PgLspCommand { +pub enum PgltCommand { /// Shows the version information and quit. #[bpaf(command)] Version(#[bpaf(external(cli_options), hide_usage)] CliOptions), @@ -43,7 +43,7 @@ pub enum PgLspCommand { /// /// The file doesn't need to exist on disk, what matters is the extension of the file. Based on the extension, we know how to check the code. /// - /// Example: `echo 'let a;' | pg_cli check --stdin-file-path=test.sql` + /// Example: `echo 'let a;' | pglt_cli check --stdin-file-path=test.sql` #[bpaf(long("stdin-file-path"), argument("PATH"), hide_usage)] stdin_file_path: Option, @@ -87,7 +87,7 @@ pub enum PgLspCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pg_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, @@ -123,7 +123,7 @@ pub enum PgLspCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pg_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), )] log_path: PathBuf, /// Allows to set a custom file path to the configuration file, @@ -157,7 +157,7 @@ pub enum PgLspCommand { long("log-path"), argument("PATH"), hide_usage, - fallback(pg_fs::ensure_cache_dir().join("pglsp-logs")), + fallback(pglt_fs::ensure_cache_dir().join("pglsp-logs")), )] log_path: PathBuf, @@ -172,19 +172,19 @@ pub enum PgLspCommand { PrintSocket, } -impl PgLspCommand { +impl PgltCommand { const fn cli_options(&self) -> Option<&CliOptions> { match self { - PgLspCommand::Version(cli_options) | PgLspCommand::Check { cli_options, .. } => { + PgltCommand::Version(cli_options) | PgltCommand::Check { cli_options, .. } => { Some(cli_options) } - PgLspCommand::LspProxy { .. } - | PgLspCommand::Start { .. } - | PgLspCommand::Stop - | PgLspCommand::Init - | PgLspCommand::RunServer { .. } - | PgLspCommand::Clean { .. } - | PgLspCommand::PrintSocket => None, + PgltCommand::LspProxy { .. } + | PgltCommand::Start { .. } + | PgltCommand::Stop + | PgltCommand::Init + | PgltCommand::RunServer { .. } + | PgltCommand::Clean { .. } + | PgltCommand::PrintSocket => None, } } @@ -399,6 +399,6 @@ mod tests { /// Tests that all CLI options adhere to the invariants expected by `bpaf`. #[test] fn check_options() { - pg_lsp_command().check_invariants(false); + pglt_command().check_invariants(false); } } diff --git a/crates/pg_cli/src/commands/version.rs b/crates/pglt_cli/src/commands/version.rs similarity index 89% rename from crates/pg_cli/src/commands/version.rs rename to crates/pglt_cli/src/commands/version.rs index 434fa7161..6cdb60d27 100644 --- a/crates/pg_cli/src/commands/version.rs +++ b/crates/pglt_cli/src/commands/version.rs @@ -1,6 +1,6 @@ -use pg_console::fmt::Formatter; -use pg_console::{fmt, markup, ConsoleExt}; -use pg_workspace::workspace::ServerInfo; +use pglt_console::fmt::Formatter; +use pglt_console::{fmt, markup, ConsoleExt}; +use pglt_workspace::workspace::ServerInfo; use crate::{CliDiagnostic, CliSession, VERSION}; diff --git a/crates/pg_cli/src/diagnostics.rs b/crates/pglt_cli/src/diagnostics.rs similarity index 98% rename from crates/pg_cli/src/diagnostics.rs rename to crates/pglt_cli/src/diagnostics.rs index f1f6cdd4b..f13e0e81c 100644 --- a/crates/pg_cli/src/diagnostics.rs +++ b/crates/pglt_cli/src/diagnostics.rs @@ -1,10 +1,10 @@ -use pg_console::fmt::Display; -use pg_console::markup; -use pg_diagnostics::adapters::{BpafError, IoError, SerdeJsonError}; -use pg_diagnostics::{ +use pglt_console::fmt::Display; +use pglt_console::markup; +use pglt_diagnostics::adapters::{BpafError, IoError, SerdeJsonError}; +use pglt_diagnostics::{ Advices, Category, Diagnostic, Error, LogCategory, MessageAndDescription, Severity, Visit, }; -use pg_workspace::WorkspaceError; +use pglt_workspace::WorkspaceError; use std::process::{ExitCode, Termination}; use std::{env::current_exe, fmt::Debug}; diff --git a/crates/pg_cli/src/execute/diagnostics.rs b/crates/pglt_cli/src/execute/diagnostics.rs similarity index 93% rename from crates/pg_cli/src/execute/diagnostics.rs rename to crates/pglt_cli/src/execute/diagnostics.rs index 232709159..c9be55182 100644 --- a/crates/pg_cli/src/execute/diagnostics.rs +++ b/crates/pglt_cli/src/execute/diagnostics.rs @@ -1,5 +1,5 @@ -use pg_diagnostics::adapters::{IoError, StdError}; -use pg_diagnostics::{Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error}; +use pglt_diagnostics::adapters::{IoError, StdError}; +use pglt_diagnostics::{Category, Diagnostic, DiagnosticExt, DiagnosticTags, Error}; use std::io; #[derive(Debug, Diagnostic)] diff --git a/crates/pg_cli/src/execute/mod.rs b/crates/pglt_cli/src/execute/mod.rs similarity index 99% rename from crates/pg_cli/src/execute/mod.rs rename to crates/pglt_cli/src/execute/mod.rs index c18f8ec21..266686820 100644 --- a/crates/pg_cli/src/execute/mod.rs +++ b/crates/pglt_cli/src/execute/mod.rs @@ -10,8 +10,8 @@ use crate::reporter::gitlab::{GitLabReporter, GitLabReporterVisitor}; use crate::reporter::junit::{JunitReporter, JunitReporterVisitor}; use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor}; use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter}; -use pg_diagnostics::{category, Category}; -use pg_fs::PgLspPath; +use pglt_diagnostics::{category, Category}; +use pglt_fs::PgLspPath; use std::borrow::Borrow; use std::ffi::OsString; use std::fmt::{Display, Formatter}; diff --git a/crates/pg_cli/src/execute/process_file.rs b/crates/pglt_cli/src/execute/process_file.rs similarity index 98% rename from crates/pg_cli/src/execute/process_file.rs rename to crates/pglt_cli/src/execute/process_file.rs index 6135c012e..35044fb94 100644 --- a/crates/pg_cli/src/execute/process_file.rs +++ b/crates/pglt_cli/src/execute/process_file.rs @@ -4,8 +4,8 @@ pub(crate) mod workspace_file; use crate::execute::traverse::TraversalOptions; use crate::execute::TraversalMode; use check::check_file; -use pg_diagnostics::Error; -use pg_fs::PgLspPath; +use pglt_diagnostics::Error; +use pglt_fs::PgLspPath; use std::marker::PhantomData; use std::ops::Deref; diff --git a/crates/pg_cli/src/execute/process_file/check.rs b/crates/pglt_cli/src/execute/process_file/check.rs similarity index 96% rename from crates/pg_cli/src/execute/process_file/check.rs rename to crates/pglt_cli/src/execute/process_file/check.rs index 866fa7401..cf51b5327 100644 --- a/crates/pg_cli/src/execute/process_file/check.rs +++ b/crates/pglt_cli/src/execute/process_file/check.rs @@ -1,5 +1,5 @@ -use pg_analyse::RuleCategoriesBuilder; -use pg_diagnostics::{category, Error}; +use pglt_analyse::RuleCategoriesBuilder; +use pglt_diagnostics::{category, Error}; use crate::execute::diagnostics::ResultExt; use crate::execute::process_file::workspace_file::WorkspaceFile; diff --git a/crates/pg_cli/src/execute/process_file/workspace_file.rs b/crates/pglt_cli/src/execute/process_file/workspace_file.rs similarity index 92% rename from crates/pg_cli/src/execute/process_file/workspace_file.rs rename to crates/pglt_cli/src/execute/process_file/workspace_file.rs index 6f3cedc79..07e1f6e77 100644 --- a/crates/pg_cli/src/execute/process_file/workspace_file.rs +++ b/crates/pglt_cli/src/execute/process_file/workspace_file.rs @@ -1,9 +1,9 @@ use crate::execute::diagnostics::{ResultExt, ResultIoExt}; use crate::execute::process_file::SharedTraversalOptions; -use pg_diagnostics::{category, Error}; -use pg_fs::{File, OpenOptions, PgLspPath}; -use pg_workspace::workspace::{ChangeParams, FileGuard, OpenFileParams}; -use pg_workspace::{Workspace, WorkspaceError}; +use pglt_diagnostics::{category, Error}; +use pglt_fs::{File, OpenOptions, PgLspPath}; +use pglt_workspace::workspace::{ChangeParams, FileGuard, OpenFileParams}; +use pglt_workspace::{Workspace, WorkspaceError}; use std::ffi::OsStr; use std::path::{Path, PathBuf}; diff --git a/crates/pg_cli/src/execute/std_in.rs b/crates/pglt_cli/src/execute/std_in.rs similarity index 88% rename from crates/pg_cli/src/execute/std_in.rs rename to crates/pglt_cli/src/execute/std_in.rs index 8aaf50ea4..3c1bfb286 100644 --- a/crates/pg_cli/src/execute/std_in.rs +++ b/crates/pglt_cli/src/execute/std_in.rs @@ -2,8 +2,8 @@ //! use crate::execute::Execution; use crate::{CliDiagnostic, CliSession}; -use pg_console::{markup, ConsoleExt}; -use pg_fs::PgLspPath; +use pglt_console::{markup, ConsoleExt}; +use pglt_fs::PgLspPath; pub(crate) fn run<'a>( session: CliSession, diff --git a/crates/pg_cli/src/execute/traverse.rs b/crates/pglt_cli/src/execute/traverse.rs similarity index 98% rename from crates/pg_cli/src/execute/traverse.rs rename to crates/pglt_cli/src/execute/traverse.rs index ee51125cd..a20128a4d 100644 --- a/crates/pg_cli/src/execute/traverse.rs +++ b/crates/pglt_cli/src/execute/traverse.rs @@ -5,13 +5,13 @@ use crate::execute::diagnostics::PanicDiagnostic; use crate::reporter::TraversalSummary; use crate::{CliDiagnostic, CliSession}; use crossbeam::channel::{unbounded, Receiver, Sender}; -use pg_diagnostics::DiagnosticTags; -use pg_diagnostics::{DiagnosticExt, Error, Resource, Severity}; -use pg_fs::{FileSystem, PathInterner, PgLspPath}; -use pg_fs::{TraversalContext, TraversalScope}; -use pg_workspace::dome::Dome; -use pg_workspace::workspace::IsPathIgnoredParams; -use pg_workspace::{Workspace, WorkspaceError}; +use pglt_diagnostics::DiagnosticTags; +use pglt_diagnostics::{DiagnosticExt, Error, Resource, Severity}; +use pglt_fs::{FileSystem, PathInterner, PgLspPath}; +use pglt_fs::{TraversalContext, TraversalScope}; +use pglt_workspace::dome::Dome; +use pglt_workspace::workspace::IsPathIgnoredParams; +use pglt_workspace::{Workspace, WorkspaceError}; use rustc_hash::FxHashSet; use std::collections::BTreeSet; use std::sync::atomic::AtomicU32; diff --git a/crates/pg_cli/src/lib.rs b/crates/pglt_cli/src/lib.rs similarity index 82% rename from crates/pg_cli/src/lib.rs rename to crates/pglt_cli/src/lib.rs index 8dabff3ad..72585813e 100644 --- a/crates/pg_cli/src/lib.rs +++ b/crates/pglt_cli/src/lib.rs @@ -7,9 +7,9 @@ use cli_options::CliOptions; use commands::check::CheckCommandPayload; use commands::CommandRunner; -use pg_console::{ColorMode, Console}; -use pg_fs::OsFileSystem; -use pg_workspace::{App, DynRef, Workspace, WorkspaceRef}; +use pglt_console::{ColorMode, Console}; +use pglt_fs::OsFileSystem; +use pglt_workspace::{App, DynRef, Workspace, WorkspaceRef}; use std::env; mod changed; @@ -24,7 +24,7 @@ mod reporter; mod service; use crate::cli_options::ColorsArg; -pub use crate::commands::{pg_lsp_command, PgLspCommand}; +pub use crate::commands::{pglt_command, PgltCommand}; pub use crate::logging::{setup_cli_subscriber, LoggingLevel}; pub use diagnostics::CliDiagnostic; pub use execute::{execute_mode, Execution, TraversalMode, VcsTargeted}; @@ -58,15 +58,15 @@ impl<'app> CliSession<'app> { } /// Main function to run the CLI - pub fn run(self, command: PgLspCommand) -> Result<(), CliDiagnostic> { + pub fn run(self, command: PgltCommand) -> Result<(), CliDiagnostic> { let has_metrics = command.has_metrics(); if has_metrics { crate::metrics::init_metrics(); } let result = match command { - PgLspCommand::Version(_) => commands::version::full_version(self), - PgLspCommand::Check { + PgltCommand::Version(_) => commands::version::full_version(self), + PgltCommand::Check { cli_options, configuration, paths, @@ -86,21 +86,21 @@ impl<'app> CliSession<'app> { since, }, ), - PgLspCommand::Clean => commands::clean::clean(self), - PgLspCommand::Start { + PgltCommand::Clean => commands::clean::clean(self), + PgltCommand::Start { config_path, log_path, log_prefix_name, } => commands::daemon::start(self, config_path, Some(log_path), Some(log_prefix_name)), - PgLspCommand::Stop => commands::daemon::stop(self), - PgLspCommand::Init => commands::init::init(self), - PgLspCommand::LspProxy { + PgltCommand::Stop => commands::daemon::stop(self), + PgltCommand::Init => commands::init::init(self), + PgltCommand::LspProxy { config_path, log_path, log_prefix_name, .. } => commands::daemon::lsp_proxy(config_path, Some(log_path), Some(log_prefix_name)), - PgLspCommand::RunServer { + PgltCommand::RunServer { stop_on_disconnect, config_path, log_path, @@ -111,7 +111,7 @@ impl<'app> CliSession<'app> { Some(log_path), Some(log_prefix_name), ), - PgLspCommand::PrintSocket => commands::daemon::print_socket(), + PgltCommand::PrintSocket => commands::daemon::print_socket(), }; if has_metrics { diff --git a/crates/pg_cli/src/logging.rs b/crates/pglt_cli/src/logging.rs similarity index 100% rename from crates/pg_cli/src/logging.rs rename to crates/pglt_cli/src/logging.rs diff --git a/crates/pg_cli/src/main.rs b/crates/pglt_cli/src/main.rs similarity index 80% rename from crates/pg_cli/src/main.rs rename to crates/pglt_cli/src/main.rs index c97f9291e..f8ba64dd0 100644 --- a/crates/pg_cli/src/main.rs +++ b/crates/pglt_cli/src/main.rs @@ -1,12 +1,12 @@ //! This is the main binary -use pg_cli::{ - open_transport, pg_lsp_command, setup_panic_handler, to_color_mode, CliDiagnostic, CliSession, - PgLspCommand, +use pglt_cli::{ + open_transport, pglt_command, setup_panic_handler, to_color_mode, CliDiagnostic, CliSession, + PgltCommand, }; -use pg_console::{markup, ConsoleExt, EnvConsole}; -use pg_diagnostics::{set_bottom_frame, Diagnostic, PrintDiagnostic}; -use pg_workspace::workspace; +use pglt_console::{markup, ConsoleExt, EnvConsole}; +use pglt_diagnostics::{set_bottom_frame, Diagnostic, PrintDiagnostic}; +use pglt_workspace::workspace; use std::process::{ExitCode, Termination}; use tokio::runtime::Runtime; @@ -31,7 +31,7 @@ fn main() -> ExitCode { set_bottom_frame(main as usize); let mut console = EnvConsole::default(); - let command = pg_lsp_command().fallback_to_usage().run(); + let command = pglt_command().fallback_to_usage().run(); console.set_color(to_color_mode(command.get_color())); @@ -50,7 +50,7 @@ fn main() -> ExitCode { } } -fn run_workspace(console: &mut EnvConsole, command: PgLspCommand) -> Result<(), CliDiagnostic> { +fn run_workspace(console: &mut EnvConsole, command: PgltCommand) -> Result<(), CliDiagnostic> { // If the `--use-server` CLI flag is set, try to open a connection to an // existing server socket let workspace = if command.should_use_server() { diff --git a/crates/pg_cli/src/metrics.rs b/crates/pglt_cli/src/metrics.rs similarity index 100% rename from crates/pg_cli/src/metrics.rs rename to crates/pglt_cli/src/metrics.rs diff --git a/crates/pg_cli/src/panic.rs b/crates/pglt_cli/src/panic.rs similarity index 100% rename from crates/pg_cli/src/panic.rs rename to crates/pglt_cli/src/panic.rs diff --git a/crates/pg_cli/src/reporter/github.rs b/crates/pglt_cli/src/reporter/github.rs similarity index 93% rename from crates/pg_cli/src/reporter/github.rs rename to crates/pglt_cli/src/reporter/github.rs index 6b1588b1b..099944c42 100644 --- a/crates/pg_cli/src/reporter/github.rs +++ b/crates/pglt_cli/src/reporter/github.rs @@ -1,6 +1,6 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; -use pg_console::{markup, Console, ConsoleExt}; -use pg_diagnostics::PrintGitHubDiagnostic; +use pglt_console::{markup, Console, ConsoleExt}; +use pglt_diagnostics::PrintGitHubDiagnostic; use std::io; pub(crate) struct GithubReporter { diff --git a/crates/pg_cli/src/reporter/gitlab.rs b/crates/pglt_cli/src/reporter/gitlab.rs similarity index 97% rename from crates/pg_cli/src/reporter/gitlab.rs rename to crates/pglt_cli/src/reporter/gitlab.rs index 473f4f63e..7035e5324 100644 --- a/crates/pg_cli/src/reporter/gitlab.rs +++ b/crates/pglt_cli/src/reporter/gitlab.rs @@ -1,9 +1,9 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; use path_absolutize::Absolutize; -use pg_console::fmt::{Display, Formatter}; -use pg_console::{markup, Console, ConsoleExt}; -use pg_diagnostics::display::SourceFile; -use pg_diagnostics::{Error, PrintDescription, Resource, Severity}; +use pglt_console::fmt::{Display, Formatter}; +use pglt_console::{markup, Console, ConsoleExt}; +use pglt_diagnostics::display::SourceFile; +use pglt_diagnostics::{Error, PrintDescription, Resource, Severity}; use serde::Serialize; use std::sync::RwLock; use std::{ diff --git a/crates/pg_cli/src/reporter/junit.rs b/crates/pglt_cli/src/reporter/junit.rs similarity index 96% rename from crates/pg_cli/src/reporter/junit.rs rename to crates/pglt_cli/src/reporter/junit.rs index c10059fcf..1097c1ec5 100644 --- a/crates/pg_cli/src/reporter/junit.rs +++ b/crates/pglt_cli/src/reporter/junit.rs @@ -1,7 +1,7 @@ use crate::{DiagnosticsPayload, Execution, Reporter, ReporterVisitor, TraversalSummary}; -use pg_console::{markup, Console, ConsoleExt}; -use pg_diagnostics::display::SourceFile; -use pg_diagnostics::{Error, Resource}; +use pglt_console::{markup, Console, ConsoleExt}; +use pglt_diagnostics::display::SourceFile; +use pglt_diagnostics::{Error, Resource}; use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite}; use std::fmt::{Display, Formatter}; use std::io; diff --git a/crates/pg_cli/src/reporter/mod.rs b/crates/pglt_cli/src/reporter/mod.rs similarity index 96% rename from crates/pg_cli/src/reporter/mod.rs rename to crates/pglt_cli/src/reporter/mod.rs index adc7c0235..fb7837b8c 100644 --- a/crates/pg_cli/src/reporter/mod.rs +++ b/crates/pglt_cli/src/reporter/mod.rs @@ -4,8 +4,8 @@ pub(crate) mod junit; pub(crate) mod terminal; use crate::execute::Execution; -use pg_diagnostics::{Error, Severity}; -use pg_fs::PgLspPath; +use pglt_diagnostics::{Error, Severity}; +use pglt_fs::PgLspPath; use serde::Serialize; use std::collections::BTreeSet; use std::io; diff --git a/crates/pg_cli/src/reporter/terminal.rs b/crates/pglt_cli/src/reporter/terminal.rs similarity index 96% rename from crates/pg_cli/src/reporter/terminal.rs rename to crates/pglt_cli/src/reporter/terminal.rs index 5fd493a25..734c95c39 100644 --- a/crates/pg_cli/src/reporter/terminal.rs +++ b/crates/pglt_cli/src/reporter/terminal.rs @@ -1,11 +1,11 @@ use crate::execute::{Execution, TraversalMode}; use crate::reporter::{DiagnosticsPayload, ReporterVisitor, TraversalSummary}; use crate::Reporter; -use pg_console::fmt::Formatter; -use pg_console::{fmt, markup, Console, ConsoleExt}; -use pg_diagnostics::advice::ListAdvice; -use pg_diagnostics::{Diagnostic, PrintDiagnostic}; -use pg_fs::PgLspPath; +use pglt_console::fmt::Formatter; +use pglt_console::{fmt, markup, Console, ConsoleExt}; +use pglt_diagnostics::advice::ListAdvice; +use pglt_diagnostics::{Diagnostic, PrintDiagnostic}; +use pglt_fs::PgLspPath; use std::collections::BTreeSet; use std::io; use std::time::Duration; diff --git a/crates/pg_cli/src/service/mod.rs b/crates/pglt_cli/src/service/mod.rs similarity index 99% rename from crates/pg_cli/src/service/mod.rs rename to crates/pglt_cli/src/service/mod.rs index 43eb62641..4e55632a4 100644 --- a/crates/pg_cli/src/service/mod.rs +++ b/crates/pglt_cli/src/service/mod.rs @@ -17,7 +17,7 @@ use std::{ use anyhow::{bail, ensure, Context, Error}; use dashmap::DashMap; -use pg_workspace::{ +use pglt_workspace::{ workspace::{TransportRequest, WorkspaceTransport}, TransportError, }; diff --git a/crates/pg_cli/src/service/unix.rs b/crates/pglt_cli/src/service/unix.rs similarity index 97% rename from crates/pg_cli/src/service/unix.rs rename to crates/pglt_cli/src/service/unix.rs index a30d6e38c..22608abc5 100644 --- a/crates/pg_cli/src/service/unix.rs +++ b/crates/pglt_cli/src/service/unix.rs @@ -6,7 +6,7 @@ use std::{ time::Duration, }; -use pg_lsp::{ServerConnection, ServerFactory}; +use pglt_lsp::{ServerConnection, ServerFactory}; use tokio::{ io::Interest, net::{ @@ -21,11 +21,11 @@ use tracing::{debug, info, Instrument}; /// Returns the filesystem path of the global socket used to communicate with /// the server daemon fn get_socket_name() -> PathBuf { - pg_fs::ensure_cache_dir().join(format!("pglsp-socket-{}", pg_configuration::VERSION)) + pglt_fs::ensure_cache_dir().join(format!("pglsp-socket-{}", pglt_configuration::VERSION)) } pub(crate) fn enumerate_pipes() -> io::Result> { - fs::read_dir(pg_fs::ensure_cache_dir()).map(|iter| { + fs::read_dir(pglt_fs::ensure_cache_dir()).map(|iter| { iter.filter_map(|entry| { let entry = entry.ok()?.path(); let file_name = entry.file_name()?; diff --git a/crates/pg_cli/src/service/windows.rs b/crates/pglt_cli/src/service/windows.rs similarity index 98% rename from crates/pg_cli/src/service/windows.rs rename to crates/pglt_cli/src/service/windows.rs index 25c59641b..408553c0c 100644 --- a/crates/pg_cli/src/service/windows.rs +++ b/crates/pglt_cli/src/service/windows.rs @@ -13,7 +13,7 @@ use std::{ time::Duration, }; -use pg_lsp::{ServerConnection, ServerFactory}; +use pglt_lsp::{ServerConnection, ServerFactory}; use tokio::{ io::{AsyncRead, AsyncWrite, ReadBuf}, net::windows::named_pipe::{ClientOptions, NamedPipeClient, NamedPipeServer, ServerOptions}, @@ -24,7 +24,7 @@ use tracing::Instrument; /// Returns the name of the global named pipe used to communicate with the /// server daemon fn get_pipe_name() -> String { - format!(r"\\.\pipe\pglsp-service-{}", pg_configuration::VERSION) + format!(r"\\.\pipe\pglsp-service-{}", pglt_configuration::VERSION) } pub(crate) fn enumerate_pipes() -> io::Result> { diff --git a/crates/pg_commands/Cargo.toml b/crates/pglt_commands/Cargo.toml similarity index 91% rename from crates/pg_commands/Cargo.toml rename to crates/pglt_commands/Cargo.toml index 85808e137..ffa9c214b 100644 --- a/crates/pg_commands/Cargo.toml +++ b/crates/pglt_commands/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_commands" +name = "pglt_commands" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_commands/src/command.rs b/crates/pglt_commands/src/command.rs similarity index 100% rename from crates/pg_commands/src/command.rs rename to crates/pglt_commands/src/command.rs diff --git a/crates/pg_commands/src/execute_statement.rs b/crates/pglt_commands/src/execute_statement.rs similarity index 100% rename from crates/pg_commands/src/execute_statement.rs rename to crates/pglt_commands/src/execute_statement.rs diff --git a/crates/pg_commands/src/lib.rs b/crates/pglt_commands/src/lib.rs similarity index 100% rename from crates/pg_commands/src/lib.rs rename to crates/pglt_commands/src/lib.rs diff --git a/crates/pg_completions/Cargo.toml b/crates/pglt_completions/Cargo.toml similarity index 55% rename from crates/pg_completions/Cargo.toml rename to crates/pglt_completions/Cargo.toml index 0fee5ef03..84a8abd2b 100644 --- a/crates/pg_completions/Cargo.toml +++ b/crates/pglt_completions/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_completions" +name = "pglt_completions" repository.workspace = true version = "0.0.0" @@ -17,19 +17,19 @@ async-std = "1.12.0" text-size.workspace = true -pg_schema_cache.workspace = true -pg_treesitter_queries.workspace = true -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -tree-sitter.workspace = true -tree_sitter_sql.workspace = true +pglt_schema_cache.workspace = true +pglt_treesitter_queries.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +tree-sitter.workspace = true +tree_sitter_sql.workspace = true sqlx.workspace = true tokio = { version = "1.41.1", features = ["full"] } [dev-dependencies] -pg_test_utils.workspace = true +pglt_test_utils.workspace = true [lib] doctest = false diff --git a/crates/pg_completions/README.md b/crates/pglt_completions/README.md similarity index 75% rename from crates/pg_completions/README.md rename to crates/pglt_completions/README.md index 1d3218ac9..f34d82919 100644 --- a/crates/pg_completions/README.md +++ b/crates/pglt_completions/README.md @@ -2,14 +2,14 @@ ## What does this crate do? -The `pg_completions` identifies and ranks autocompletion items that can be displayed in your code editor. +The `pglt_completions` identifies and ranks autocompletion items that can be displayed in your code editor. Its main export is the `complete` function. The function takes a PostgreSQL statement, a cursor position, and a datastructure representing the underlying databases schema. It returns a list of completion items. Postgres's statement-parsing-engine, `libpg_query`, which is used in other parts of this LSP, is only capable of parsing _complete and valid_ statements. Since autocompletion should work for incomplete statements, we rely heavily on tree-sitter – an incremental parsing library. ### Working with TreeSitter -In the `pg_test_utils` crate, there's a binary that parses an SQL file and prints out the matching tree-sitter tree. +In the `pglt_test_utils` crate, there's a binary that parses an SQL file and prints out the matching tree-sitter tree. This makes writing tree-sitter queries for this crate easy. To print a tree, run `cargo run --bin tree_print -- -f `. diff --git a/crates/pg_completions/src/builder.rs b/crates/pglt_completions/src/builder.rs similarity index 100% rename from crates/pg_completions/src/builder.rs rename to crates/pglt_completions/src/builder.rs diff --git a/crates/pg_completions/src/complete.rs b/crates/pglt_completions/src/complete.rs similarity index 95% rename from crates/pg_completions/src/complete.rs rename to crates/pglt_completions/src/complete.rs index c45d01aca..6049a33ad 100644 --- a/crates/pg_completions/src/complete.rs +++ b/crates/pglt_completions/src/complete.rs @@ -13,7 +13,7 @@ pub const LIMIT: usize = 50; #[derive(Debug)] pub struct CompletionParams<'a> { pub position: TextSize, - pub schema: &'a pg_schema_cache::SchemaCache, + pub schema: &'a pglt_schema_cache::SchemaCache, pub text: String, pub tree: Option<&'a tree_sitter::Tree>, } diff --git a/crates/pg_completions/src/context.rs b/crates/pglt_completions/src/context.rs similarity index 96% rename from crates/pg_completions/src/context.rs rename to crates/pglt_completions/src/context.rs index d3ff10523..39973aed2 100644 --- a/crates/pg_completions/src/context.rs +++ b/crates/pglt_completions/src/context.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, HashSet}; -use pg_schema_cache::SchemaCache; -use pg_treesitter_queries::{ +use pglt_schema_cache::SchemaCache; +use pglt_treesitter_queries::{ queries::{self, QueryResult}, TreeSitterQueriesExecutor, }; @@ -266,7 +266,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -298,7 +298,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -332,7 +332,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -357,7 +357,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -385,7 +385,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -411,7 +411,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); @@ -436,7 +436,7 @@ mod tests { position: (position as u32).into(), text, tree: Some(&tree), - schema: &pg_schema_cache::SchemaCache::default(), + schema: &pglt_schema_cache::SchemaCache::default(), }; let ctx = CompletionContext::new(¶ms); diff --git a/crates/pg_completions/src/item.rs b/crates/pglt_completions/src/item.rs similarity index 100% rename from crates/pg_completions/src/item.rs rename to crates/pglt_completions/src/item.rs diff --git a/crates/pg_completions/src/lib.rs b/crates/pglt_completions/src/lib.rs similarity index 100% rename from crates/pg_completions/src/lib.rs rename to crates/pglt_completions/src/lib.rs diff --git a/crates/pg_completions/src/providers/columns.rs b/crates/pglt_completions/src/providers/columns.rs similarity index 100% rename from crates/pg_completions/src/providers/columns.rs rename to crates/pglt_completions/src/providers/columns.rs diff --git a/crates/pg_completions/src/providers/functions.rs b/crates/pglt_completions/src/providers/functions.rs similarity index 100% rename from crates/pg_completions/src/providers/functions.rs rename to crates/pglt_completions/src/providers/functions.rs diff --git a/crates/pg_completions/src/providers/mod.rs b/crates/pglt_completions/src/providers/mod.rs similarity index 100% rename from crates/pg_completions/src/providers/mod.rs rename to crates/pglt_completions/src/providers/mod.rs diff --git a/crates/pg_completions/src/providers/tables.rs b/crates/pglt_completions/src/providers/tables.rs similarity index 100% rename from crates/pg_completions/src/providers/tables.rs rename to crates/pglt_completions/src/providers/tables.rs diff --git a/crates/pg_completions/src/relevance.rs b/crates/pglt_completions/src/relevance.rs similarity index 97% rename from crates/pg_completions/src/relevance.rs rename to crates/pglt_completions/src/relevance.rs index 108f7c7fc..01610c185 100644 --- a/crates/pg_completions/src/relevance.rs +++ b/crates/pglt_completions/src/relevance.rs @@ -2,9 +2,9 @@ use crate::context::{ClauseType, CompletionContext}; #[derive(Debug)] pub(crate) enum CompletionRelevanceData<'a> { - Table(&'a pg_schema_cache::Table), - Function(&'a pg_schema_cache::Function), - Column(&'a pg_schema_cache::Column), + Table(&'a pglt_schema_cache::Table), + Function(&'a pglt_schema_cache::Function), + Column(&'a pglt_schema_cache::Column), } impl CompletionRelevanceData<'_> { diff --git a/crates/pg_completions/src/test_helper.rs b/crates/pglt_completions/src/test_helper.rs similarity index 88% rename from crates/pg_completions/src/test_helper.rs rename to crates/pglt_completions/src/test_helper.rs index 1449c2d07..01893b147 100644 --- a/crates/pg_completions/src/test_helper.rs +++ b/crates/pglt_completions/src/test_helper.rs @@ -1,5 +1,5 @@ -use pg_schema_cache::SchemaCache; -use pg_test_utils::test_database::get_new_test_db; +use pglt_schema_cache::SchemaCache; +use pglt_test_utils::test_database::get_new_test_db; use sqlx::Executor; use crate::CompletionParams; @@ -34,7 +34,7 @@ impl ToString for InputQuery { pub(crate) async fn get_test_deps( setup: &str, input: InputQuery, -) -> (tree_sitter::Tree, pg_schema_cache::SchemaCache) { +) -> (tree_sitter::Tree, pglt_schema_cache::SchemaCache) { let test_db = get_new_test_db().await; test_db @@ -62,7 +62,7 @@ pub(crate) fn get_text_and_position(q: InputQuery) -> (usize, String) { pub(crate) fn get_test_params<'a>( tree: &'a tree_sitter::Tree, - schema_cache: &'a pg_schema_cache::SchemaCache, + schema_cache: &'a pglt_schema_cache::SchemaCache, sql: InputQuery, ) -> CompletionParams<'a> { let (position, text) = get_text_and_position(sql); diff --git a/crates/pg_configuration/Cargo.toml b/crates/pglt_configuration/Cargo.toml similarity index 78% rename from crates/pg_configuration/Cargo.toml rename to crates/pglt_configuration/Cargo.toml index 63e2f773d..f9f4ce186 100644 --- a/crates/pg_configuration/Cargo.toml +++ b/crates/pglt_configuration/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_configuration" +name = "pglt_configuration" repository.workspace = true version = "0.0.0" @@ -15,10 +15,10 @@ version = "0.0.0" biome_deserialize = { workspace = true } biome_deserialize_macros = { workspace = true } bpaf = { workspace = true } -pg_analyse = { workspace = true } -pg_analyser = { workspace = true } -pg_console = { workspace = true } -pg_diagnostics = { workspace = true } +pglt_analyse = { workspace = true } +pglt_analyser = { workspace = true } +pglt_console = { workspace = true } +pglt_diagnostics = { workspace = true } rustc-hash = { workspace = true } schemars = { workspace = true, features = ["indexmap1"], optional = true } serde = { workspace = true, features = ["derive"] } diff --git a/crates/pg_configuration/src/analyser/linter/mod.rs b/crates/pglt_configuration/src/analyser/linter/mod.rs similarity index 100% rename from crates/pg_configuration/src/analyser/linter/mod.rs rename to crates/pglt_configuration/src/analyser/linter/mod.rs diff --git a/crates/pg_configuration/src/analyser/linter/rules.rs b/crates/pglt_configuration/src/analyser/linter/rules.rs similarity index 94% rename from crates/pg_configuration/src/analyser/linter/rules.rs rename to crates/pglt_configuration/src/analyser/linter/rules.rs index a74843afb..8e9544008 100644 --- a/crates/pg_configuration/src/analyser/linter/rules.rs +++ b/crates/pglt_configuration/src/analyser/linter/rules.rs @@ -2,8 +2,8 @@ use crate::analyser::{RuleConfiguration, RulePlainConfiguration}; use biome_deserialize_macros::Merge; -use pg_analyse::{options::RuleOptions, RuleFilter}; -use pg_diagnostics::{Category, Severity}; +use pglt_analyse::{options::RuleOptions, RuleFilter}; +use pglt_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; #[cfg(feature = "schema")] use schemars::JsonSchema; @@ -56,15 +56,15 @@ pub struct Rules { pub safety: Option, } impl Rules { - #[doc = r" Checks if the code coming from [pg_diagnostics::Diagnostic] corresponds to a rule."] + #[doc = r" Checks if the code coming from [pglt_diagnostics::Diagnostic] corresponds to a rule."] #[doc = r" Usually the code is built like {group}/{rule_name}"] pub fn has_rule(group: RuleGroup, rule_name: &str) -> Option<&'static str> { match group { RuleGroup::Safety => Safety::has_rule(rule_name), } } - #[doc = r" Given a category coming from [Diagnostic](pg_diagnostics::Diagnostic), this function returns"] - #[doc = r" the [Severity](pg_diagnostics::Severity) associated to the rule, if the configuration changed it."] + #[doc = r" Given a category coming from [Diagnostic](pglt_diagnostics::Diagnostic), this function returns"] + #[doc = r" the [Severity](pglt_diagnostics::Severity) associated to the rule, if the configuration changed it."] #[doc = r" If the severity is off or not set, then the function returns the default severity of the rule:"] #[doc = r" [Severity::Error] for recommended rules and [Severity::Warning] for other rules."] #[doc = r""] @@ -145,10 +145,10 @@ pub struct Safety { pub all: Option, #[doc = "Dropping a column may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_column: Option>, + pub ban_drop_column: Option>, #[doc = "Dropping a NOT NULL constraint may break existing clients."] #[serde(skip_serializing_if = "Option::is_none")] - pub ban_drop_not_null: Option>, + pub ban_drop_not_null: Option>, } impl Safety { const GROUP_NAME: &'static str = "safety"; diff --git a/crates/pg_configuration/src/analyser/mod.rs b/crates/pglt_configuration/src/analyser/mod.rs similarity index 99% rename from crates/pg_configuration/src/analyser/mod.rs rename to crates/pglt_configuration/src/analyser/mod.rs index 5dae9d19b..9dd868d6e 100644 --- a/crates/pg_configuration/src/analyser/mod.rs +++ b/crates/pglt_configuration/src/analyser/mod.rs @@ -3,9 +3,9 @@ pub mod linter; pub use crate::analyser::linter::*; use biome_deserialize::Merge; use biome_deserialize_macros::Deserializable; -use pg_analyse::options::RuleOptions; -use pg_analyse::RuleFilter; -use pg_diagnostics::Severity; +use pglt_analyse::options::RuleOptions; +use pglt_analyse::RuleFilter; +use pglt_diagnostics::Severity; #[cfg(feature = "schema")] use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/crates/pg_configuration/src/database.rs b/crates/pglt_configuration/src/database.rs similarity index 100% rename from crates/pg_configuration/src/database.rs rename to crates/pglt_configuration/src/database.rs diff --git a/crates/pg_configuration/src/diagnostics.rs b/crates/pglt_configuration/src/diagnostics.rs similarity index 96% rename from crates/pg_configuration/src/diagnostics.rs rename to crates/pglt_configuration/src/diagnostics.rs index e62f080f5..743c16ce5 100644 --- a/crates/pg_configuration/src/diagnostics.rs +++ b/crates/pglt_configuration/src/diagnostics.rs @@ -1,6 +1,6 @@ -use pg_console::fmt::Display; -use pg_console::{markup, MarkupBuf}; -use pg_diagnostics::{Advices, Diagnostic, Error, LogCategory, MessageAndDescription, Visit}; +use pglt_console::fmt::Display; +use pglt_console::{markup, MarkupBuf}; +use pglt_diagnostics::{Advices, Diagnostic, Error, LogCategory, MessageAndDescription, Visit}; use serde::{Deserialize, Serialize}; use std::fmt::{Debug, Formatter}; diff --git a/crates/pg_configuration/src/files.rs b/crates/pglt_configuration/src/files.rs similarity index 100% rename from crates/pg_configuration/src/files.rs rename to crates/pglt_configuration/src/files.rs diff --git a/crates/pg_configuration/src/generated.rs b/crates/pglt_configuration/src/generated.rs similarity index 100% rename from crates/pg_configuration/src/generated.rs rename to crates/pglt_configuration/src/generated.rs diff --git a/crates/pg_configuration/src/generated/linter.rs b/crates/pglt_configuration/src/generated/linter.rs similarity index 92% rename from crates/pg_configuration/src/generated/linter.rs rename to crates/pglt_configuration/src/generated/linter.rs index ecce64efd..81e4b2a9f 100644 --- a/crates/pg_configuration/src/generated/linter.rs +++ b/crates/pglt_configuration/src/generated/linter.rs @@ -1,7 +1,7 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use crate::analyser::linter::*; -use pg_analyse::{AnalyserRules, MetadataRegistry}; +use pglt_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_rules( rules: &Rules, metadata: &MetadataRegistry, diff --git a/crates/pg_configuration/src/lib.rs b/crates/pglt_configuration/src/lib.rs similarity index 100% rename from crates/pg_configuration/src/lib.rs rename to crates/pglt_configuration/src/lib.rs diff --git a/crates/pg_configuration/src/migrations.rs b/crates/pglt_configuration/src/migrations.rs similarity index 100% rename from crates/pg_configuration/src/migrations.rs rename to crates/pglt_configuration/src/migrations.rs diff --git a/crates/pg_configuration/src/vcs.rs b/crates/pglt_configuration/src/vcs.rs similarity index 100% rename from crates/pg_configuration/src/vcs.rs rename to crates/pglt_configuration/src/vcs.rs diff --git a/crates/pg_console/Cargo.toml b/crates/pglt_console/Cargo.toml similarity index 86% rename from crates/pg_console/Cargo.toml rename to crates/pglt_console/Cargo.toml index 56dc4ad0f..fde900ec0 100644 --- a/crates/pg_console/Cargo.toml +++ b/crates/pglt_console/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_console" +name = "pglt_console" repository.workspace = true version = "0.0.0" [dependencies] -pg_markup = { workspace = true } -text-size = { workspace = true } +pglt_markup = { workspace = true } +text-size = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["derive"] } diff --git a/crates/pg_console/README.md b/crates/pglt_console/README.md similarity index 92% rename from crates/pg_console/README.md rename to crates/pglt_console/README.md index 7baceba9e..9e12fb3a3 100644 --- a/crates/pg_console/README.md +++ b/crates/pglt_console/README.md @@ -1,4 +1,4 @@ -# `pg_console` +# `pglt_console` The crate contains a general abstraction over printing messages (formatted with markup) and diagnostics to a console. diff --git a/crates/pg_console/src/fmt.rs b/crates/pglt_console/src/fmt.rs similarity index 98% rename from crates/pg_console/src/fmt.rs rename to crates/pglt_console/src/fmt.rs index 82a83a0e6..f405b4161 100644 --- a/crates/pg_console/src/fmt.rs +++ b/crates/pglt_console/src/fmt.rs @@ -38,7 +38,7 @@ impl<'a> MarkupElements<'a> { } } -/// The [Formatter] is the `pg_console` equivalent to [std::fmt::Formatter]: +/// The [Formatter] is the `pglt_console` equivalent to [std::fmt::Formatter]: /// it's never constructed directly by consumers, and can only be used through /// the mutable reference passed to implementations of the [Display] trait). /// It manages the state of the markup to print, and implementations of @@ -99,13 +99,13 @@ impl<'fmt> Formatter<'fmt> { } } -/// Formatting trait for types to be displayed as markup, the `pg_console` +/// Formatting trait for types to be displayed as markup, the `pglt_console` /// equivalent to [std::fmt::Display] /// /// # Example /// Implementing `Display` on a custom struct /// ``` -/// use pg_console::{ +/// use pglt_console::{ /// fmt::{Display, Formatter}, /// markup, /// }; @@ -204,7 +204,7 @@ impl_std_display!(usize); impl Display for Duration { fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> { - use crate as pg_console; + use crate as pglt_console; let secs = self.as_secs(); if secs > 1 { diff --git a/crates/pg_console/src/lib.rs b/crates/pglt_console/src/lib.rs similarity index 99% rename from crates/pg_console/src/lib.rs rename to crates/pglt_console/src/lib.rs index 7830e347e..935e6bb42 100644 --- a/crates/pg_console/src/lib.rs +++ b/crates/pglt_console/src/lib.rs @@ -1,4 +1,4 @@ -//! # pg_console +//! # pglt_console use std::io; use std::io::{IsTerminal, Read, Write}; @@ -12,7 +12,7 @@ mod utils; mod write; pub use self::markup::{Markup, MarkupBuf, MarkupElement, MarkupNode}; -pub use pg_markup::markup; +pub use pglt_markup::markup; pub use utils::*; /// Determines the "output stream" a message should get printed to diff --git a/crates/pg_console/src/markup.rs b/crates/pglt_console/src/markup.rs similarity index 100% rename from crates/pg_console/src/markup.rs rename to crates/pglt_console/src/markup.rs diff --git a/crates/pg_console/src/utils.rs b/crates/pglt_console/src/utils.rs similarity index 98% rename from crates/pg_console/src/utils.rs rename to crates/pglt_console/src/utils.rs index d56e0139f..5de95c9b4 100644 --- a/crates/pg_console/src/utils.rs +++ b/crates/pglt_console/src/utils.rs @@ -22,7 +22,7 @@ where T: std::fmt::Debug, { fn fmt(&self, fmt: &mut Formatter) -> io::Result<()> { - use crate as pg_console; + use crate as pglt_console; if let Some(value) = &self.0 { markup!({ DebugDisplay(value) }).fmt(fmt)?; diff --git a/crates/pg_console/src/write.rs b/crates/pglt_console/src/write.rs similarity index 100% rename from crates/pg_console/src/write.rs rename to crates/pglt_console/src/write.rs diff --git a/crates/pg_console/src/write/html.rs b/crates/pglt_console/src/write/html.rs similarity index 99% rename from crates/pg_console/src/write/html.rs rename to crates/pglt_console/src/write/html.rs index 244ea4b8e..748644e60 100644 --- a/crates/pg_console/src/write/html.rs +++ b/crates/pglt_console/src/write/html.rs @@ -144,9 +144,9 @@ impl io::Write for HtmlAdapter { #[cfg(test)] mod test { - use crate as pg_console; + use crate as pglt_console; use crate::fmt::Formatter; - use pg_markup::markup; + use pglt_markup::markup; #[test] fn test_mdx_new_lines() { diff --git a/crates/pg_console/src/write/termcolor.rs b/crates/pglt_console/src/write/termcolor.rs similarity index 100% rename from crates/pg_console/src/write/termcolor.rs rename to crates/pglt_console/src/write/termcolor.rs diff --git a/crates/pg_console/tests/macro.rs b/crates/pglt_console/tests/macro.rs similarity index 90% rename from crates/pg_console/tests/macro.rs rename to crates/pglt_console/tests/macro.rs index daa02332e..8dd2eafc8 100644 --- a/crates/pg_console/tests/macro.rs +++ b/crates/pglt_console/tests/macro.rs @@ -1,4 +1,4 @@ -use pg_console::{Markup, MarkupElement}; +use pglt_console::{Markup, MarkupElement}; #[test] fn test_macro() { @@ -7,7 +7,7 @@ fn test_macro() { match // Due to how MarkupNode is implemented, the result of the markup macro // cannot be stored in a binding and must be matched upon immediately - pg_markup::markup! { + pglt_markup::markup! { {category}" Commands" } { @@ -25,7 +25,7 @@ fn test_macro() { #[test] fn test_macro_attributes() { - pg_markup::markup! { + pglt_markup::markup! { "link" }; } diff --git a/crates/pg_console/tests/markup/closing_element_standalone.rs b/crates/pglt_console/tests/markup/closing_element_standalone.rs similarity index 58% rename from crates/pg_console/tests/markup/closing_element_standalone.rs rename to crates/pglt_console/tests/markup/closing_element_standalone.rs index 1e448f1a9..927f04961 100644 --- a/crates/pg_console/tests/markup/closing_element_standalone.rs +++ b/crates/pglt_console/tests/markup/closing_element_standalone.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { } } diff --git a/crates/pg_console/tests/markup/closing_element_standalone.stderr b/crates/pglt_console/tests/markup/closing_element_standalone.stderr similarity index 100% rename from crates/pg_console/tests/markup/closing_element_standalone.stderr rename to crates/pglt_console/tests/markup/closing_element_standalone.stderr diff --git a/crates/pg_console/tests/markup/element_non_ident_name.rs b/crates/pglt_console/tests/markup/element_non_ident_name.rs similarity index 60% rename from crates/pg_console/tests/markup/element_non_ident_name.rs rename to crates/pglt_console/tests/markup/element_non_ident_name.rs index 43813d9d6..9dd9143c3 100644 --- a/crates/pg_console/tests/markup/element_non_ident_name.rs +++ b/crates/pglt_console/tests/markup/element_non_ident_name.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { <"Literal" /> } } diff --git a/crates/pg_console/tests/markup/element_non_ident_name.stderr b/crates/pglt_console/tests/markup/element_non_ident_name.stderr similarity index 100% rename from crates/pg_console/tests/markup/element_non_ident_name.stderr rename to crates/pglt_console/tests/markup/element_non_ident_name.stderr diff --git a/crates/pg_console/tests/markup/invalid_group.rs b/crates/pglt_console/tests/markup/invalid_group.rs similarity index 52% rename from crates/pg_console/tests/markup/invalid_group.rs rename to crates/pglt_console/tests/markup/invalid_group.rs index 2228e2804..4e0761a78 100644 --- a/crates/pg_console/tests/markup/invalid_group.rs +++ b/crates/pglt_console/tests/markup/invalid_group.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { [] } } diff --git a/crates/pg_console/tests/markup/invalid_group.stderr b/crates/pglt_console/tests/markup/invalid_group.stderr similarity index 100% rename from crates/pg_console/tests/markup/invalid_group.stderr rename to crates/pglt_console/tests/markup/invalid_group.stderr diff --git a/crates/pg_console/tests/markup/invalid_punct.rs b/crates/pglt_console/tests/markup/invalid_punct.rs similarity index 51% rename from crates/pg_console/tests/markup/invalid_punct.rs rename to crates/pglt_console/tests/markup/invalid_punct.rs index 5857a3ec5..8e149f18c 100644 --- a/crates/pg_console/tests/markup/invalid_punct.rs +++ b/crates/pglt_console/tests/markup/invalid_punct.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { ! } } diff --git a/crates/pg_console/tests/markup/invalid_punct.stderr b/crates/pglt_console/tests/markup/invalid_punct.stderr similarity index 100% rename from crates/pg_console/tests/markup/invalid_punct.stderr rename to crates/pglt_console/tests/markup/invalid_punct.stderr diff --git a/crates/pg_console/tests/markup/open_element_improper_close_1.rs b/crates/pglt_console/tests/markup/open_element_improper_close_1.rs similarity index 59% rename from crates/pg_console/tests/markup/open_element_improper_close_1.rs rename to crates/pglt_console/tests/markup/open_element_improper_close_1.rs index 291809695..f7f22da67 100644 --- a/crates/pg_console/tests/markup/open_element_improper_close_1.rs +++ b/crates/pglt_console/tests/markup/open_element_improper_close_1.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { } } diff --git a/crates/pg_console/tests/markup/open_element_improper_prop_value.stderr b/crates/pglt_console/tests/markup/open_element_improper_prop_value.stderr similarity index 100% rename from crates/pg_console/tests/markup/open_element_improper_prop_value.stderr rename to crates/pglt_console/tests/markup/open_element_improper_prop_value.stderr diff --git a/crates/pg_console/tests/markup/open_element_missing_prop_value.rs b/crates/pglt_console/tests/markup/open_element_missing_prop_value.rs similarity index 64% rename from crates/pg_console/tests/markup/open_element_missing_prop_value.rs rename to crates/pglt_console/tests/markup/open_element_missing_prop_value.rs index 38547643c..8119cc582 100644 --- a/crates/pg_console/tests/markup/open_element_missing_prop_value.rs +++ b/crates/pglt_console/tests/markup/open_element_missing_prop_value.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { } } diff --git a/crates/pg_console/tests/markup/open_element_missing_prop_value.stderr b/crates/pglt_console/tests/markup/open_element_missing_prop_value.stderr similarity index 100% rename from crates/pg_console/tests/markup/open_element_missing_prop_value.stderr rename to crates/pglt_console/tests/markup/open_element_missing_prop_value.stderr diff --git a/crates/pg_console/tests/markup/open_element_unfinished_1.rs b/crates/pglt_console/tests/markup/open_element_unfinished_1.rs similarity index 51% rename from crates/pg_console/tests/markup/open_element_unfinished_1.rs rename to crates/pglt_console/tests/markup/open_element_unfinished_1.rs index 13939e522..be2500fbc 100644 --- a/crates/pg_console/tests/markup/open_element_unfinished_1.rs +++ b/crates/pglt_console/tests/markup/open_element_unfinished_1.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { < } } diff --git a/crates/pglt_console/tests/markup/open_element_unfinished_1.stderr b/crates/pglt_console/tests/markup/open_element_unfinished_1.stderr new file mode 100644 index 000000000..6a53f1c9b --- /dev/null +++ b/crates/pglt_console/tests/markup/open_element_unfinished_1.stderr @@ -0,0 +1,9 @@ +error: unexpected end of input + --> tests/markup/open_element_unfinished_1.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | < +4 | | } + | |_____^ + | + = note: this error originates in the macro `pglt_console::markup` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/pg_console/tests/markup/open_element_unfinished_2.rs b/crates/pglt_console/tests/markup/open_element_unfinished_2.rs similarity index 57% rename from crates/pg_console/tests/markup/open_element_unfinished_2.rs rename to crates/pglt_console/tests/markup/open_element_unfinished_2.rs index 40552a6ea..8321c0175 100644 --- a/crates/pg_console/tests/markup/open_element_unfinished_2.rs +++ b/crates/pglt_console/tests/markup/open_element_unfinished_2.rs @@ -1,5 +1,5 @@ fn main() { - pg_console::markup! { + pglt_console::markup! { tests/markup/open_element_unfinished_2.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | tests/markup/open_element_unfinished_3.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | tests/markup/open_element_unfinished_4.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | tests/markup/open_element_unfinished_5.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | tests/markup/open_element_unfinished_6.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | tests/markup/open_element_unfinished_7.rs:2:5 + | +2 | / pglt_console::markup! { +3 | | } } diff --git a/crates/pg_console/tests/markup/unclosed_element.stderr b/crates/pglt_console/tests/markup/unclosed_element.stderr similarity index 100% rename from crates/pg_console/tests/markup/unclosed_element.stderr rename to crates/pglt_console/tests/markup/unclosed_element.stderr diff --git a/crates/pglt_diagnostics/Cargo.toml b/crates/pglt_diagnostics/Cargo.toml new file mode 100644 index 000000000..0f4d80e2b --- /dev/null +++ b/crates/pglt_diagnostics/Cargo.toml @@ -0,0 +1,35 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pglt_diagnostics" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +backtrace = "0.3.74" +bpaf = { workspace = true } +enumflags2 = { workspace = true } +pglt_console = { workspace = true, features = ["serde_markup"] } +pglt_diagnostics_categories = { workspace = true, features = ["serde"] } +pglt_diagnostics_macros = { workspace = true } +pglt_text_edit = { workspace = true } +schemars = { workspace = true, optional = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +termcolor = { workspace = true } +text-size.workspace = true +unicode-width = { workspace = true } + +[features] +schema = ["schemars", "pglt_text_edit/schemars", "pglt_diagnostics_categories/schemars"] + +[dev-dependencies] + +[lib] +doctest = false diff --git a/crates/pg_diagnostics/src/adapters.rs b/crates/pglt_diagnostics/src/adapters.rs similarity index 99% rename from crates/pg_diagnostics/src/adapters.rs rename to crates/pglt_diagnostics/src/adapters.rs index 1521b1390..1e73cc236 100644 --- a/crates/pg_diagnostics/src/adapters.rs +++ b/crates/pglt_diagnostics/src/adapters.rs @@ -4,7 +4,7 @@ use std::io; -use pg_console::{ +use pglt_console::{ fmt::{self}, markup, }; diff --git a/crates/pg_diagnostics/src/advice.rs b/crates/pglt_diagnostics/src/advice.rs similarity index 98% rename from crates/pg_diagnostics/src/advice.rs rename to crates/pglt_diagnostics/src/advice.rs index 1488ed81a..d436f3ac6 100644 --- a/crates/pg_diagnostics/src/advice.rs +++ b/crates/pglt_diagnostics/src/advice.rs @@ -4,9 +4,9 @@ use crate::{ location::{AsResource, AsSourceCode, AsSpan}, Location, }; -use pg_console::fmt::{self, Display}; -use pg_console::{markup, MarkupBuf}; -use pg_text_edit::TextEdit; +use pglt_console::fmt::{self, Display}; +use pglt_console::{markup, MarkupBuf}; +use pglt_text_edit::TextEdit; use serde::{Deserialize, Serialize}; use std::io; diff --git a/crates/pg_diagnostics/src/context.rs b/crates/pglt_diagnostics/src/context.rs similarity index 99% rename from crates/pg_diagnostics/src/context.rs rename to crates/pglt_diagnostics/src/context.rs index c9811aeea..a73bc2bf8 100644 --- a/crates/pg_diagnostics/src/context.rs +++ b/crates/pglt_diagnostics/src/context.rs @@ -1,4 +1,4 @@ -use pg_console::fmt; +use pglt_console::fmt; use crate::context::internal::{SeverityDiagnostic, TagsDiagnostic}; use crate::{ @@ -249,8 +249,8 @@ mod internal { use std::{fmt::Debug, io}; - use pg_console::{fmt, markup}; - use pg_text_edit::TextEdit; + use pglt_console::{fmt, markup}; + use pglt_text_edit::TextEdit; use text_size::TextRange; use crate::{ @@ -260,7 +260,7 @@ mod internal { }; /// This trait is inherited by `DiagnosticExt` and `Context`, since it's - /// not visible outside of `pg_diagnostics` this prevents these extension + /// not visible outside of `pglt_diagnostics` this prevents these extension /// traits from being implemented on other types outside of this module /// /// Making these traits "sealed" is mainly intended as a stability diff --git a/crates/pg_diagnostics/src/diagnostic.rs b/crates/pglt_diagnostics/src/diagnostic.rs similarity index 98% rename from crates/pg_diagnostics/src/diagnostic.rs rename to crates/pglt_diagnostics/src/diagnostic.rs index e50690691..2ccdddf21 100644 --- a/crates/pg_diagnostics/src/diagnostic.rs +++ b/crates/pglt_diagnostics/src/diagnostic.rs @@ -9,7 +9,7 @@ use std::{ use enumflags2::{bitflags, make_bitflags, BitFlags}; use serde::{Deserialize, Serialize}; -use pg_console::fmt; +use pglt_console::fmt; use crate::{Category, Location, Visit}; @@ -22,7 +22,7 @@ use crate::{Category, Location, Visit}; /// instead rely on the `Diagnostic` derive macro also provided by this crate: /// /// ``` -/// # use pg_diagnostics::Diagnostic; +/// # use pglt_diagnostics::Diagnostic; /// #[derive(Debug, Diagnostic)] /// #[diagnostic(category = "lint/style/noShoutyConstants", tags(FIXABLE))] /// struct ExampleDiagnostic { @@ -247,7 +247,7 @@ pub(crate) mod internal { /// trait (as that would conflict with the implementation of `From for T` /// in the standard library). The [AsDiagnostic] exists as an internal /// implementation detail to bridge this gap and allow various types and - /// functions in `pg_diagnostics` to be generic over all diagnostics + + /// functions in `pglt_diagnostics` to be generic over all diagnostics + /// `Error`. pub trait AsDiagnostic: Debug { type Diagnostic: Diagnostic + ?Sized; diff --git a/crates/pg_diagnostics/src/display.rs b/crates/pglt_diagnostics/src/display.rs similarity index 98% rename from crates/pg_diagnostics/src/display.rs rename to crates/pglt_diagnostics/src/display.rs index e3b7a7bad..df9a2ef40 100644 --- a/crates/pg_diagnostics/src/display.rs +++ b/crates/pglt_diagnostics/src/display.rs @@ -1,8 +1,8 @@ -use pg_console::fmt::MarkupElements; -use pg_console::{ +use pglt_console::fmt::MarkupElements; +use pglt_console::{ fmt, markup, HorizontalLine, Markup, MarkupBuf, MarkupElement, MarkupNode, Padding, }; -use pg_text_edit::TextEdit; +use pglt_text_edit::TextEdit; use std::path::Path; use std::{env, io, iter}; use unicode_width::UnicodeWidthStr; @@ -35,7 +35,7 @@ impl std::fmt::Display for PrintDescription<'_, D> { } /// Helper struct for printing a diagnostic as markup into any formatter -/// implementing [pg_console::fmt::Write]. +/// implementing [pglt_console::fmt::Write]. pub struct PrintDiagnostic<'fmt, D: ?Sized> { diag: &'fmt D, verbose: bool, @@ -665,14 +665,14 @@ impl fmt::Write for IndentWriter<'_, W> { mod tests { use std::io; - use pg_console::{fmt, markup}; - use pg_diagnostics::{DiagnosticTags, Severity}; - use pg_diagnostics_categories::{category, Category}; - use pg_text_edit::TextEdit; + use pglt_console::{fmt, markup}; + use pglt_diagnostics::{DiagnosticTags, Severity}; + use pglt_diagnostics_categories::{category, Category}; + use pglt_text_edit::TextEdit; use serde_json::{from_value, json}; use text_size::{TextRange, TextSize}; - use crate::{self as pg_diagnostics}; + use crate::{self as pglt_diagnostics}; use crate::{ Advices, Diagnostic, Location, LogCategory, PrintDiagnostic, Resource, SourceCode, Visit, }; diff --git a/crates/pg_diagnostics/src/display/backtrace.rs b/crates/pglt_diagnostics/src/display/backtrace.rs similarity index 99% rename from crates/pg_diagnostics/src/display/backtrace.rs rename to crates/pglt_diagnostics/src/display/backtrace.rs index bae7d979c..ff9b1d985 100644 --- a/crates/pg_diagnostics/src/display/backtrace.rs +++ b/crates/pglt_diagnostics/src/display/backtrace.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, path::PathBuf}; use std::{cell::Cell, fmt::Write as _, io, os::raw::c_void, path::Path, slice}; -use pg_console::{fmt, markup}; +use pglt_console::{fmt, markup}; use serde::{Deserialize, Serialize}; use super::IndentWriter; @@ -197,7 +197,7 @@ thread_local! { /// /// On the main thread: /// ``` -/// # use pg_diagnostics::set_bottom_frame; +/// # use pglt_diagnostics::set_bottom_frame; /// # #[allow(clippy::needless_doctest_main)] /// pub fn main() { /// set_bottom_frame(main as usize); @@ -208,7 +208,7 @@ thread_local! { /// /// On worker threads: /// ``` -/// # use pg_diagnostics::set_bottom_frame; +/// # use pglt_diagnostics::set_bottom_frame; /// fn worker_thread() { /// set_bottom_frame(worker_thread as usize); /// diff --git a/crates/pg_diagnostics/src/display/diff.rs b/crates/pglt_diagnostics/src/display/diff.rs similarity index 99% rename from crates/pg_diagnostics/src/display/diff.rs rename to crates/pglt_diagnostics/src/display/diff.rs index f98396475..c16b3e0e9 100644 --- a/crates/pg_diagnostics/src/display/diff.rs +++ b/crates/pglt_diagnostics/src/display/diff.rs @@ -3,8 +3,8 @@ use std::{ io, slice, }; -use pg_console::{fmt, markup, MarkupElement}; -use pg_text_edit::{ChangeTag, CompressedOp, TextEdit}; +use pglt_console::{fmt, markup, MarkupElement}; +use pglt_text_edit::{ChangeTag, CompressedOp, TextEdit}; use super::frame::{ calculate_print_width, print_invisibles, text_width, IntoIter, OneIndexed, @@ -669,8 +669,8 @@ impl fmt::Write for ElementWrapper<'_, W> { #[cfg(test)] mod tests { use super::print_diff; - use pg_console::{fmt, markup, MarkupBuf}; - use pg_text_edit::TextEdit; + use pglt_console::{fmt, markup, MarkupBuf}; + use pglt_text_edit::TextEdit; use termcolor::Buffer; fn assert_eq_markup(actual: &MarkupBuf, expected: &MarkupBuf) { diff --git a/crates/pg_diagnostics/src/display/frame.rs b/crates/pglt_diagnostics/src/display/frame.rs similarity index 99% rename from crates/pg_diagnostics/src/display/frame.rs rename to crates/pglt_diagnostics/src/display/frame.rs index 8719cc0df..6526d82be 100644 --- a/crates/pg_diagnostics/src/display/frame.rs +++ b/crates/pglt_diagnostics/src/display/frame.rs @@ -6,7 +6,7 @@ use std::{ ops::{Bound, RangeBounds}, }; -use pg_console::{fmt, markup}; +use pglt_console::{fmt, markup}; use text_size::{TextLen, TextRange, TextSize}; use unicode_width::UnicodeWidthChar; diff --git a/crates/pg_diagnostics/src/display/message.rs b/crates/pglt_diagnostics/src/display/message.rs similarity index 92% rename from crates/pg_diagnostics/src/display/message.rs rename to crates/pglt_diagnostics/src/display/message.rs index 460f70387..9fc7ba95d 100644 --- a/crates/pg_diagnostics/src/display/message.rs +++ b/crates/pglt_diagnostics/src/display/message.rs @@ -1,5 +1,5 @@ -use pg_console::fmt::{Formatter, Termcolor}; -use pg_console::{markup, MarkupBuf}; +use pglt_console::fmt::{Formatter, Termcolor}; +use pglt_console::{markup, MarkupBuf}; use serde::{Deserialize, Serialize}; use termcolor::NoColor; @@ -9,7 +9,7 @@ use termcolor::NoColor; /// ## Examples /// /// ``` -/// use pg_diagnostics::{Diagnostic, MessageAndDescription}; +/// use pglt_diagnostics::{Diagnostic, MessageAndDescription}; /// /// #[derive(Debug, Diagnostic)] /// struct TestDiagnostic { @@ -69,7 +69,7 @@ impl std::fmt::Debug for MessageAndDescription { } } -impl pg_console::fmt::Display for MessageAndDescription { +impl pglt_console::fmt::Display for MessageAndDescription { fn fmt(&self, fmt: &mut Formatter<'_>) -> std::io::Result<()> { fmt.write_markup(markup! {{self.message}}) } diff --git a/crates/pg_diagnostics/src/display_github.rs b/crates/pglt_diagnostics/src/display_github.rs similarity index 98% rename from crates/pg_diagnostics/src/display_github.rs rename to crates/pglt_diagnostics/src/display_github.rs index d029e508a..badf57ed4 100644 --- a/crates/pg_diagnostics/src/display_github.rs +++ b/crates/pglt_diagnostics/src/display_github.rs @@ -1,11 +1,11 @@ use crate::display::frame::SourceFile; use crate::{diagnostic::internal::AsDiagnostic, Diagnostic, Resource, Severity}; -use pg_console::{fmt, markup, MarkupBuf}; +use pglt_console::{fmt, markup, MarkupBuf}; use std::io; use text_size::{TextRange, TextSize}; /// Helper struct for printing a diagnostic as markup into any formatter -/// implementing [pg_console::fmt::Write]. +/// implementing [pglt_console::fmt::Write]. pub struct PrintGitHubDiagnostic<'fmt, D: ?Sized>(pub &'fmt D); impl fmt::Display for PrintGitHubDiagnostic<'_, D> { diff --git a/crates/pg_diagnostics/src/error.rs b/crates/pglt_diagnostics/src/error.rs similarity index 99% rename from crates/pg_diagnostics/src/error.rs rename to crates/pglt_diagnostics/src/error.rs index eea8fc9cb..b522f1b49 100644 --- a/crates/pg_diagnostics/src/error.rs +++ b/crates/pglt_diagnostics/src/error.rs @@ -14,7 +14,7 @@ use std::{ io, }; -use pg_console::fmt; +use pglt_console::fmt; use crate::{ diagnostic::internal::AsDiagnostic, Category, Diagnostic, DiagnosticTags, Location, Severity, diff --git a/crates/pg_diagnostics/src/lib.rs b/crates/pglt_diagnostics/src/lib.rs similarity index 88% rename from crates/pg_diagnostics/src/lib.rs rename to crates/pglt_diagnostics/src/lib.rs index 93e4a5def..263c7013e 100644 --- a/crates/pg_diagnostics/src/lib.rs +++ b/crates/pglt_diagnostics/src/lib.rs @@ -20,11 +20,11 @@ pub use termcolor; #[doc(hidden)] // Convenience re-export for procedural macro -pub use pg_console as console; +pub use pglt_console as console; // Re-export macros from utility crates -pub use pg_diagnostics_categories::{category, category_concat, Category}; -pub use pg_diagnostics_macros::Diagnostic; +pub use pglt_diagnostics_categories::{category, category_concat, Category}; +pub use pglt_diagnostics_macros::Diagnostic; pub use crate::advice::{ Advices, CodeFrameAdvice, CommandAdvice, DiffAdvice, LogAdvice, LogCategory, Visit, @@ -37,13 +37,13 @@ pub use crate::display::{ pub use crate::display_github::PrintGitHubDiagnostic; pub use crate::error::{Error, Result}; pub use crate::location::{LineIndex, LineIndexBuf, Location, Resource, SourceCode}; -use pg_console::fmt::{Formatter, Termcolor}; -use pg_console::markup; +use pglt_console::fmt::{Formatter, Termcolor}; +use pglt_console::markup; use std::fmt::Write; pub mod prelude { //! Anonymously re-exports all the traits declared by this module, this is - //! intended to be imported as `use pg_diagnostics::prelude::*;` to + //! intended to be imported as `use pglt_diagnostics::prelude::*;` to //! automatically bring all these traits into the ambient context pub use crate::advice::{Advices as _, Visit as _}; diff --git a/crates/pg_diagnostics/src/location.rs b/crates/pglt_diagnostics/src/location.rs similarity index 100% rename from crates/pg_diagnostics/src/location.rs rename to crates/pglt_diagnostics/src/location.rs diff --git a/crates/pg_diagnostics/src/panic.rs b/crates/pglt_diagnostics/src/panic.rs similarity index 100% rename from crates/pg_diagnostics/src/panic.rs rename to crates/pglt_diagnostics/src/panic.rs diff --git a/crates/pg_diagnostics/src/serde.rs b/crates/pglt_diagnostics/src/serde.rs similarity index 98% rename from crates/pg_diagnostics/src/serde.rs rename to crates/pglt_diagnostics/src/serde.rs index f99a11956..810f9ffdf 100644 --- a/crates/pg_diagnostics/src/serde.rs +++ b/crates/pglt_diagnostics/src/serde.rs @@ -1,7 +1,7 @@ use std::io; -use pg_console::{fmt, markup, MarkupBuf}; -use pg_text_edit::TextEdit; +use pglt_console::{fmt, markup, MarkupBuf}; +use pglt_text_edit::TextEdit; use serde::{ de::{self, SeqAccess}, Deserialize, Deserializer, Serialize, Serializer, @@ -362,9 +362,9 @@ mod tests { use text_size::{TextRange, TextSize}; use crate::{ - self as pg_diagnostics, {Advices, LogCategory, Visit}, + self as pglt_diagnostics, {Advices, LogCategory, Visit}, }; - use pg_diagnostics_macros::Diagnostic; + use pglt_diagnostics_macros::Diagnostic; #[derive(Debug, Diagnostic)] #[diagnostic( diff --git a/crates/pg_diagnostics/src/suggestion.rs b/crates/pglt_diagnostics/src/suggestion.rs similarity index 94% rename from crates/pg_diagnostics/src/suggestion.rs rename to crates/pglt_diagnostics/src/suggestion.rs index 44ed4548f..0809b2bfc 100644 --- a/crates/pg_diagnostics/src/suggestion.rs +++ b/crates/pglt_diagnostics/src/suggestion.rs @@ -1,6 +1,6 @@ use ::serde::{Deserialize, Serialize}; -use pg_console::MarkupBuf; -use pg_text_edit::TextEdit; +use pglt_console::MarkupBuf; +use pglt_text_edit::TextEdit; use text_size::TextRange; /// Indicates how a tool should manage this suggestion. diff --git a/crates/pg_diagnostics_categories/Cargo.toml b/crates/pglt_diagnostics_categories/Cargo.toml similarity index 89% rename from crates/pg_diagnostics_categories/Cargo.toml rename to crates/pglt_diagnostics_categories/Cargo.toml index bfb7be433..0771c05f6 100644 --- a/crates/pg_diagnostics_categories/Cargo.toml +++ b/crates/pglt_diagnostics_categories/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_diagnostics_categories" +name = "pglt_diagnostics_categories" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_diagnostics_categories/build.rs b/crates/pglt_diagnostics_categories/build.rs similarity index 93% rename from crates/pg_diagnostics_categories/build.rs rename to crates/pglt_diagnostics_categories/build.rs index dc2636642..ab9c41ad6 100644 --- a/crates/pg_diagnostics_categories/build.rs +++ b/crates/pglt_diagnostics_categories/build.rs @@ -85,7 +85,7 @@ pub fn main() -> io::Result<()> { /// # Example /// /// ``` - /// # use pg_diagnostics_categories::{Category, category}; + /// # use pglt_diagnostics_categories::{Category, category}; /// let category: &'static Category = category!("internalError/io"); /// assert_eq!(category.name(), "internalError/io"); /// assert_eq!(category.link(), None); @@ -95,7 +95,7 @@ pub fn main() -> io::Result<()> { #( #macro_arms )* ( $name:literal ) => { - compile_error!(concat!("Unregistered diagnostic category \"", $name, "\", please add it to \"crates/pg_diagnostics_categories/src/categories.rs\"")) + compile_error!(concat!("Unregistered diagnostic category \"", $name, "\", please add it to \"crates/pglt_diagnostics_categories/src/categories.rs\"")) }; ( $( $parts:tt )* ) => { compile_error!(concat!("Invalid diagnostic category `", stringify!($( $parts )*), "`, expected a single string literal")) @@ -110,7 +110,7 @@ pub fn main() -> io::Result<()> { #( #concat_macro_arms )* ( @compile_error $( $parts:tt )* ) => { - compile_error!(concat!("Unregistered diagnostic category \"", $( $parts, )* "\", please add it to \"crates/pg_diagnostics_categories/src/categories.rs\"")) + compile_error!(concat!("Unregistered diagnostic category \"", $( $parts, )* "\", please add it to \"crates/pglt_diagnostics_categories/src/categories.rs\"")) }; ( $( $parts:tt ),* ) => { $crate::category_concat!( @compile_error $( $parts )"/"* ) diff --git a/crates/pg_diagnostics_categories/src/categories.rs b/crates/pglt_diagnostics_categories/src/categories.rs similarity index 100% rename from crates/pg_diagnostics_categories/src/categories.rs rename to crates/pglt_diagnostics_categories/src/categories.rs diff --git a/crates/pg_diagnostics_categories/src/lib.rs b/crates/pglt_diagnostics_categories/src/lib.rs similarity index 96% rename from crates/pg_diagnostics_categories/src/lib.rs rename to crates/pglt_diagnostics_categories/src/lib.rs index fda85b8e2..e72e9d0fd 100644 --- a/crates/pg_diagnostics_categories/src/lib.rs +++ b/crates/pglt_diagnostics_categories/src/lib.rs @@ -5,7 +5,7 @@ use std::{ /// Metadata for a diagnostic category /// -/// This type cannot be instantiated outside of the `pg_diagnostics_categories` +/// This type cannot be instantiated outside of the `pglt_diagnostics_categories` /// crate, which serves as a registry for all known diagnostic categories /// (currently this registry is fully static and generated at compile time) #[derive(Debug)] diff --git a/crates/pg_diagnostics_macros/Cargo.toml b/crates/pglt_diagnostics_macros/Cargo.toml similarity index 91% rename from crates/pg_diagnostics_macros/Cargo.toml rename to crates/pglt_diagnostics_macros/Cargo.toml index e67067beb..8cc10058c 100644 --- a/crates/pg_diagnostics_macros/Cargo.toml +++ b/crates/pglt_diagnostics_macros/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_diagnostics_macros" +name = "pglt_diagnostics_macros" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_diagnostics_macros/src/generate.rs b/crates/pglt_diagnostics_macros/src/generate.rs similarity index 69% rename from crates/pg_diagnostics_macros/src/generate.rs rename to crates/pglt_diagnostics_macros/src/generate.rs index 66c231f3e..ea422b1f4 100644 --- a/crates/pg_diagnostics_macros/src/generate.rs +++ b/crates/pglt_diagnostics_macros/src/generate.rs @@ -37,7 +37,7 @@ fn generate_struct_diagnostic(input: DeriveStructInput) -> TokenStream { let generics = input.generics; quote! { - impl #generic_params pg_diagnostics::Diagnostic for #ident #generics { + impl #generic_params pglt_diagnostics::Diagnostic for #ident #generics { #category #severity #description @@ -54,7 +54,7 @@ fn generate_struct_diagnostic(input: DeriveStructInput) -> TokenStream { fn generate_category(input: &DeriveStructInput) -> TokenStream { let category = match &input.category { Some(StaticOrDynamic::Static(value)) => quote! { - pg_diagnostics::category!(#value) + pglt_diagnostics::category!(#value) }, Some(StaticOrDynamic::Dynamic(value)) => quote! { self.#value @@ -63,7 +63,7 @@ fn generate_category(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn category(&self) -> Option<&'static pg_diagnostics::Category> { + fn category(&self) -> Option<&'static pglt_diagnostics::Category> { Some(#category) } } @@ -72,7 +72,7 @@ fn generate_category(input: &DeriveStructInput) -> TokenStream { fn generate_severity(input: &DeriveStructInput) -> TokenStream { let severity = match &input.severity { Some(StaticOrDynamic::Static(value)) => quote! { - pg_diagnostics::Severity::#value + pglt_diagnostics::Severity::#value }, Some(StaticOrDynamic::Dynamic(value)) => quote! { self.#value @@ -81,7 +81,7 @@ fn generate_severity(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn severity(&self) -> pg_diagnostics::Severity { + fn severity(&self) -> pglt_diagnostics::Severity { #severity } } @@ -137,12 +137,12 @@ fn generate_description(input: &DeriveStructInput) -> TokenStream { Some(StaticOrDynamic::Static(StringOrMarkup::Markup(markup))) => quote! { let mut buffer = Vec::new(); - let write = pg_diagnostics::termcolor::NoColor::new(&mut buffer); - let mut write = pg_diagnostics::console::fmt::Termcolor(write); - let mut write = pg_diagnostics::console::fmt::Formatter::new(&mut write); + let write = pglt_diagnostics::termcolor::NoColor::new(&mut buffer); + let mut write = pglt_diagnostics::console::fmt::Termcolor(write); + let mut write = pglt_diagnostics::console::fmt::Formatter::new(&mut write); - use pg_diagnostics::console as pg_console; - write.write_markup(&pg_diagnostics::console::markup!{ #markup }) + use pglt_diagnostics::console as pglt_console; + write.write_markup(&pglt_diagnostics::console::markup!{ #markup }) .map_err(|_| ::std::fmt::Error)?; fmt.write_str(::std::str::from_utf8(&buffer).map_err(|_| ::std::fmt::Error)?) @@ -166,17 +166,17 @@ fn generate_message(input: &DeriveStructInput) -> TokenStream { fmt.write_str(#value) }, Some(StaticOrDynamic::Static(StringOrMarkup::Markup(markup))) => quote! { - use pg_diagnostics::console as pg_console; - fmt.write_markup(pg_diagnostics::console::markup!{ #markup }) + use pglt_diagnostics::console as pglt_console; + fmt.write_markup(pglt_diagnostics::console::markup!{ #markup }) }, Some(StaticOrDynamic::Dynamic(value)) => quote! { - pg_diagnostics::console::fmt::Display::fmt(&self.#value, fmt) + pglt_diagnostics::console::fmt::Display::fmt(&self.#value, fmt) }, None => return quote!(), }; quote! { - fn message(&self, fmt: &mut pg_diagnostics::console::fmt::Formatter<'_>) -> ::std::io::Result<()> { + fn message(&self, fmt: &mut pglt_diagnostics::console::fmt::Formatter<'_>) -> ::std::io::Result<()> { #message } } @@ -190,8 +190,8 @@ fn generate_advices(input: &DeriveStructInput) -> TokenStream { let advices = input.advices.iter(); quote! { - fn advices(&self, visitor: &mut dyn pg_diagnostics::Visit) -> ::std::io::Result<()> { - #( pg_diagnostics::Advices::record(&self.#advices, visitor)?; )* + fn advices(&self, visitor: &mut dyn pglt_diagnostics::Visit) -> ::std::io::Result<()> { + #( pglt_diagnostics::Advices::record(&self.#advices, visitor)?; )* Ok(()) } } @@ -205,8 +205,8 @@ fn generate_verbose_advices(input: &DeriveStructInput) -> TokenStream { let verbose_advices = input.verbose_advices.iter(); quote! { - fn verbose_advices(&self, visitor: &mut dyn pg_diagnostics::Visit) -> ::std::io::Result<()> { - #( pg_diagnostics::Advices::record(&self.#verbose_advices, visitor)?; )* + fn verbose_advices(&self, visitor: &mut dyn pglt_diagnostics::Visit) -> ::std::io::Result<()> { + #( pglt_diagnostics::Advices::record(&self.#verbose_advices, visitor)?; )* Ok(()) } } @@ -221,8 +221,8 @@ fn generate_location(input: &DeriveStructInput) -> TokenStream { let method = input.location.iter().map(|(_, method)| method); quote! { - fn location(&self) -> pg_diagnostics::Location<'_> { - pg_diagnostics::Location::builder() + fn location(&self) -> pglt_diagnostics::Location<'_> { + pglt_diagnostics::Location::builder() #( .#method(&self.#field) )* .build() } @@ -234,7 +234,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { Some(StaticOrDynamic::Static(value)) => { let values = value.iter(); quote! { - #( pg_diagnostics::DiagnosticTags::#values )|* + #( pglt_diagnostics::DiagnosticTags::#values )|* } } Some(StaticOrDynamic::Dynamic(value)) => quote! { @@ -244,7 +244,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { }; quote! { - fn tags(&self) -> pg_diagnostics::DiagnosticTags { + fn tags(&self) -> pglt_diagnostics::DiagnosticTags { #tags } } @@ -253,7 +253,7 @@ fn generate_tags(input: &DeriveStructInput) -> TokenStream { fn generate_source(input: &DeriveStructInput) -> TokenStream { match &input.source { Some(value) => quote! { - fn source(&self) -> Option<&dyn pg_diagnostics::Diagnostic> { + fn source(&self) -> Option<&dyn pglt_diagnostics::Diagnostic> { self.#value.as_deref() } }, @@ -280,58 +280,58 @@ fn generate_enum_diagnostic(input: DeriveEnumInput) -> TokenStream { .collect(); quote! { - impl #generic_params pg_diagnostics::Diagnostic for #ident #generics { - fn category(&self) -> Option<&'static pg_diagnostics::Category> { + impl #generic_params pglt_diagnostics::Diagnostic for #ident #generics { + fn category(&self) -> Option<&'static pglt_diagnostics::Category> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::category(error),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::category(error),)* } } fn description(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::description(error, fmt),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::description(error, fmt),)* } } - fn message(&self, fmt: &mut pg_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pglt_console::fmt::Formatter<'_>) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::message(error, fmt),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::message(error, fmt),)* } } - fn severity(&self) -> pg_diagnostics::Severity { + fn severity(&self) -> pglt_diagnostics::Severity { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::severity(error),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::severity(error),)* } } - fn tags(&self) -> pg_diagnostics::DiagnosticTags { + fn tags(&self) -> pglt_diagnostics::DiagnosticTags { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::tags(error),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::tags(error),)* } } - fn location(&self) -> pg_diagnostics::Location<'_> { + fn location(&self) -> pglt_diagnostics::Location<'_> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::location(error),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::location(error),)* } } - fn source(&self) -> Option<&dyn pg_diagnostics::Diagnostic> { + fn source(&self) -> Option<&dyn pglt_diagnostics::Diagnostic> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::source(error),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::source(error),)* } } - fn advices(&self, visitor: &mut dyn pg_diagnostics::Visit) -> std::io::Result<()> { + fn advices(&self, visitor: &mut dyn pglt_diagnostics::Visit) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::advices(error, visitor),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::advices(error, visitor),)* } } - fn verbose_advices(&self, visitor: &mut dyn pg_diagnostics::Visit) -> std::io::Result<()> { + fn verbose_advices(&self, visitor: &mut dyn pglt_diagnostics::Visit) -> std::io::Result<()> { match self { - #(Self::#variants(error) => pg_diagnostics::Diagnostic::verbose_advices(error, visitor),)* + #(Self::#variants(error) => pglt_diagnostics::Diagnostic::verbose_advices(error, visitor),)* } } } diff --git a/crates/pg_diagnostics_macros/src/lib.rs b/crates/pglt_diagnostics_macros/src/lib.rs similarity index 100% rename from crates/pg_diagnostics_macros/src/lib.rs rename to crates/pglt_diagnostics_macros/src/lib.rs diff --git a/crates/pg_diagnostics_macros/src/parse.rs b/crates/pglt_diagnostics_macros/src/parse.rs similarity index 100% rename from crates/pg_diagnostics_macros/src/parse.rs rename to crates/pglt_diagnostics_macros/src/parse.rs diff --git a/crates/pg_flags/Cargo.toml b/crates/pglt_flags/Cargo.toml similarity index 81% rename from crates/pg_flags/Cargo.toml rename to crates/pglt_flags/Cargo.toml index 17277a3aa..eac82a48a 100644 --- a/crates/pg_flags/Cargo.toml +++ b/crates/pglt_flags/Cargo.toml @@ -6,13 +6,13 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_flags" +name = "pglt_flags" repository.workspace = true version = "0.0.0" [dependencies] -pg_console = { workspace = true } +pglt_console = { workspace = true } [dev-dependencies] diff --git a/crates/pg_flags/src/lib.rs b/crates/pglt_flags/src/lib.rs similarity index 97% rename from crates/pg_flags/src/lib.rs rename to crates/pglt_flags/src/lib.rs index 864ea6a6a..ad293db3a 100644 --- a/crates/pg_flags/src/lib.rs +++ b/crates/pglt_flags/src/lib.rs @@ -1,7 +1,7 @@ //! A simple implementation of feature flags. -use pg_console::fmt::{Display, Formatter}; -use pg_console::{markup, DebugDisplay, KeyValuePair}; +use pglt_console::fmt::{Display, Formatter}; +use pglt_console::{markup, DebugDisplay, KeyValuePair}; use std::env; use std::ops::Deref; use std::sync::{LazyLock, OnceLock}; diff --git a/crates/pglt_fs/Cargo.toml b/crates/pglt_fs/Cargo.toml new file mode 100644 index 000000000..11edb8778 --- /dev/null +++ b/crates/pglt_fs/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pglt_fs" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +crossbeam = { workspace = true } +directories = "5.0.1" +enumflags2 = { workspace = true } +parking_lot = { version = "0.12.3", features = ["arc_lock"] } +pglt_diagnostics = { workspace = true } +rayon = { workspace = true } +rustc-hash = { workspace = true } +schemars = { workspace = true, optional = true } +serde = { workspace = true } +smallvec = { workspace = true } +tracing = { workspace = true } + +[features] +serde = ["schemars", "pglt_diagnostics/schema"] + +[dev-dependencies] + +[lib] +doctest = false diff --git a/crates/pg_fs/src/dir.rs b/crates/pglt_fs/src/dir.rs similarity index 100% rename from crates/pg_fs/src/dir.rs rename to crates/pglt_fs/src/dir.rs diff --git a/crates/pg_fs/src/fs.rs b/crates/pglt_fs/src/fs.rs similarity index 99% rename from crates/pg_fs/src/fs.rs rename to crates/pglt_fs/src/fs.rs index 9771a0c6c..30f9cea7d 100644 --- a/crates/pg_fs/src/fs.rs +++ b/crates/pglt_fs/src/fs.rs @@ -1,8 +1,8 @@ use crate::{PathInterner, PgLspPath}; pub use memory::{ErrorEntry, MemoryFileSystem}; pub use os::OsFileSystem; -use pg_diagnostics::{console, Advices, Diagnostic, LogCategory, Visit}; -use pg_diagnostics::{Error, Severity}; +use pglt_diagnostics::{console, Advices, Diagnostic, LogCategory, Visit}; +use pglt_diagnostics::{Error, Severity}; use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; use std::fmt::{Debug, Display, Formatter}; diff --git a/crates/pg_fs/src/fs/memory.rs b/crates/pglt_fs/src/fs/memory.rs similarity index 99% rename from crates/pg_fs/src/fs/memory.rs rename to crates/pglt_fs/src/fs/memory.rs index cd8072703..e6b58a436 100644 --- a/crates/pg_fs/src/fs/memory.rs +++ b/crates/pglt_fs/src/fs/memory.rs @@ -7,7 +7,7 @@ use std::str; use std::sync::Arc; use parking_lot::{lock_api::ArcMutexGuard, Mutex, RawMutex, RwLock}; -use pg_diagnostics::{Error, Severity}; +use pglt_diagnostics::{Error, Severity}; use crate::fs::OpenOptions; use crate::{FileSystem, PgLspPath, TraversalContext, TraversalScope}; @@ -342,7 +342,7 @@ mod tests { }; use parking_lot::Mutex; - use pg_diagnostics::Error; + use pglt_diagnostics::Error; use crate::{fs::FileSystemExt, OpenOptions}; use crate::{FileSystem, MemoryFileSystem, PathInterner, PgLspPath, TraversalContext}; diff --git a/crates/pg_fs/src/fs/os.rs b/crates/pglt_fs/src/fs/os.rs similarity index 99% rename from crates/pg_fs/src/fs/os.rs rename to crates/pglt_fs/src/fs/os.rs index d5353f550..fce0d8f70 100644 --- a/crates/pg_fs/src/fs/os.rs +++ b/crates/pglt_fs/src/fs/os.rs @@ -5,7 +5,7 @@ use crate::{ fs::{TraversalContext, TraversalScope}, FileSystem, PgLspPath, }; -use pg_diagnostics::{adapters::IoError, DiagnosticExt, Error, Severity}; +use pglt_diagnostics::{adapters::IoError, DiagnosticExt, Error, Severity}; use rayon::{scope, Scope}; use std::fs::{DirEntry, FileType}; use std::process::Command; diff --git a/crates/pg_fs/src/interner.rs b/crates/pglt_fs/src/interner.rs similarity index 100% rename from crates/pg_fs/src/interner.rs rename to crates/pglt_fs/src/interner.rs diff --git a/crates/pg_fs/src/lib.rs b/crates/pglt_fs/src/lib.rs similarity index 95% rename from crates/pg_fs/src/lib.rs rename to crates/pglt_fs/src/lib.rs index 660d9a6d2..7c225058c 100644 --- a/crates/pg_fs/src/lib.rs +++ b/crates/pglt_fs/src/lib.rs @@ -1,4 +1,4 @@ -//! # pg_fs +//! # pglt_fs mod dir; mod fs; diff --git a/crates/pg_fs/src/path.rs b/crates/pglt_fs/src/path.rs similarity index 100% rename from crates/pg_fs/src/path.rs rename to crates/pglt_fs/src/path.rs diff --git a/crates/pg_lexer/Cargo.toml b/crates/pglt_lexer/Cargo.toml similarity index 81% rename from crates/pg_lexer/Cargo.toml rename to crates/pglt_lexer/Cargo.toml index db5a18fa1..efa02bd1b 100644 --- a/crates/pg_lexer/Cargo.toml +++ b/crates/pglt_lexer/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_lexer" +name = "pglt_lexer" repository.workspace = true version = "0.0.0" @@ -14,8 +14,8 @@ version = "0.0.0" [dependencies] regex = "1.9.1" -pg_lexer_codegen.workspace = true -pg_query.workspace = true +pg_query.workspace = true +pglt_lexer_codegen.workspace = true cstree = { version = "0.12.0", features = ["derive"] } text-size.workspace = true diff --git a/crates/pg_lexer/README.md b/crates/pglt_lexer/README.md similarity index 69% rename from crates/pg_lexer/README.md rename to crates/pglt_lexer/README.md index 2945d0268..5fbc58f70 100644 --- a/crates/pg_lexer/README.md +++ b/crates/pglt_lexer/README.md @@ -1,6 +1,6 @@ -# pg_lexer +# pglt_lexer -The `pg_lexer` crate exposes the `lex` method, which turns an SQL query text into a `Vec>`: the base for the `pg_parser` and most of pgtools's operations. +The `pglt_lexer` crate exposes the `lex` method, which turns an SQL query text into a `Vec>`: the base for the `pg_parser` and most of pgtools's operations. A token is always of a certain `SyntaxKind` kind. That `SyntaxKind` enum is derived from `libpg_query`'s protobuf file. diff --git a/crates/pglt_lexer/src/codegen.rs b/crates/pglt_lexer/src/codegen.rs new file mode 100644 index 000000000..a32b41fa0 --- /dev/null +++ b/crates/pglt_lexer/src/codegen.rs @@ -0,0 +1,3 @@ +use pglt_lexer_codegen::lexer_codegen; + +lexer_codegen!(); diff --git a/crates/pg_lexer/src/lib.rs b/crates/pglt_lexer/src/lib.rs similarity index 91% rename from crates/pg_lexer/src/lib.rs rename to crates/pglt_lexer/src/lib.rs index 225e32c2a..82edebfe6 100644 --- a/crates/pg_lexer/src/lib.rs +++ b/crates/pglt_lexer/src/lib.rs @@ -111,7 +111,7 @@ pub fn lex(text: &str) -> Vec { let mut whitespace_tokens = whitespace_tokens(text); // tokens from pg_query.rs - let mut pg_query_tokens = match pg_query::scan(text) { + let mut pglt_query_tokens = match pg_query::scan(text) { Ok(scanned) => VecDeque::from(scanned.tokens), // this _should_ never fail _ => panic!("pg_query::scan failed"), @@ -122,24 +122,24 @@ pub fn lex(text: &str) -> Vec { let mut pos = TextSize::from(0); while pos < text.text_len() { - if !pg_query_tokens.is_empty() - && TextSize::from(u32::try_from(pg_query_tokens[0].start).unwrap()) == pos + if !pglt_query_tokens.is_empty() + && TextSize::from(u32::try_from(pglt_query_tokens[0].start).unwrap()) == pos { - let pg_query_token = pg_query_tokens.pop_front().unwrap(); + let pglt_query_token = pglt_query_tokens.pop_front().unwrap(); // the lexer returns byte indices, so we need to slice - let token_text = &text[usize::try_from(pg_query_token.start).unwrap() - ..usize::try_from(pg_query_token.end).unwrap()]; + let token_text = &text[usize::try_from(pglt_query_token.start).unwrap() + ..usize::try_from(pglt_query_token.end).unwrap()]; let len = token_text.text_len(); let has_whitespace = token_text.contains(" ") || token_text.contains("\n"); tokens.push(Token { - token_type: TokenType::from(&pg_query_token), - kind: SyntaxKind::from(&pg_query_token), + token_type: TokenType::from(&pglt_query_token), + kind: SyntaxKind::from(&pglt_query_token), text: token_text.to_string(), span: TextRange::new( - TextSize::from(u32::try_from(pg_query_token.start).unwrap()), - TextSize::from(u32::try_from(pg_query_token.end).unwrap()), + TextSize::from(u32::try_from(pglt_query_token.start).unwrap()), + TextSize::from(u32::try_from(pglt_query_token.end).unwrap()), ), }); pos += len; diff --git a/crates/pg_lexer_codegen/Cargo.toml b/crates/pglt_lexer_codegen/Cargo.toml similarity index 66% rename from crates/pg_lexer_codegen/Cargo.toml rename to crates/pglt_lexer_codegen/Cargo.toml index 854919cdb..a7d18fd8f 100644 --- a/crates/pg_lexer_codegen/Cargo.toml +++ b/crates/pglt_lexer_codegen/Cargo.toml @@ -6,15 +6,15 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_lexer_codegen" +name = "pglt_lexer_codegen" repository.workspace = true version = "0.0.0" [dependencies] -pg_query_proto_parser.workspace = true -proc-macro2.workspace = true -quote = "1.0.33" +pglt_query_proto_parser.workspace = true +proc-macro2.workspace = true +quote = "1.0.33" [lib] doctest = false diff --git a/crates/pg_lexer_codegen/README.md b/crates/pglt_lexer_codegen/README.md similarity index 94% rename from crates/pg_lexer_codegen/README.md rename to crates/pglt_lexer_codegen/README.md index 76642e268..c6a123c10 100644 --- a/crates/pg_lexer_codegen/README.md +++ b/crates/pglt_lexer_codegen/README.md @@ -1,4 +1,4 @@ -# pg_lexer_codegen +# pglt_lexer_codegen This crate is responsible for reading `libpg_query`'s protobuf file and turning it into the Rust enum `SyntaxKind`. diff --git a/crates/pg_lexer_codegen/src/lib.rs b/crates/pglt_lexer_codegen/src/lib.rs similarity index 94% rename from crates/pg_lexer_codegen/src/lib.rs rename to crates/pglt_lexer_codegen/src/lib.rs index c041a29a1..99a35aa5d 100644 --- a/crates/pg_lexer_codegen/src/lib.rs +++ b/crates/pglt_lexer_codegen/src/lib.rs @@ -1,6 +1,6 @@ mod syntax_kind; -use pg_query_proto_parser::ProtoParser; +use pglt_query_proto_parser::ProtoParser; use quote::quote; use std::{env, path, path::Path}; diff --git a/crates/pg_lexer_codegen/src/syntax_kind.rs b/crates/pglt_lexer_codegen/src/syntax_kind.rs similarity index 98% rename from crates/pg_lexer_codegen/src/syntax_kind.rs rename to crates/pglt_lexer_codegen/src/syntax_kind.rs index ef335296d..4bb28d123 100644 --- a/crates/pg_lexer_codegen/src/syntax_kind.rs +++ b/crates/pglt_lexer_codegen/src/syntax_kind.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use pg_query_proto_parser::{Node, ProtoFile, Token}; +use pglt_query_proto_parser::{Node, ProtoFile, Token}; use proc_macro2::{Ident, Literal}; use quote::{format_ident, quote}; diff --git a/crates/pg_lsp/Cargo.toml b/crates/pglt_lsp/Cargo.toml similarity index 66% rename from crates/pg_lsp/Cargo.toml rename to crates/pglt_lsp/Cargo.toml index 88faf0228..e8e6dc249 100644 --- a/crates/pg_lsp/Cargo.toml +++ b/crates/pglt_lsp/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_lsp" +name = "pglt_lsp" repository.workspace = true version = "0.0.0" @@ -15,15 +15,15 @@ version = "0.0.0" anyhow = { workspace = true } biome_deserialize = { workspace = true } futures = "0.3.31" -pg_analyse = { workspace = true } -pg_completions = { workspace = true } -pg_configuration = { workspace = true } -pg_console = { workspace = true } -pg_diagnostics = { workspace = true } -pg_fs = { workspace = true } -pg_lsp_converters = { workspace = true } -pg_text_edit = { workspace = true } -pg_workspace = { workspace = true } +pglt_analyse = { workspace = true } +pglt_completions = { workspace = true } +pglt_configuration = { workspace = true } +pglt_console = { workspace = true } +pglt_diagnostics = { workspace = true } +pglt_fs = { workspace = true } +pglt_lsp_converters = { workspace = true } +pglt_text_edit = { workspace = true } +pglt_workspace = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } diff --git a/crates/pg_lsp/src/capabilities.rs b/crates/pglt_lsp/src/capabilities.rs similarity index 96% rename from crates/pg_lsp/src/capabilities.rs rename to crates/pglt_lsp/src/capabilities.rs index a3b2ecb57..0a1adc05e 100644 --- a/crates/pg_lsp/src/capabilities.rs +++ b/crates/pglt_lsp/src/capabilities.rs @@ -1,4 +1,4 @@ -use pg_lsp_converters::{negotiated_encoding, PositionEncoding, WideEncoding}; +use pglt_lsp_converters::{negotiated_encoding, PositionEncoding, WideEncoding}; use tower_lsp::lsp_types::{ ClientCapabilities, CompletionOptions, PositionEncodingKind, SaveOptions, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, diff --git a/crates/pg_lsp/src/diagnostics.rs b/crates/pglt_lsp/src/diagnostics.rs similarity index 90% rename from crates/pg_lsp/src/diagnostics.rs rename to crates/pglt_lsp/src/diagnostics.rs index a0a04144a..efb086ea7 100644 --- a/crates/pg_lsp/src/diagnostics.rs +++ b/crates/pglt_lsp/src/diagnostics.rs @@ -1,7 +1,7 @@ use crate::utils::into_lsp_error; use anyhow::Error; -use pg_diagnostics::print_diagnostic_to_string; -use pg_workspace::WorkspaceError; +use pglt_diagnostics::print_diagnostic_to_string; +use pglt_workspace::WorkspaceError; use std::fmt::{Display, Formatter}; use tower_lsp::lsp_types::MessageType; @@ -9,7 +9,7 @@ use tower_lsp::lsp_types::MessageType; pub enum LspError { WorkspaceError(WorkspaceError), Anyhow(anyhow::Error), - Error(pg_diagnostics::Error), + Error(pglt_diagnostics::Error), } impl From for LspError { @@ -18,8 +18,8 @@ impl From for LspError { } } -impl From for LspError { - fn from(value: pg_diagnostics::Error) -> Self { +impl From for LspError { + fn from(value: pglt_diagnostics::Error) -> Self { Self::Error(value) } } diff --git a/crates/pg_lsp/src/documents.rs b/crates/pglt_lsp/src/documents.rs similarity index 91% rename from crates/pg_lsp/src/documents.rs rename to crates/pglt_lsp/src/documents.rs index c32da8089..ea5dce5f5 100644 --- a/crates/pg_lsp/src/documents.rs +++ b/crates/pglt_lsp/src/documents.rs @@ -1,4 +1,4 @@ -use pg_lsp_converters::line_index::LineIndex; +use pglt_lsp_converters::line_index::LineIndex; /// Represents an open [`textDocument`]. Can be cheaply cloned. /// diff --git a/crates/pg_lsp/src/handlers.rs b/crates/pglt_lsp/src/handlers.rs similarity index 100% rename from crates/pg_lsp/src/handlers.rs rename to crates/pglt_lsp/src/handlers.rs diff --git a/crates/pg_lsp/src/handlers/completions.rs b/crates/pglt_lsp/src/handlers/completions.rs similarity index 78% rename from crates/pg_lsp/src/handlers/completions.rs rename to crates/pglt_lsp/src/handlers/completions.rs index 83ade9f48..1adaa52a4 100644 --- a/crates/pg_lsp/src/handlers/completions.rs +++ b/crates/pglt_lsp/src/handlers/completions.rs @@ -1,6 +1,6 @@ use crate::session::Session; use anyhow::Result; -use pg_workspace::{workspace, WorkspaceError}; +use pglt_workspace::{workspace, WorkspaceError}; use tower_lsp::lsp_types::{self, CompletionItem, CompletionItemLabelDetails}; #[tracing::instrument(level = "trace", skip_all)] @@ -20,10 +20,10 @@ pub fn get_completions( .map(|doc| doc.line_index) .map_err(|_| anyhow::anyhow!("Document not found."))?; - let offset = pg_lsp_converters::from_proto::offset( + let offset = pglt_lsp_converters::from_proto::offset( &line_index, params.text_document_position.position, - pg_lsp_converters::negotiated_encoding(client_capabilities), + pglt_lsp_converters::negotiated_encoding(client_capabilities), )?; let completion_result = match session @@ -61,11 +61,11 @@ pub fn get_completions( } fn to_lsp_types_completion_item_kind( - pg_comp_kind: pg_completions::CompletionItemKind, + pg_comp_kind: pglt_completions::CompletionItemKind, ) -> lsp_types::CompletionItemKind { match pg_comp_kind { - pg_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION, - pg_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS, - pg_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD, + pglt_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION, + pglt_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS, + pglt_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD, } } diff --git a/crates/pg_lsp/src/handlers/text_document.rs b/crates/pglt_lsp/src/handlers/text_document.rs similarity index 97% rename from crates/pg_lsp/src/handlers/text_document.rs rename to crates/pglt_lsp/src/handlers/text_document.rs index da75dc2f2..bd30f8406 100644 --- a/crates/pg_lsp/src/handlers/text_document.rs +++ b/crates/pglt_lsp/src/handlers/text_document.rs @@ -2,8 +2,8 @@ use crate::{ diagnostics::LspError, documents::Document, session::Session, utils::apply_document_changes, }; use anyhow::Result; -use pg_lsp_converters::from_proto::text_range; -use pg_workspace::workspace::{ +use pglt_lsp_converters::from_proto::text_range; +use pglt_workspace::workspace::{ ChangeFileParams, ChangeParams, CloseFileParams, GetFileContentParams, OpenFileParams, }; use tower_lsp::lsp_types; diff --git a/crates/pg_lsp/src/lib.rs b/crates/pglt_lsp/src/lib.rs similarity index 100% rename from crates/pg_lsp/src/lib.rs rename to crates/pglt_lsp/src/lib.rs diff --git a/crates/pg_lsp/src/server.rs b/crates/pglt_lsp/src/server.rs similarity index 98% rename from crates/pg_lsp/src/server.rs rename to crates/pglt_lsp/src/server.rs index d07dab9e3..697c1f287 100644 --- a/crates/pg_lsp/src/server.rs +++ b/crates/pglt_lsp/src/server.rs @@ -7,9 +7,9 @@ use crate::session::{ use crate::utils::{into_lsp_error, panic_to_lsp_error}; use futures::future::ready; use futures::FutureExt; -use pg_diagnostics::panic::PanicError; -use pg_fs::{ConfigName, FileSystem, OsFileSystem}; -use pg_workspace::{workspace, DynRef, Workspace}; +use pglt_diagnostics::panic::PanicError; +use pglt_fs::{ConfigName, FileSystem, OsFileSystem}; +use pglt_workspace::{workspace, DynRef, Workspace}; use rustc_hash::FxHashMap; use serde_json::json; use std::panic::RefUnwindSafe; @@ -136,7 +136,7 @@ impl LanguageServer for LSPServer { capabilities: server_capabilities, server_info: Some(ServerInfo { name: String::from(env!("CARGO_PKG_NAME")), - version: Some(pg_configuration::VERSION.to_string()), + version: Some(pglt_configuration::VERSION.to_string()), }), }; diff --git a/crates/pg_lsp/src/session.rs b/crates/pglt_lsp/src/session.rs similarity index 97% rename from crates/pg_lsp/src/session.rs rename to crates/pglt_lsp/src/session.rs index d8379617b..b592de48e 100644 --- a/crates/pg_lsp/src/session.rs +++ b/crates/pglt_lsp/src/session.rs @@ -4,16 +4,16 @@ use crate::utils; use anyhow::Result; use futures::stream::FuturesUnordered; use futures::StreamExt; -use pg_analyse::RuleCategoriesBuilder; -use pg_configuration::ConfigurationPathHint; -use pg_diagnostics::{DiagnosticExt, Error}; -use pg_fs::{FileSystem, PgLspPath}; -use pg_lsp_converters::{negotiated_encoding, PositionEncoding, WideEncoding}; -use pg_workspace::configuration::{load_configuration, LoadedConfiguration}; -use pg_workspace::settings::PartialConfigurationExt; -use pg_workspace::workspace::{PullDiagnosticsParams, UpdateSettingsParams}; -use pg_workspace::Workspace; -use pg_workspace::{DynRef, WorkspaceError}; +use pglt_analyse::RuleCategoriesBuilder; +use pglt_configuration::ConfigurationPathHint; +use pglt_diagnostics::{DiagnosticExt, Error}; +use pglt_fs::{FileSystem, PgLspPath}; +use pglt_lsp_converters::{negotiated_encoding, PositionEncoding, WideEncoding}; +use pglt_workspace::configuration::{load_configuration, LoadedConfiguration}; +use pglt_workspace::settings::PartialConfigurationExt; +use pglt_workspace::workspace::{PullDiagnosticsParams, UpdateSettingsParams}; +use pglt_workspace::Workspace; +use pglt_workspace::{DynRef, WorkspaceError}; use rustc_hash::FxHashMap; use serde_json::Value; use std::path::PathBuf; diff --git a/crates/pg_lsp/src/utils.rs b/crates/pglt_lsp/src/utils.rs similarity index 95% rename from crates/pg_lsp/src/utils.rs rename to crates/pglt_lsp/src/utils.rs index 33eef1f70..f752636ac 100644 --- a/crates/pg_lsp/src/utils.rs +++ b/crates/pglt_lsp/src/utils.rs @@ -1,12 +1,12 @@ use anyhow::{ensure, Context, Result}; -use pg_console::fmt::Termcolor; -use pg_console::fmt::{self, Formatter}; -use pg_console::MarkupBuf; -use pg_diagnostics::termcolor::NoColor; -use pg_diagnostics::{Diagnostic, DiagnosticTags, Location, PrintDescription, Severity, Visit}; -use pg_lsp_converters::line_index::LineIndex; -use pg_lsp_converters::{from_proto, to_proto, PositionEncoding}; -use pg_text_edit::{CompressedOp, DiffOp, TextEdit}; +use pglt_console::fmt::Termcolor; +use pglt_console::fmt::{self, Formatter}; +use pglt_console::MarkupBuf; +use pglt_diagnostics::termcolor::NoColor; +use pglt_diagnostics::{Diagnostic, DiagnosticTags, Location, PrintDescription, Severity, Visit}; +use pglt_lsp_converters::line_index::LineIndex; +use pglt_lsp_converters::{from_proto, to_proto, PositionEncoding}; +use pglt_text_edit::{CompressedOp, DiffOp, TextEdit}; use std::any::Any; use std::borrow::Cow; use std::fmt::{Debug, Display}; @@ -86,7 +86,7 @@ pub(crate) fn text_edit( Ok(result) } -/// Convert an [pg_diagnostics::Diagnostic] to a [lsp::Diagnostic], using the span +/// Convert an [pglt_diagnostics::Diagnostic] to a [lsp::Diagnostic], using the span /// of the diagnostic's primary label as the diagnostic range. /// Requires a [LineIndex] to convert a byte offset range to the line/col range /// expected by LSP. @@ -305,9 +305,9 @@ pub(crate) fn apply_document_changes( #[cfg(test)] mod tests { - use pg_lsp_converters::line_index::LineIndex; - use pg_lsp_converters::PositionEncoding; - use pg_text_edit::TextEdit; + use pglt_lsp_converters::line_index::LineIndex; + use pglt_lsp_converters::PositionEncoding; + use pglt_text_edit::TextEdit; use tower_lsp::lsp_types as lsp; #[test] diff --git a/crates/pg_lsp_converters/Cargo.toml b/crates/pglt_lsp_converters/Cargo.toml similarity index 91% rename from crates/pg_lsp_converters/Cargo.toml rename to crates/pglt_lsp_converters/Cargo.toml index e4e7e2852..48687ba3a 100644 --- a/crates/pg_lsp_converters/Cargo.toml +++ b/crates/pglt_lsp_converters/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_lsp_converters" +name = "pglt_lsp_converters" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_lsp_converters/src/from_proto.rs b/crates/pglt_lsp_converters/src/from_proto.rs similarity index 100% rename from crates/pg_lsp_converters/src/from_proto.rs rename to crates/pglt_lsp_converters/src/from_proto.rs diff --git a/crates/pg_lsp_converters/src/lib.rs b/crates/pglt_lsp_converters/src/lib.rs similarity index 100% rename from crates/pg_lsp_converters/src/lib.rs rename to crates/pglt_lsp_converters/src/lib.rs diff --git a/crates/pg_lsp_converters/src/line_index.rs b/crates/pglt_lsp_converters/src/line_index.rs similarity index 100% rename from crates/pg_lsp_converters/src/line_index.rs rename to crates/pglt_lsp_converters/src/line_index.rs diff --git a/crates/pg_lsp_converters/src/to_proto.rs b/crates/pglt_lsp_converters/src/to_proto.rs similarity index 100% rename from crates/pg_lsp_converters/src/to_proto.rs rename to crates/pglt_lsp_converters/src/to_proto.rs diff --git a/crates/pg_markup/Cargo.toml b/crates/pglt_markup/Cargo.toml similarity index 92% rename from crates/pg_markup/Cargo.toml rename to crates/pglt_markup/Cargo.toml index 2b76998e9..80ef7ed24 100644 --- a/crates/pg_markup/Cargo.toml +++ b/crates/pglt_markup/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_markup" +name = "pglt_markup" repository.workspace = true version = "0.0.0" diff --git a/crates/pglt_markup/README.md b/crates/pglt_markup/README.md new file mode 100644 index 000000000..b5dde5213 --- /dev/null +++ b/crates/pglt_markup/README.md @@ -0,0 +1,10 @@ +# `pglt_markup` + +The crate contains procedural macros to build `pglt_console` markup object with a JSX-like syntax + +The macro cannot be used alone as it generates code that requires supporting types declared in the +`pglt_console` crate, so it's re-exported from there and should be used as `pglt_console::markup` + +## Acknowledgement + +This crate was initially forked from [biome](https://github.com/biomejs/biome). diff --git a/crates/pg_markup/src/lib.rs b/crates/pglt_markup/src/lib.rs similarity index 95% rename from crates/pg_markup/src/lib.rs rename to crates/pglt_markup/src/lib.rs index bcd3d86cf..c79b7cd59 100644 --- a/crates/pg_markup/src/lib.rs +++ b/crates/pglt_markup/src/lib.rs @@ -11,7 +11,7 @@ impl ToTokens for StackEntry { fn to_tokens(&self, tokens: &mut TokenStream) { let name = &self.name; tokens.extend(quote! { - pg_console::MarkupElement::#name + pglt_console::MarkupElement::#name }); if !self.attributes.is_empty() { @@ -137,7 +137,7 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { .collect(); output.push(quote! { - pg_console::MarkupNode { + pglt_console::MarkupNode { elements: &[ #( #elements ),* ], content: &(#literal), } @@ -149,9 +149,9 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let body = group.stream(); output.push(quote! { - pg_console::MarkupNode { + pglt_console::MarkupNode { elements: &[ #( #elements ),* ], - content: &(#body) as &dyn pg_console::fmt::Display, + content: &(#body) as &dyn pglt_console::fmt::Display, } }); } @@ -165,5 +165,5 @@ pub fn markup(input: proc_macro::TokenStream) -> proc_macro::TokenStream { abort!(top.name.span(), "unclosed element"); } - quote! { pg_console::Markup(&[ #( #output ),* ]) }.into() + quote! { pglt_console::Markup(&[ #( #output ),* ]) }.into() } diff --git a/crates/pg_query_ext/Cargo.toml b/crates/pglt_query_ext/Cargo.toml similarity index 58% rename from crates/pg_query_ext/Cargo.toml rename to crates/pglt_query_ext/Cargo.toml index 5ff3a493a..99e94ee65 100644 --- a/crates/pg_query_ext/Cargo.toml +++ b/crates/pglt_query_ext/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_query_ext" +name = "pglt_query_ext" repository.workspace = true version = "0.0.0" @@ -14,11 +14,11 @@ version = "0.0.0" [dependencies] petgraph = "0.6.4" -pg_diagnostics.workspace = true -pg_lexer.workspace = true -pg_query.workspace = true -pg_query_ext_codegen.workspace = true -text-size.workspace = true +pg_query.workspace = true +pglt_diagnostics.workspace = true +pglt_lexer.workspace = true +pglt_query_ext_codegen.workspace = true +text-size.workspace = true [lib] doctest = false diff --git a/crates/pglt_query_ext/src/codegen.rs b/crates/pglt_query_ext/src/codegen.rs new file mode 100644 index 000000000..234ff5fe2 --- /dev/null +++ b/crates/pglt_query_ext/src/codegen.rs @@ -0,0 +1 @@ +pglt_query_ext_codegen::codegen!(); diff --git a/crates/pg_query_ext/src/diagnostics.rs b/crates/pglt_query_ext/src/diagnostics.rs similarity index 91% rename from crates/pg_query_ext/src/diagnostics.rs rename to crates/pglt_query_ext/src/diagnostics.rs index 2096f9cf7..a091dc978 100644 --- a/crates/pg_query_ext/src/diagnostics.rs +++ b/crates/pglt_query_ext/src/diagnostics.rs @@ -1,4 +1,4 @@ -use pg_diagnostics::{Diagnostic, MessageAndDescription}; +use pglt_diagnostics::{Diagnostic, MessageAndDescription}; use text_size::TextRange; /// A specialized diagnostic for the libpg_query parser. diff --git a/crates/pg_query_ext/src/lib.rs b/crates/pglt_query_ext/src/lib.rs similarity index 100% rename from crates/pg_query_ext/src/lib.rs rename to crates/pglt_query_ext/src/lib.rs diff --git a/crates/pg_query_ext_codegen/Cargo.toml b/crates/pglt_query_ext_codegen/Cargo.toml similarity index 81% rename from crates/pg_query_ext_codegen/Cargo.toml rename to crates/pglt_query_ext_codegen/Cargo.toml index 9098a4d54..b1cf57173 100644 --- a/crates/pg_query_ext_codegen/Cargo.toml +++ b/crates/pglt_query_ext_codegen/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_query_ext_codegen" +name = "pglt_query_ext_codegen" repository.workspace = true version = "0.0.0" @@ -15,7 +15,7 @@ version = "0.0.0" proc-macro2.workspace = true quote.workspace = true -pg_query_proto_parser.workspace = true +pglt_query_proto_parser.workspace = true [lib] doctest = false diff --git a/crates/pg_query_ext_codegen/src/get_location.rs b/crates/pglt_query_ext_codegen/src/get_location.rs similarity index 98% rename from crates/pg_query_ext_codegen/src/get_location.rs rename to crates/pglt_query_ext_codegen/src/get_location.rs index 507a5dacd..4a4476004 100644 --- a/crates/pg_query_ext_codegen/src/get_location.rs +++ b/crates/pglt_query_ext_codegen/src/get_location.rs @@ -1,4 +1,4 @@ -use pg_query_proto_parser::{FieldType, Node, ProtoFile}; +use pglt_query_proto_parser::{FieldType, Node, ProtoFile}; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; diff --git a/crates/pg_query_ext_codegen/src/get_node_properties.rs b/crates/pglt_query_ext_codegen/src/get_node_properties.rs similarity index 99% rename from crates/pg_query_ext_codegen/src/get_node_properties.rs rename to crates/pglt_query_ext_codegen/src/get_node_properties.rs index 455d4fc9b..1f2689d2a 100644 --- a/crates/pg_query_ext_codegen/src/get_node_properties.rs +++ b/crates/pglt_query_ext_codegen/src/get_node_properties.rs @@ -1,4 +1,4 @@ -use pg_query_proto_parser::{FieldType, Node, ProtoFile}; +use pglt_query_proto_parser::{FieldType, Node, ProtoFile}; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; diff --git a/crates/pg_query_ext_codegen/src/get_nodes.rs b/crates/pglt_query_ext_codegen/src/get_nodes.rs similarity index 98% rename from crates/pg_query_ext_codegen/src/get_nodes.rs rename to crates/pglt_query_ext_codegen/src/get_nodes.rs index c097773de..2ae47b585 100644 --- a/crates/pg_query_ext_codegen/src/get_nodes.rs +++ b/crates/pglt_query_ext_codegen/src/get_nodes.rs @@ -1,4 +1,4 @@ -use pg_query_proto_parser::{FieldType, Node, ProtoFile}; +use pglt_query_proto_parser::{FieldType, Node, ProtoFile}; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; diff --git a/crates/pg_query_ext_codegen/src/lib.rs b/crates/pglt_query_ext_codegen/src/lib.rs similarity index 94% rename from crates/pg_query_ext_codegen/src/lib.rs rename to crates/pglt_query_ext_codegen/src/lib.rs index 16e87d7a2..599aff056 100644 --- a/crates/pg_query_ext_codegen/src/lib.rs +++ b/crates/pglt_query_ext_codegen/src/lib.rs @@ -7,7 +7,7 @@ use get_location::get_location_mod; use get_node_properties::get_node_properties_mod; use get_nodes::get_nodes_mod; use node_iterator::node_iterator_mod; -use pg_query_proto_parser::ProtoParser; +use pglt_query_proto_parser::ProtoParser; use quote::quote; use std::{env, path, path::Path}; @@ -22,7 +22,7 @@ pub fn codegen(_input: proc_macro::TokenStream) -> proc_macro::TokenStream { let iterator = node_iterator_mod(&proto_file); quote! { - use pg_lexer::SyntaxKind; + use pglt_lexer::SyntaxKind; use std::collections::VecDeque; use pg_query::{protobuf, protobuf::ScanToken, protobuf::Token, NodeEnum, NodeRef}; use std::cmp::{min, Ordering}; diff --git a/crates/pg_query_ext_codegen/src/node_iterator.rs b/crates/pglt_query_ext_codegen/src/node_iterator.rs similarity index 98% rename from crates/pg_query_ext_codegen/src/node_iterator.rs rename to crates/pglt_query_ext_codegen/src/node_iterator.rs index 7b0187d5c..b2a880aa1 100644 --- a/crates/pg_query_ext_codegen/src/node_iterator.rs +++ b/crates/pglt_query_ext_codegen/src/node_iterator.rs @@ -1,4 +1,4 @@ -use pg_query_proto_parser::{FieldType, Node, ProtoFile}; +use pglt_query_proto_parser::{FieldType, Node, ProtoFile}; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; diff --git a/crates/pg_query_proto_parser/Cargo.toml b/crates/pglt_query_proto_parser/Cargo.toml similarity index 88% rename from crates/pg_query_proto_parser/Cargo.toml rename to crates/pglt_query_proto_parser/Cargo.toml index b63496d24..8ddd6528a 100644 --- a/crates/pg_query_proto_parser/Cargo.toml +++ b/crates/pglt_query_proto_parser/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_query_proto_parser" +name = "pglt_query_proto_parser" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_query_proto_parser/src/lib.rs b/crates/pglt_query_proto_parser/src/lib.rs similarity index 100% rename from crates/pg_query_proto_parser/src/lib.rs rename to crates/pglt_query_proto_parser/src/lib.rs diff --git a/crates/pg_query_proto_parser/src/proto_file.rs b/crates/pglt_query_proto_parser/src/proto_file.rs similarity index 100% rename from crates/pg_query_proto_parser/src/proto_file.rs rename to crates/pglt_query_proto_parser/src/proto_file.rs diff --git a/crates/pg_query_proto_parser/src/proto_parser.rs b/crates/pglt_query_proto_parser/src/proto_parser.rs similarity index 100% rename from crates/pg_query_proto_parser/src/proto_parser.rs rename to crates/pglt_query_proto_parser/src/proto_parser.rs diff --git a/crates/pglt_schema_cache/Cargo.toml b/crates/pglt_schema_cache/Cargo.toml new file mode 100644 index 000000000..076157c0f --- /dev/null +++ b/crates/pglt_schema_cache/Cargo.toml @@ -0,0 +1,29 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pglt_schema_cache" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +anyhow.workspace = true +async-std = { version = "1.12.0" } +futures-util = "0.3.31" +pglt_console.workspace = true +pglt_diagnostics.workspace = true +serde.workspace = true +serde_json.workspace = true +sqlx.workspace = true +tokio.workspace = true + +[dev-dependencies] +pglt_test_utils.workspace = true + +[lib] +doctest = false diff --git a/crates/pg_schema_cache/src/columns.rs b/crates/pglt_schema_cache/src/columns.rs similarity index 99% rename from crates/pg_schema_cache/src/columns.rs rename to crates/pglt_schema_cache/src/columns.rs index a8d88eae0..fb8cab595 100644 --- a/crates/pg_schema_cache/src/columns.rs +++ b/crates/pglt_schema_cache/src/columns.rs @@ -81,7 +81,7 @@ impl SchemaCacheItem for Column { #[cfg(test)] mod tests { - use pg_test_utils::test_database::get_new_test_db; + use pglt_test_utils::test_database::get_new_test_db; use sqlx::Executor; use crate::{columns::ColumnClassKind, SchemaCache}; diff --git a/crates/pg_schema_cache/src/functions.rs b/crates/pglt_schema_cache/src/functions.rs similarity index 100% rename from crates/pg_schema_cache/src/functions.rs rename to crates/pglt_schema_cache/src/functions.rs diff --git a/crates/pg_schema_cache/src/lib.rs b/crates/pglt_schema_cache/src/lib.rs similarity index 100% rename from crates/pg_schema_cache/src/lib.rs rename to crates/pglt_schema_cache/src/lib.rs diff --git a/crates/pg_schema_cache/src/queries/columns.sql b/crates/pglt_schema_cache/src/queries/columns.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/columns.sql rename to crates/pglt_schema_cache/src/queries/columns.sql diff --git a/crates/pg_schema_cache/src/queries/functions.sql b/crates/pglt_schema_cache/src/queries/functions.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/functions.sql rename to crates/pglt_schema_cache/src/queries/functions.sql diff --git a/crates/pg_schema_cache/src/queries/schemas.sql b/crates/pglt_schema_cache/src/queries/schemas.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/schemas.sql rename to crates/pglt_schema_cache/src/queries/schemas.sql diff --git a/crates/pg_schema_cache/src/queries/tables.sql b/crates/pglt_schema_cache/src/queries/tables.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/tables.sql rename to crates/pglt_schema_cache/src/queries/tables.sql diff --git a/crates/pg_schema_cache/src/queries/types.sql b/crates/pglt_schema_cache/src/queries/types.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/types.sql rename to crates/pglt_schema_cache/src/queries/types.sql diff --git a/crates/pg_schema_cache/src/queries/versions.sql b/crates/pglt_schema_cache/src/queries/versions.sql similarity index 100% rename from crates/pg_schema_cache/src/queries/versions.sql rename to crates/pglt_schema_cache/src/queries/versions.sql diff --git a/crates/pg_schema_cache/src/schema_cache.rs b/crates/pglt_schema_cache/src/schema_cache.rs similarity index 97% rename from crates/pg_schema_cache/src/schema_cache.rs rename to crates/pglt_schema_cache/src/schema_cache.rs index 77a0526a5..98d7ba6d8 100644 --- a/crates/pg_schema_cache/src/schema_cache.rs +++ b/crates/pglt_schema_cache/src/schema_cache.rs @@ -82,7 +82,7 @@ pub trait SchemaCacheItem { #[cfg(test)] mod tests { - use pg_test_utils::test_database::get_new_test_db; + use pglt_test_utils::test_database::get_new_test_db; use crate::SchemaCache; diff --git a/crates/pg_schema_cache/src/schemas.rs b/crates/pglt_schema_cache/src/schemas.rs similarity index 100% rename from crates/pg_schema_cache/src/schemas.rs rename to crates/pglt_schema_cache/src/schemas.rs diff --git a/crates/pg_schema_cache/src/tables.rs b/crates/pglt_schema_cache/src/tables.rs similarity index 100% rename from crates/pg_schema_cache/src/tables.rs rename to crates/pglt_schema_cache/src/tables.rs diff --git a/crates/pg_schema_cache/src/types.rs b/crates/pglt_schema_cache/src/types.rs similarity index 100% rename from crates/pg_schema_cache/src/types.rs rename to crates/pglt_schema_cache/src/types.rs diff --git a/crates/pg_schema_cache/src/versions.rs b/crates/pglt_schema_cache/src/versions.rs similarity index 100% rename from crates/pg_schema_cache/src/versions.rs rename to crates/pglt_schema_cache/src/versions.rs diff --git a/crates/pg_statement_splitter/Cargo.toml b/crates/pglt_statement_splitter/Cargo.toml similarity index 77% rename from crates/pg_statement_splitter/Cargo.toml rename to crates/pglt_statement_splitter/Cargo.toml index 4ca03c153..d5243f762 100644 --- a/crates/pg_statement_splitter/Cargo.toml +++ b/crates/pglt_statement_splitter/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_statement_splitter" +name = "pglt_statement_splitter" repository.workspace = true version = "0.0.0" [dependencies] -pg_lexer.workspace = true -text-size.workspace = true +pglt_lexer.workspace = true +text-size.workspace = true [dev-dependencies] ntest = "0.9.3" diff --git a/crates/pg_statement_splitter/src/lib.rs b/crates/pglt_statement_splitter/src/lib.rs similarity index 99% rename from crates/pg_statement_splitter/src/lib.rs rename to crates/pglt_statement_splitter/src/lib.rs index 242c2a26a..b79991470 100644 --- a/crates/pg_statement_splitter/src/lib.rs +++ b/crates/pglt_statement_splitter/src/lib.rs @@ -17,7 +17,7 @@ pub fn split(sql: &str) -> Parse { #[cfg(test)] mod tests { use ntest::timeout; - use pg_lexer::SyntaxKind; + use pglt_lexer::SyntaxKind; use syntax_error::SyntaxError; use text_size::TextRange; diff --git a/crates/pg_statement_splitter/src/parser.rs b/crates/pglt_statement_splitter/src/parser.rs similarity index 98% rename from crates/pg_statement_splitter/src/parser.rs rename to crates/pglt_statement_splitter/src/parser.rs index 25fe685e1..8868ee38d 100644 --- a/crates/pg_statement_splitter/src/parser.rs +++ b/crates/pglt_statement_splitter/src/parser.rs @@ -5,7 +5,7 @@ mod dml; pub use common::source; -use pg_lexer::{lex, SyntaxKind, Token, WHITESPACE_TOKENS}; +use pglt_lexer::{lex, SyntaxKind, Token, WHITESPACE_TOKENS}; use text_size::{TextRange, TextSize}; use crate::syntax_error::SyntaxError; diff --git a/crates/pg_statement_splitter/src/parser/common.rs b/crates/pglt_statement_splitter/src/parser/common.rs similarity index 98% rename from crates/pg_statement_splitter/src/parser/common.rs rename to crates/pglt_statement_splitter/src/parser/common.rs index b723af287..6db298953 100644 --- a/crates/pg_statement_splitter/src/parser/common.rs +++ b/crates/pglt_statement_splitter/src/parser/common.rs @@ -1,4 +1,4 @@ -use pg_lexer::{SyntaxKind, Token, TokenType}; +use pglt_lexer::{SyntaxKind, Token, TokenType}; use super::{ data::at_statement_start, diff --git a/crates/pg_statement_splitter/src/parser/data.rs b/crates/pglt_statement_splitter/src/parser/data.rs similarity index 96% rename from crates/pg_statement_splitter/src/parser/data.rs rename to crates/pglt_statement_splitter/src/parser/data.rs index 543896ddc..7551467b2 100644 --- a/crates/pg_statement_splitter/src/parser/data.rs +++ b/crates/pglt_statement_splitter/src/parser/data.rs @@ -1,4 +1,4 @@ -use pg_lexer::SyntaxKind; +use pglt_lexer::SyntaxKind; // All tokens listed here must be explicitly handled in the `unknown` function to ensure that we do // not break in the middle of another statement that contains a statement start token. diff --git a/crates/pg_statement_splitter/src/parser/ddl.rs b/crates/pglt_statement_splitter/src/parser/ddl.rs similarity index 89% rename from crates/pg_statement_splitter/src/parser/ddl.rs rename to crates/pglt_statement_splitter/src/parser/ddl.rs index 80119b6f1..5130f2be1 100644 --- a/crates/pg_statement_splitter/src/parser/ddl.rs +++ b/crates/pglt_statement_splitter/src/parser/ddl.rs @@ -1,4 +1,4 @@ -use pg_lexer::SyntaxKind; +use pglt_lexer::SyntaxKind; use super::{common::unknown, Parser}; diff --git a/crates/pg_statement_splitter/src/parser/dml.rs b/crates/pglt_statement_splitter/src/parser/dml.rs similarity index 96% rename from crates/pg_statement_splitter/src/parser/dml.rs rename to crates/pglt_statement_splitter/src/parser/dml.rs index 40e59cea9..5ca68acd7 100644 --- a/crates/pg_statement_splitter/src/parser/dml.rs +++ b/crates/pglt_statement_splitter/src/parser/dml.rs @@ -1,4 +1,4 @@ -use pg_lexer::SyntaxKind; +use pglt_lexer::SyntaxKind; use super::{ common::{parenthesis, statement, unknown}, diff --git a/crates/pg_statement_splitter/src/syntax_error.rs b/crates/pglt_statement_splitter/src/syntax_error.rs similarity index 100% rename from crates/pg_statement_splitter/src/syntax_error.rs rename to crates/pglt_statement_splitter/src/syntax_error.rs diff --git a/crates/pg_statement_splitter/tests/data/simple_select__4.sql b/crates/pglt_statement_splitter/tests/data/simple_select__4.sql similarity index 100% rename from crates/pg_statement_splitter/tests/data/simple_select__4.sql rename to crates/pglt_statement_splitter/tests/data/simple_select__4.sql diff --git a/crates/pg_statement_splitter/tests/statement_splitter_tests.rs b/crates/pglt_statement_splitter/tests/statement_splitter_tests.rs similarity index 93% rename from crates/pg_statement_splitter/tests/statement_splitter_tests.rs rename to crates/pglt_statement_splitter/tests/statement_splitter_tests.rs index b4ea1de65..3bc9b2bc0 100644 --- a/crates/pg_statement_splitter/tests/statement_splitter_tests.rs +++ b/crates/pglt_statement_splitter/tests/statement_splitter_tests.rs @@ -22,7 +22,7 @@ fn test_statement_splitter() { let contents = fs::read_to_string(&path).unwrap(); - let split = pg_statement_splitter::split(&contents); + let split = pglt_statement_splitter::split(&contents); assert_eq!( split.ranges.len(), diff --git a/crates/pg_test_utils/Cargo.toml b/crates/pglt_test_utils/Cargo.toml similarity index 93% rename from crates/pg_test_utils/Cargo.toml rename to crates/pglt_test_utils/Cargo.toml index ea8377937..22a3510d8 100644 --- a/crates/pg_test_utils/Cargo.toml +++ b/crates/pglt_test_utils/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_test_utils" +name = "pglt_test_utils" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_test_utils/src/bin/tree_print.rs b/crates/pglt_test_utils/src/bin/tree_print.rs similarity index 100% rename from crates/pg_test_utils/src/bin/tree_print.rs rename to crates/pglt_test_utils/src/bin/tree_print.rs diff --git a/crates/pg_test_utils/src/lib.rs b/crates/pglt_test_utils/src/lib.rs similarity index 100% rename from crates/pg_test_utils/src/lib.rs rename to crates/pglt_test_utils/src/lib.rs diff --git a/crates/pg_test_utils/src/test_database.rs b/crates/pglt_test_utils/src/test_database.rs similarity index 100% rename from crates/pg_test_utils/src/test_database.rs rename to crates/pglt_test_utils/src/test_database.rs diff --git a/crates/pg_text_edit/Cargo.toml b/crates/pglt_text_edit/Cargo.toml similarity index 93% rename from crates/pg_text_edit/Cargo.toml rename to crates/pglt_text_edit/Cargo.toml index 2a1803f70..1025093b4 100644 --- a/crates/pg_text_edit/Cargo.toml +++ b/crates/pglt_text_edit/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_text_edit" +name = "pglt_text_edit" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_text_edit/src/lib.rs b/crates/pglt_text_edit/src/lib.rs similarity index 100% rename from crates/pg_text_edit/src/lib.rs rename to crates/pglt_text_edit/src/lib.rs diff --git a/crates/pg_treesitter_queries/Cargo.toml b/crates/pglt_treesitter_queries/Cargo.toml similarity index 90% rename from crates/pg_treesitter_queries/Cargo.toml rename to crates/pglt_treesitter_queries/Cargo.toml index bb85c4482..ed6e65b98 100644 --- a/crates/pg_treesitter_queries/Cargo.toml +++ b/crates/pglt_treesitter_queries/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_treesitter_queries" +name = "pglt_treesitter_queries" repository.workspace = true version = "0.0.0" diff --git a/crates/pg_treesitter_queries/src/lib.rs b/crates/pglt_treesitter_queries/src/lib.rs similarity index 100% rename from crates/pg_treesitter_queries/src/lib.rs rename to crates/pglt_treesitter_queries/src/lib.rs diff --git a/crates/pg_treesitter_queries/src/queries/mod.rs b/crates/pglt_treesitter_queries/src/queries/mod.rs similarity index 100% rename from crates/pg_treesitter_queries/src/queries/mod.rs rename to crates/pglt_treesitter_queries/src/queries/mod.rs diff --git a/crates/pg_treesitter_queries/src/queries/relations.rs b/crates/pglt_treesitter_queries/src/queries/relations.rs similarity index 100% rename from crates/pg_treesitter_queries/src/queries/relations.rs rename to crates/pglt_treesitter_queries/src/queries/relations.rs diff --git a/crates/pg_type_resolver/Cargo.toml b/crates/pglt_type_resolver/Cargo.toml similarity index 75% rename from crates/pg_type_resolver/Cargo.toml rename to crates/pglt_type_resolver/Cargo.toml index c75d80ad3..929e8a919 100644 --- a/crates/pg_type_resolver/Cargo.toml +++ b/crates/pglt_type_resolver/Cargo.toml @@ -6,14 +6,14 @@ edition.workspace = true homepage.workspace = true keywords.workspace = true license.workspace = true -name = "pg_type_resolver" +name = "pglt_type_resolver" repository.workspace = true version = "0.0.0" [dependencies] -pg_query_ext.workspace = true -pg_schema_cache.workspace = true +pglt_query_ext.workspace = true +pglt_schema_cache.workspace = true [dev-dependencies] diff --git a/crates/pg_type_resolver/src/functions.rs b/crates/pglt_type_resolver/src/functions.rs similarity index 91% rename from crates/pg_type_resolver/src/functions.rs rename to crates/pglt_type_resolver/src/functions.rs index 86ab73e5a..c827e627a 100644 --- a/crates/pg_type_resolver/src/functions.rs +++ b/crates/pglt_type_resolver/src/functions.rs @@ -1,4 +1,4 @@ -use pg_schema_cache::{Function, SchemaCache}; +use pglt_schema_cache::{Function, SchemaCache}; use crate::{ types::{resolve_type, PossibleType}, @@ -6,7 +6,7 @@ use crate::{ }; pub fn resolve_func_call<'b>( - node: &pg_query_ext::protobuf::FuncCall, + node: &pglt_query_ext::protobuf::FuncCall, schema_cache: &'b SchemaCache, ) -> Option<&'b Function> { let (schema, name) = resolve_func_identifier(node); @@ -34,7 +34,7 @@ pub fn resolve_func_call<'b>( } } -fn resolve_func_identifier(node: &pg_query_ext::protobuf::FuncCall) -> (Option, String) { +fn resolve_func_identifier(node: &pglt_query_ext::protobuf::FuncCall) -> (Option, String) { match node.funcname.as_slice() { [name] => (None, get_string_from_node(name)), [schema, name] => ( diff --git a/crates/pg_type_resolver/src/lib.rs b/crates/pglt_type_resolver/src/lib.rs similarity index 100% rename from crates/pg_type_resolver/src/lib.rs rename to crates/pglt_type_resolver/src/lib.rs diff --git a/crates/pg_type_resolver/src/types.rs b/crates/pglt_type_resolver/src/types.rs similarity index 82% rename from crates/pg_type_resolver/src/types.rs rename to crates/pglt_type_resolver/src/types.rs index 8e8a0694d..749cdc5ac 100644 --- a/crates/pg_type_resolver/src/types.rs +++ b/crates/pglt_type_resolver/src/types.rs @@ -1,13 +1,13 @@ -use pg_schema_cache::SchemaCache; +use pglt_schema_cache::SchemaCache; pub(crate) enum PossibleType { Null, AnyOf(Vec), } -pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) -> PossibleType { +pub fn resolve_type(node: &pglt_query_ext::NodeEnum, schema_cache: &SchemaCache) -> PossibleType { match node { - pg_query_ext::NodeEnum::AConst(n) => { + pglt_query_ext::NodeEnum::AConst(n) => { if n.isnull { PossibleType::Null } else { @@ -16,7 +16,7 @@ pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) - .as_ref() .expect("expected non-nullable AConst to have a value") { - pg_query_ext::protobuf::a_const::Val::Ival(_) => { + pglt_query_ext::protobuf::a_const::Val::Ival(_) => { let types: Vec = ["int2", "int4", "int8"] .iter() .map(|s| s.to_string()) @@ -33,7 +33,7 @@ pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) - .collect(), ) } - pg_query_ext::protobuf::a_const::Val::Fval(_) => { + pglt_query_ext::protobuf::a_const::Val::Fval(_) => { let types: Vec = ["float4", "float8"].iter().map(|s| s.to_string()).collect(); @@ -46,7 +46,7 @@ pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) - .collect(), ) } - pg_query_ext::protobuf::a_const::Val::Boolval(_) => PossibleType::AnyOf( + pglt_query_ext::protobuf::a_const::Val::Boolval(_) => PossibleType::AnyOf( schema_cache .types .iter() @@ -54,7 +54,7 @@ pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) - .map(|t| t.id) .collect(), ), - pg_query_ext::protobuf::a_const::Val::Sval(v) => { + pglt_query_ext::protobuf::a_const::Val::Sval(v) => { let types: Vec = ["text", "varchar"].iter().map(|s| s.to_string()).collect(); @@ -70,7 +70,7 @@ pub fn resolve_type(node: &pg_query_ext::NodeEnum, schema_cache: &SchemaCache) - .collect(), ) } - pg_query_ext::protobuf::a_const::Val::Bsval(_) => todo!(), + pglt_query_ext::protobuf::a_const::Val::Bsval(_) => todo!(), } } } diff --git a/crates/pglt_type_resolver/src/util.rs b/crates/pglt_type_resolver/src/util.rs new file mode 100644 index 000000000..440db403c --- /dev/null +++ b/crates/pglt_type_resolver/src/util.rs @@ -0,0 +1,6 @@ +pub(crate) fn get_string_from_node(node: &pglt_query_ext::protobuf::Node) -> String { + match &node.node { + Some(pglt_query_ext::NodeEnum::String(s)) => s.sval.to_string(), + _ => "".to_string(), + } +} diff --git a/crates/pglt_typecheck/Cargo.toml b/crates/pglt_typecheck/Cargo.toml new file mode 100644 index 000000000..bf8cfb00b --- /dev/null +++ b/crates/pglt_typecheck/Cargo.toml @@ -0,0 +1,32 @@ +[package] +authors.workspace = true +categories.workspace = true +description = "" +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "pglt_typecheck" +repository.workspace = true +version = "0.0.0" + + +[dependencies] +insta = "1.31.0" +pglt_console.workspace = true +pglt_diagnostics.workspace = true +pglt_query_ext.workspace = true +pglt_schema_cache.workspace = true +sqlx.workspace = true +text-size.workspace = true +tokio.workspace = true +tree-sitter.workspace = true +tree_sitter_sql.workspace = true + +[dev-dependencies] +pglt_test_utils.workspace = true + +[lib] +doctest = false + +[features] diff --git a/crates/pg_typecheck/src/diagnostics.rs b/crates/pglt_typecheck/src/diagnostics.rs similarity index 98% rename from crates/pg_typecheck/src/diagnostics.rs rename to crates/pglt_typecheck/src/diagnostics.rs index 6a6fe9143..495af5a67 100644 --- a/crates/pg_typecheck/src/diagnostics.rs +++ b/crates/pglt_typecheck/src/diagnostics.rs @@ -1,7 +1,7 @@ use std::io; -use pg_console::markup; -use pg_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; +use pglt_console::markup; +use pglt_diagnostics::{Advices, Diagnostic, LogCategory, MessageAndDescription, Severity, Visit}; use sqlx::postgres::{PgDatabaseError, PgSeverity}; use text_size::TextRange; diff --git a/crates/pg_typecheck/src/lib.rs b/crates/pglt_typecheck/src/lib.rs similarity index 79% rename from crates/pg_typecheck/src/lib.rs rename to crates/pglt_typecheck/src/lib.rs index 9c9b8ff4c..adf766040 100644 --- a/crates/pg_typecheck/src/lib.rs +++ b/crates/pglt_typecheck/src/lib.rs @@ -12,7 +12,7 @@ use text_size::TextRange; pub struct TypecheckParams<'a> { pub conn: &'a PgPool, pub sql: &'a str, - pub ast: &'a pg_query_ext::NodeEnum, + pub ast: &'a pglt_query_ext::NodeEnum, pub tree: Option<&'a tree_sitter::Tree>, } @@ -33,11 +33,11 @@ pub async fn check_sql(params: TypecheckParams<'_>) -> Option AnalyserRules { let mut analyser_rules = AnalyserRules::default(); if let Some(rules) = settings.linter.rules.as_ref() { - push_to_analyser_rules(rules, pg_analyser::METADATA.deref(), &mut analyser_rules); + push_to_analyser_rules(rules, pglt_analyser::METADATA.deref(), &mut analyser_rules); } analyser_rules } diff --git a/crates/pg_workspace/src/diagnostics.rs b/crates/pglt_workspace/src/diagnostics.rs similarity index 96% rename from crates/pg_workspace/src/diagnostics.rs rename to crates/pglt_workspace/src/diagnostics.rs index 16efcea06..c1abde4ea 100644 --- a/crates/pg_workspace/src/diagnostics.rs +++ b/crates/pglt_workspace/src/diagnostics.rs @@ -1,10 +1,10 @@ -use pg_configuration::ConfigurationDiagnostic; -use pg_console::fmt::Bytes; -use pg_console::markup; -use pg_diagnostics::{ +use pglt_configuration::ConfigurationDiagnostic; +use pglt_console::fmt::Bytes; +use pglt_console::markup; +use pglt_diagnostics::{ category, Advices, Category, Diagnostic, DiagnosticTags, LogCategory, Severity, Visit, }; -use pg_fs::FileSystemDiagnostic; +use pglt_fs::FileSystemDiagnostic; use serde::{Deserialize, Serialize}; use std::error::Error; use std::fmt; @@ -147,7 +147,7 @@ impl Diagnostic for TransportError { } } - fn message(&self, fmt: &mut pg_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pglt_console::fmt::Formatter<'_>) -> std::io::Result<()> { match self { TransportError::SerdeError(err) => write!(fmt, "serialization error: {err}"), TransportError::ChannelClosed => fmt.write_str( @@ -332,7 +332,7 @@ impl Diagnostic for FileTooLarge { Some(category!("internalError/fs")) } - fn message(&self, fmt: &mut pg_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pglt_console::fmt::Formatter<'_>) -> std::io::Result<()> { fmt.write_markup( markup!{ "Size of "{self.path}" is "{Bytes(self.size)}" which exceeds configured maximum of "{Bytes(self.limit)}" for this project. diff --git a/crates/pg_workspace/src/dome.rs b/crates/pglt_workspace/src/dome.rs similarity index 98% rename from crates/pg_workspace/src/dome.rs rename to crates/pglt_workspace/src/dome.rs index 4d59837c1..42bed5864 100644 --- a/crates/pg_workspace/src/dome.rs +++ b/crates/pglt_workspace/src/dome.rs @@ -1,4 +1,4 @@ -use pg_fs::PgLspPath; +use pglt_fs::PgLspPath; use std::collections::btree_set::Iter; use std::collections::BTreeSet; use std::iter::{FusedIterator, Peekable}; diff --git a/crates/pg_workspace/src/lib.rs b/crates/pglt_workspace/src/lib.rs similarity index 97% rename from crates/pg_workspace/src/lib.rs rename to crates/pglt_workspace/src/lib.rs index 9467d1fb4..6985d09f2 100644 --- a/crates/pg_workspace/src/lib.rs +++ b/crates/pglt_workspace/src/lib.rs @@ -1,7 +1,7 @@ use std::ops::{Deref, DerefMut}; -use pg_console::Console; -use pg_fs::{FileSystem, OsFileSystem}; +use pglt_console::Console; +use pglt_fs::{FileSystem, OsFileSystem}; pub mod configuration; pub mod diagnostics; diff --git a/crates/pg_workspace/src/matcher/LICENCE-APACHE b/crates/pglt_workspace/src/matcher/LICENCE-APACHE similarity index 100% rename from crates/pg_workspace/src/matcher/LICENCE-APACHE rename to crates/pglt_workspace/src/matcher/LICENCE-APACHE diff --git a/crates/pg_workspace/src/matcher/LICENSE-MIT b/crates/pglt_workspace/src/matcher/LICENSE-MIT similarity index 100% rename from crates/pg_workspace/src/matcher/LICENSE-MIT rename to crates/pglt_workspace/src/matcher/LICENSE-MIT diff --git a/crates/pg_workspace/src/matcher/mod.rs b/crates/pglt_workspace/src/matcher/mod.rs similarity index 97% rename from crates/pg_workspace/src/matcher/mod.rs rename to crates/pglt_workspace/src/matcher/mod.rs index c4740ad00..8c29978d5 100644 --- a/crates/pg_workspace/src/matcher/mod.rs +++ b/crates/pglt_workspace/src/matcher/mod.rs @@ -1,8 +1,8 @@ pub mod pattern; pub use pattern::{MatchOptions, Pattern, PatternError}; -use pg_console::markup; -use pg_diagnostics::Diagnostic; +use pglt_console::markup; +use pglt_diagnostics::Diagnostic; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::sync::RwLock; @@ -128,7 +128,7 @@ impl Diagnostic for PatternError { write!(fmt, "{}", self.msg) } - fn message(&self, fmt: &mut pg_console::fmt::Formatter<'_>) -> std::io::Result<()> { + fn message(&self, fmt: &mut pglt_console::fmt::Formatter<'_>) -> std::io::Result<()> { fmt.write_markup(markup!({ self.msg })) } } diff --git a/crates/pg_workspace/src/matcher/pattern.rs b/crates/pglt_workspace/src/matcher/pattern.rs similarity index 100% rename from crates/pg_workspace/src/matcher/pattern.rs rename to crates/pglt_workspace/src/matcher/pattern.rs diff --git a/crates/pg_workspace/src/settings.rs b/crates/pglt_workspace/src/settings.rs similarity index 96% rename from crates/pg_workspace/src/settings.rs rename to crates/pglt_workspace/src/settings.rs index 5d8f9acdb..a362671ca 100644 --- a/crates/pg_workspace/src/settings.rs +++ b/crates/pglt_workspace/src/settings.rs @@ -1,5 +1,5 @@ use biome_deserialize::StringSet; -use pg_diagnostics::Category; +use pglt_diagnostics::Category; use std::{ borrow::Cow, num::NonZeroU64, @@ -9,14 +9,14 @@ use std::{ }; use ignore::gitignore::{Gitignore, GitignoreBuilder}; -use pg_configuration::{ +use pglt_configuration::{ database::PartialDatabaseConfiguration, diagnostics::InvalidIgnorePattern, files::FilesConfiguration, migrations::{MigrationsConfiguration, PartialMigrationsConfiguration}, ConfigurationDiagnostic, LinterConfiguration, PartialConfiguration, }; -use pg_fs::FileSystem; +use pglt_fs::FileSystem; use crate::{matcher::Matcher, DynRef, WorkspaceError}; @@ -123,7 +123,7 @@ impl Settings { } /// Returns linter rules. - pub fn as_linter_rules(&self) -> Option> { + pub fn as_linter_rules(&self) -> Option> { self.linter.rules.as_ref().map(Cow::Borrowed) } @@ -132,7 +132,10 @@ impl Settings { /// The code of the has the following pattern: `{group}/{rule_name}`. /// /// It returns [None] if the `code` doesn't match any rule. - pub fn get_severity_from_rule_code(&self, code: &Category) -> Option { + pub fn get_severity_from_rule_code( + &self, + code: &Category, + ) -> Option { let rules = self.linter.rules.as_ref(); if let Some(rules) = rules { rules.get_severity_from_code(code) @@ -239,7 +242,7 @@ pub struct LinterSettings { pub enabled: bool, /// List of rules - pub rules: Option, + pub rules: Option, /// List of ignored paths/files to match pub ignored_files: Matcher, @@ -252,7 +255,7 @@ impl Default for LinterSettings { fn default() -> Self { Self { enabled: true, - rules: Some(pg_configuration::analyser::linter::Rules::default()), + rules: Some(pglt_configuration::analyser::linter::Rules::default()), ignored_files: Matcher::empty(), included_files: Matcher::empty(), } diff --git a/crates/pg_workspace/src/workspace.rs b/crates/pglt_workspace/src/workspace.rs similarity index 95% rename from crates/pg_workspace/src/workspace.rs rename to crates/pglt_workspace/src/workspace.rs index 16e6d1353..0ce930e0b 100644 --- a/crates/pg_workspace/src/workspace.rs +++ b/crates/pglt_workspace/src/workspace.rs @@ -1,9 +1,9 @@ use std::{panic::RefUnwindSafe, path::PathBuf, sync::Arc}; pub use self::client::{TransportRequest, WorkspaceClient, WorkspaceTransport}; -use pg_analyse::RuleCategories; -use pg_configuration::{PartialConfiguration, RuleSelector}; -use pg_fs::PgLspPath; +use pglt_analyse::RuleCategories; +use pglt_configuration::{PartialConfiguration, RuleSelector}; +use pglt_fs::PgLspPath; use serde::{Deserialize, Serialize}; use text_size::{TextRange, TextSize}; @@ -50,7 +50,7 @@ pub struct CompletionParams { #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct PullDiagnosticsResult { - pub diagnostics: Vec, + pub diagnostics: Vec, pub errors: usize, pub skipped_diagnostics: u64, } @@ -58,9 +58,9 @@ pub struct PullDiagnosticsResult { #[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq)] /// Which fixes should be applied during the analyzing phase pub enum FixFileMode { - /// Applies [safe](pg_diagnostics::Applicability::Always) fixes + /// Applies [safe](pglt_diagnostics::Applicability::Always) fixes SafeFixes, - /// Applies [safe](pg_diagnostics::Applicability::Always) and [unsafe](pg_diagnostics::Applicability::MaybeIncorrect) fixes + /// Applies [safe](pglt_diagnostics::Applicability::Always) and [unsafe](pglt_diagnostics::Applicability::MaybeIncorrect) fixes SafeAndUnsafeFixes, /// Applies suppression comments to existing diagnostics when using `--suppress` ApplySuppressions, @@ -118,7 +118,7 @@ pub trait Workspace: Send + Sync + RefUnwindSafe { fn get_completions( &self, params: CompletionParams, - ) -> Result; + ) -> Result; /// Update the global settings for this workspace fn update_settings(&self, params: UpdateSettingsParams) -> Result<(), WorkspaceError>; diff --git a/crates/pg_workspace/src/workspace/client.rs b/crates/pglt_workspace/src/workspace/client.rs similarity index 96% rename from crates/pg_workspace/src/workspace/client.rs rename to crates/pglt_workspace/src/workspace/client.rs index 36e673638..28672f170 100644 --- a/crates/pg_workspace/src/workspace/client.rs +++ b/crates/pglt_workspace/src/workspace/client.rs @@ -57,7 +57,7 @@ where "capabilities": {}, "clientInfo": { "name": env!("CARGO_PKG_NAME"), - "version": pg_configuration::VERSION + "version": pglt_configuration::VERSION }, }), )?; @@ -127,7 +127,7 @@ where fn get_completions( &self, params: super::CompletionParams, - ) -> Result { + ) -> Result { self.request("pglsp/get_completions", params) } } diff --git a/crates/pg_workspace/src/workspace/server.rs b/crates/pglt_workspace/src/workspace/server.rs similarity index 96% rename from crates/pg_workspace/src/workspace/server.rs rename to crates/pglt_workspace/src/workspace/server.rs index a8734da27..4e2671c39 100644 --- a/crates/pg_workspace/src/workspace/server.rs +++ b/crates/pglt_workspace/src/workspace/server.rs @@ -7,12 +7,12 @@ use dashmap::{DashMap, DashSet}; use db_connection::DbConnection; use document::{Document, Statement}; use futures::{stream, StreamExt}; -use pg_analyse::{AnalyserOptions, AnalysisFilter}; -use pg_analyser::{Analyser, AnalyserConfig, AnalyserContext}; -use pg_diagnostics::{serde::Diagnostic as SDiagnostic, Diagnostic, DiagnosticExt, Severity}; -use pg_fs::{ConfigName, PgLspPath}; use pg_query::PgQueryStore; -use pg_typecheck::TypecheckParams; +use pglt_analyse::{AnalyserOptions, AnalysisFilter}; +use pglt_analyser::{Analyser, AnalyserConfig, AnalyserContext}; +use pglt_diagnostics::{serde::Diagnostic as SDiagnostic, Diagnostic, DiagnosticExt, Severity}; +use pglt_fs::{ConfigName, PgLspPath}; +use pglt_typecheck::TypecheckParams; use schema_cache_manager::SchemaCacheManager; use tracing::info; use tree_sitter::TreeSitterStore; @@ -324,7 +324,7 @@ impl Workspace for WorkspaceServer { let path = path_clone.clone(); async move { if let Some(ast) = ast { - pg_typecheck::check_sql(TypecheckParams { + pglt_typecheck::check_sql(TypecheckParams { conn: &pool, sql: &text, ast: &ast, @@ -409,7 +409,7 @@ impl Workspace for WorkspaceServer { fn get_completions( &self, params: super::CompletionParams, - ) -> Result { + ) -> Result { tracing::debug!( "Getting completions for file {:?} at position {:?}", ¶ms.path, @@ -418,7 +418,7 @@ impl Workspace for WorkspaceServer { let pool = match self.connection.read().unwrap().get_pool() { Some(pool) => pool, - None => return Ok(pg_completions::CompletionResult::default()), + None => return Ok(pglt_completions::CompletionResult::default()), }; let doc = self @@ -437,7 +437,7 @@ impl Workspace for WorkspaceServer { .find(|(_, r, _)| r.contains(params.position)) { Some(s) => s, - None => return Ok(pg_completions::CompletionResult::default()), + None => return Ok(pglt_completions::CompletionResult::default()), }; // `offset` is the position in the document, @@ -450,7 +450,7 @@ impl Workspace for WorkspaceServer { let schema_cache = self.schema_cache.load(pool)?; - let result = pg_completions::complete(pg_completions::CompletionParams { + let result = pglt_completions::complete(pglt_completions::CompletionParams { position, schema: schema_cache.as_ref(), tree: tree.as_deref(), diff --git a/crates/pg_workspace/src/workspace/server/analyser.rs b/crates/pglt_workspace/src/workspace/server/analyser.rs similarity index 94% rename from crates/pg_workspace/src/workspace/server/analyser.rs rename to crates/pglt_workspace/src/workspace/server/analyser.rs index e0ad4c2f8..f2ae22fef 100644 --- a/crates/pg_workspace/src/workspace/server/analyser.rs +++ b/crates/pglt_workspace/src/workspace/server/analyser.rs @@ -1,5 +1,5 @@ -use pg_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup}; -use pg_configuration::RuleSelector; +use pglt_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup}; +use pglt_configuration::RuleSelector; use rustc_hash::FxHashSet; use crate::settings::Settings; @@ -31,7 +31,7 @@ impl<'a, 'b> AnalyserVisitorBuilder<'a, 'b> { let mut disabled_rules = vec![]; let mut enabled_rules = vec![]; if let Some(mut lint) = self.lint { - pg_analyser::visit_registry(&mut lint); + pglt_analyser::visit_registry(&mut lint); let (linter_enabled_rules, linter_disabled_rules) = lint.finish(); enabled_rules.extend(linter_enabled_rules); disabled_rules.extend(linter_disabled_rules); diff --git a/crates/pg_workspace/src/workspace/server/async_helper.rs b/crates/pglt_workspace/src/workspace/server/async_helper.rs similarity index 100% rename from crates/pg_workspace/src/workspace/server/async_helper.rs rename to crates/pglt_workspace/src/workspace/server/async_helper.rs diff --git a/crates/pg_workspace/src/workspace/server/change.rs b/crates/pglt_workspace/src/workspace/server/change.rs similarity index 98% rename from crates/pg_workspace/src/workspace/server/change.rs rename to crates/pglt_workspace/src/workspace/server/change.rs index 8cf3a1947..f51c4775b 100644 --- a/crates/pg_workspace/src/workspace/server/change.rs +++ b/crates/pglt_workspace/src/workspace/server/change.rs @@ -83,7 +83,7 @@ impl Document { self.content = text.to_string(); changes.extend( - pg_statement_splitter::split(&self.content) + pglt_statement_splitter::split(&self.content) .ranges .into_iter() .map(|range| { @@ -235,7 +235,7 @@ impl Document { .get(usize::from(affected_range.start())..usize::from(affected_range.end())) .unwrap(); - let new_ranges = pg_statement_splitter::split(changed_content).ranges; + let new_ranges = pglt_statement_splitter::split(changed_content).ranges; if new_ranges.len() == 1 { if change.is_whitespace() { @@ -289,7 +289,7 @@ impl Document { .get(usize::from(full_affected_range.start())..usize::from(full_affected_range.end())) .unwrap(); - let new_ranges = pg_statement_splitter::split(changed_content).ranges; + let new_ranges = pglt_statement_splitter::split(changed_content).ranges; // delete and add new ones if let Some(next_index) = next_index { @@ -391,7 +391,7 @@ mod tests { use crate::workspace::{ChangeFileParams, ChangeParams}; - use pg_fs::PgLspPath; + use pglt_fs::PgLspPath; impl Document { pub fn get_text(&self, idx: usize) -> String { @@ -401,7 +401,7 @@ mod tests { } fn assert_document_integrity(d: &Document) { - let ranges = pg_statement_splitter::split(&d.content).ranges; + let ranges = pglt_statement_splitter::split(&d.content).ranges; assert!(ranges.len() == d.positions.len()); diff --git a/crates/pg_workspace/src/workspace/server/db_connection.rs b/crates/pglt_workspace/src/workspace/server/db_connection.rs similarity index 94% rename from crates/pg_workspace/src/workspace/server/db_connection.rs rename to crates/pglt_workspace/src/workspace/server/db_connection.rs index 3a747342a..639be0008 100644 --- a/crates/pg_workspace/src/workspace/server/db_connection.rs +++ b/crates/pglt_workspace/src/workspace/server/db_connection.rs @@ -23,7 +23,7 @@ impl DbConnection { .password(&settings.password) .database(&settings.database); - let timeout = settings.conn_timeout_secs.clone(); + let timeout = settings.conn_timeout_secs; let pool = PoolOptions::::new() .acquire_timeout(timeout) diff --git a/crates/pg_workspace/src/workspace/server/document.rs b/crates/pglt_workspace/src/workspace/server/document.rs similarity index 96% rename from crates/pg_workspace/src/workspace/server/document.rs rename to crates/pglt_workspace/src/workspace/server/document.rs index 7c8dba06f..c34d76913 100644 --- a/crates/pg_workspace/src/workspace/server/document.rs +++ b/crates/pglt_workspace/src/workspace/server/document.rs @@ -1,4 +1,4 @@ -use pg_fs::PgLspPath; +use pglt_fs::PgLspPath; use text_size::TextRange; /// Global unique identifier for a statement @@ -28,7 +28,7 @@ impl Document { pub(crate) fn new(path: PgLspPath, content: String, version: i32) -> Self { let mut id_generator = IdGenerator::new(); - let ranges: Vec = pg_statement_splitter::split(&content) + let ranges: Vec = pglt_statement_splitter::split(&content) .ranges .iter() .map(|r| (id_generator.next(), *r)) diff --git a/crates/pg_workspace/src/workspace/server/migration.rs b/crates/pglt_workspace/src/workspace/server/migration.rs similarity index 100% rename from crates/pg_workspace/src/workspace/server/migration.rs rename to crates/pglt_workspace/src/workspace/server/migration.rs diff --git a/crates/pg_workspace/src/workspace/server/pg_query.rs b/crates/pglt_workspace/src/workspace/server/pg_query.rs similarity index 80% rename from crates/pg_workspace/src/workspace/server/pg_query.rs rename to crates/pglt_workspace/src/workspace/server/pg_query.rs index e9ca77eb0..bf356d4c0 100644 --- a/crates/pg_workspace/src/workspace/server/pg_query.rs +++ b/crates/pglt_workspace/src/workspace/server/pg_query.rs @@ -1,13 +1,13 @@ use std::sync::Arc; use dashmap::DashMap; -use pg_diagnostics::serde::Diagnostic as SDiagnostic; -use pg_query_ext::diagnostics::*; +use pglt_diagnostics::serde::Diagnostic as SDiagnostic; +use pglt_query_ext::diagnostics::*; use super::{change::ModifiedStatement, document::Statement}; pub struct PgQueryStore { - ast_db: DashMap>, + ast_db: DashMap>, diagnostics: DashMap, } @@ -19,12 +19,12 @@ impl PgQueryStore { } } - pub fn get_ast(&self, statement: &Statement) -> Option> { + pub fn get_ast(&self, statement: &Statement) -> Option> { self.ast_db.get(statement).map(|x| x.clone()) } pub fn add_statement(&self, statement: &Statement, content: &str) { - let r = pg_query_ext::parse(content); + let r = pglt_query_ext::parse(content); if let Ok(ast) = r { self.ast_db.insert(statement.clone(), Arc::new(ast)); } else { @@ -44,7 +44,7 @@ impl PgQueryStore { self.add_statement(&change.new_stmt, &change.new_stmt_text); } - pub fn get_diagnostics(&self, stmt: &Statement) -> Vec { + pub fn get_diagnostics(&self, stmt: &Statement) -> Vec { self.diagnostics .get(stmt) .map_or_else(Vec::new, |err| vec![SDiagnostic::new(err.value().clone())]) diff --git a/crates/pg_workspace/src/workspace/server/schema_cache_manager.rs b/crates/pglt_workspace/src/workspace/server/schema_cache_manager.rs similarity index 98% rename from crates/pg_workspace/src/workspace/server/schema_cache_manager.rs rename to crates/pglt_workspace/src/workspace/server/schema_cache_manager.rs index 9df910e3f..9e5529cfb 100644 --- a/crates/pg_workspace/src/workspace/server/schema_cache_manager.rs +++ b/crates/pglt_workspace/src/workspace/server/schema_cache_manager.rs @@ -1,6 +1,6 @@ use std::sync::{RwLock, RwLockReadGuard}; -use pg_schema_cache::SchemaCache; +use pglt_schema_cache::SchemaCache; use sqlx::PgPool; use crate::WorkspaceError; diff --git a/crates/pg_workspace/src/workspace/server/tree_sitter.rs b/crates/pglt_workspace/src/workspace/server/tree_sitter.rs similarity index 100% rename from crates/pg_workspace/src/workspace/server/tree_sitter.rs rename to crates/pglt_workspace/src/workspace/server/tree_sitter.rs diff --git a/xtask/codegen/Cargo.toml b/xtask/codegen/Cargo.toml index d571f7dfb..c13dba184 100644 --- a/xtask/codegen/Cargo.toml +++ b/xtask/codegen/Cargo.toml @@ -8,8 +8,8 @@ version = "0.0.0" anyhow = { workspace = true } biome_string_case = { workspace = true } bpaf = { workspace = true, features = ["derive"] } -pg_analyse = { workspace = true } -pg_analyser = { workspace = true } +pglt_analyse = { workspace = true } +pglt_analyser = { workspace = true } proc-macro2 = { workspace = true, features = ["span-locations"] } pulldown-cmark = { version = "0.12.2" } quote = "1.0.36" diff --git a/xtask/codegen/src/generate_analyser.rs b/xtask/codegen/src/generate_analyser.rs index 6ea909076..55aae038a 100644 --- a/xtask/codegen/src/generate_analyser.rs +++ b/xtask/codegen/src/generate_analyser.rs @@ -13,7 +13,7 @@ pub fn generate_analyser() -> Result<()> { } fn generate_linter() -> Result<()> { - let base_path = project_root().join("crates/pg_analyser/src"); + let base_path = project_root().join("crates/pglt_analyser/src"); let mut analysers = BTreeMap::new(); generate_category("lint", &mut analysers, &base_path)?; @@ -39,7 +39,7 @@ fn generate_options(base_path: &Path) -> Result<()> { let rule_module_name = format_ident!("{}", rule_filename); let rule_name = format_ident!("{}", rule_name); rules_options.insert(rule_filename.to_string(), quote! { - pub type #rule_name = <#category_name::#group_name::#rule_module_name::#rule_name as pg_analyse::Rule>::Options; + pub type #rule_name = <#category_name::#group_name::#rule_module_name::#rule_name as pglt_analyse::Rule>::Options; }); } } @@ -120,7 +120,7 @@ fn generate_category( let (modules, paths): (Vec<_>, Vec<_>) = groups.into_values().unzip(); let tokens = xtask::reformat(quote! { #( #modules )* - ::pg_analyse::declare_category! { + ::pglt_analyse::declare_category! { pub #category_name { kind: #kind, groups: [ @@ -173,7 +173,7 @@ fn generate_group(category: &'static str, group: &str, base_path: &Path) -> Resu let (import_macro, use_macro) = match category { "lint" => ( quote!( - use pg_analyse::declare_lint_group; + use pglt_analyse::declare_lint_group; ), quote!(declare_lint_group), ), @@ -200,12 +200,12 @@ fn generate_group(category: &'static str, group: &str, base_path: &Path) -> Resu } fn update_linter_registry_builder(rules: BTreeMap<&'static str, TokenStream>) -> Result<()> { - let path = project_root().join("crates/pg_analyser/src/registry.rs"); + let path = project_root().join("crates/pglt_analyser/src/registry.rs"); let categories = rules.into_values(); let tokens = xtask::reformat(quote! { - use pg_analyse::RegistryVisitor; + use pglt_analyse::RegistryVisitor; pub fn visit_registry(registry: &mut V) { #( #categories )* diff --git a/xtask/codegen/src/generate_configuration.rs b/xtask/codegen/src/generate_configuration.rs index d75878994..398d461ae 100644 --- a/xtask/codegen/src/generate_configuration.rs +++ b/xtask/codegen/src/generate_configuration.rs @@ -1,6 +1,6 @@ use crate::{to_capitalized, update}; use biome_string_case::Case; -use pg_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; +use pglt_analyse::{GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleGroup, RuleMetadata}; use proc_macro2::{Ident, Literal, Span, TokenStream}; use pulldown_cmark::{Event, Parser, Tag, TagEnd}; use quote::quote; @@ -32,11 +32,11 @@ impl RegistryVisitor for LintRulesVisitor { } pub fn generate_rules_configuration(mode: Mode) -> Result<()> { - let linter_config_root = project_root().join("crates/pg_configuration/src/analyser/linter"); - let push_rules_directory = project_root().join("crates/pg_configuration/src/generated"); + let linter_config_root = project_root().join("crates/pglt_configuration/src/analyser/linter"); + let push_rules_directory = project_root().join("crates/pglt_configuration/src/generated"); let mut lint_visitor = LintRulesVisitor::default(); - pg_analyser::visit_registry(&mut lint_visitor); + pglt_analyser::visit_registry(&mut lint_visitor); generate_for_groups( lint_visitor.groups, @@ -102,8 +102,8 @@ fn generate_for_groups( let severity_fn = if kind == RuleCategory::Action { quote! { - /// Given a category coming from [Diagnostic](pg_diagnostics::Diagnostic), this function returns - /// the [Severity](pg_diagnostics::Severity) associated to the rule, if the configuration changed it. + /// Given a category coming from [Diagnostic](pglt_diagnostics::Diagnostic), this function returns + /// the [Severity](pglt_diagnostics::Severity) associated to the rule, if the configuration changed it. /// If the severity is off or not set, then the function returns the default severity of the rule: /// [Severity::Error] for recommended rules and [Severity::Warning] for other rules. /// @@ -133,8 +133,8 @@ fn generate_for_groups( } else { quote! { - /// Given a category coming from [Diagnostic](pg_diagnostics::Diagnostic), this function returns - /// the [Severity](pg_diagnostics::Severity) associated to the rule, if the configuration changed it. + /// Given a category coming from [Diagnostic](pglt_diagnostics::Diagnostic), this function returns + /// the [Severity](pglt_diagnostics::Severity) associated to the rule, if the configuration changed it. /// If the severity is off or not set, then the function returns the default severity of the rule: /// [Severity::Error] for recommended rules and [Severity::Warning] for other rules. /// @@ -173,12 +173,12 @@ fn generate_for_groups( let use_rule_configuration = if kind == RuleCategory::Action { quote! { use crate::analyser::{RuleAssistConfiguration, RuleAssistPlainConfiguration}; - use pg_analyse::{options::RuleOptions, RuleFilter}; + use pglt_analyse::{options::RuleOptions, RuleFilter}; } } else { quote! { use crate::analyser::{RuleConfiguration, RulePlainConfiguration}; - use pg_analyse::{options::RuleOptions, RuleFilter}; + use pglt_analyse::{options::RuleOptions, RuleFilter}; } }; @@ -186,7 +186,7 @@ fn generate_for_groups( quote! { #use_rule_configuration use biome_deserialize_macros::Merge; - use pg_diagnostics::{Category, Severity}; + use pglt_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; #[cfg(feature = "schema")] @@ -226,7 +226,7 @@ fn generate_for_groups( } impl Actions { - /// Checks if the code coming from [pg_diagnostics::Diagnostic] corresponds to a rule. + /// Checks if the code coming from [pglt_diagnostics::Diagnostic] corresponds to a rule. /// Usually the code is built like {group}/{rule_name} pub fn has_rule( group: RuleGroup, @@ -266,7 +266,7 @@ fn generate_for_groups( quote! { #use_rule_configuration use biome_deserialize_macros::Merge; - use pg_diagnostics::{Category, Severity}; + use pglt_diagnostics::{Category, Severity}; use rustc_hash::FxHashSet; use serde::{Deserialize, Serialize}; #[cfg(feature = "schema")] @@ -314,7 +314,7 @@ fn generate_for_groups( } impl Rules { - /// Checks if the code coming from [pg_diagnostics::Diagnostic] corresponds to a rule. + /// Checks if the code coming from [pglt_diagnostics::Diagnostic] corresponds to a rule. /// Usually the code is built like {group}/{rule_name} pub fn has_rule( group: RuleGroup, @@ -380,7 +380,7 @@ fn generate_for_groups( RuleCategory::Lint => { quote! { use crate::analyser::linter::*; - use pg_analyse::{AnalyserRules, MetadataRegistry}; + use pglt_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_rules( rules: &Rules, @@ -404,7 +404,7 @@ fn generate_for_groups( RuleCategory::Action => { quote! { use crate::analyser::assists::*; - use pg_analyse::{AnalyserRules, MetadataRegistry}; + use pglt_analyse::{AnalyserRules, MetadataRegistry}; pub fn push_to_analyser_assists( rules: &Actions, @@ -534,7 +534,7 @@ fn generate_group_struct( #rule }); let rule_option_type = quote! { - pg_analyser::options::#rule_name + pglt_analyser::options::#rule_name }; let rule_option = if kind == RuleCategory::Action { quote! { Option<#rule_config_type<#rule_option_type>> } diff --git a/xtask/codegen/src/generate_new_analyser_rule.rs b/xtask/codegen/src/generate_new_analyser_rule.rs index 8760bc606..be12b55ea 100644 --- a/xtask/codegen/src/generate_new_analyser_rule.rs +++ b/xtask/codegen/src/generate_new_analyser_rule.rs @@ -29,10 +29,10 @@ fn generate_rule_template( Category::Lint => "declare_lint_rule", }; format!( - r#"use pg_analyse::{{ + r#"use pglt_analyse::{{ context::RuleContext, {macro_name}, Rule, RuleDiagnostic }}; -use pg_console::markup; +use pglt_console::markup; {macro_name}! {{ /// Succinct description of the rule. @@ -75,7 +75,7 @@ impl Rule for {rule_name_upper_camel} {{ pub fn generate_new_analyser_rule(category: Category, rule_name: &str, group: &str) { let rule_name_camel = Case::Camel.convert(rule_name); - let crate_folder = project_root().join("crates/pg_analyser"); + let crate_folder = project_root().join("crates/pglt_analyser"); let rule_folder = match &category { Category::Lint => crate_folder.join(format!("src/lint/{group}")), }; @@ -95,7 +95,7 @@ pub fn generate_new_analyser_rule(category: Category, rule_name: &str, group: &s ); std::fs::write(file_name.clone(), code).unwrap_or_else(|_| panic!("To write {}", &file_name)); - let categories_path = "crates/pg_diagnostics_categories/src/categories.rs"; + let categories_path = "crates/pglt_diagnostics_categories/src/categories.rs"; let mut categories = std::fs::read_to_string(categories_path).unwrap(); if !categories.contains(&rule_name_camel) { diff --git a/xtask/rules_check/Cargo.toml b/xtask/rules_check/Cargo.toml index 812d3cbfe..8654f5518 100644 --- a/xtask/rules_check/Cargo.toml +++ b/xtask/rules_check/Cargo.toml @@ -6,12 +6,12 @@ publish = false version = "0.0.0" [dependencies] -anyhow = { workspace = true } -pg_analyse = { workspace = true } -pg_analyser = { workspace = true } -pg_console = { workspace = true } -pg_diagnostics = { workspace = true } -pg_query_ext = { workspace = true } -pg_statement_splitter = { workspace = true } -pg_workspace = { workspace = true } -pulldown-cmark = "0.12.2" +anyhow = { workspace = true } +pglt_analyse = { workspace = true } +pglt_analyser = { workspace = true } +pglt_console = { workspace = true } +pglt_diagnostics = { workspace = true } +pglt_query_ext = { workspace = true } +pglt_statement_splitter = { workspace = true } +pglt_workspace = { workspace = true } +pulldown-cmark = "0.12.2" diff --git a/xtask/rules_check/src/lib.rs b/xtask/rules_check/src/lib.rs index 407916123..22c4a72aa 100644 --- a/xtask/rules_check/src/lib.rs +++ b/xtask/rules_check/src/lib.rs @@ -3,15 +3,15 @@ use std::str::FromStr; use std::{fmt::Write, slice}; use anyhow::bail; -use pg_analyse::{ +use pglt_analyse::{ AnalyserOptions, AnalysisFilter, GroupCategory, RegistryVisitor, Rule, RuleCategory, RuleFilter, RuleGroup, RuleMetadata, }; -use pg_analyser::{Analyser, AnalyserConfig}; -use pg_console::{markup, Console}; -use pg_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; -use pg_query_ext::diagnostics::SyntaxDiagnostic; -use pg_workspace::settings::Settings; +use pglt_analyser::{Analyser, AnalyserConfig}; +use pglt_console::{markup, Console}; +use pglt_diagnostics::{Diagnostic, DiagnosticExt, PrintDiagnostic}; +use pglt_query_ext::diagnostics::SyntaxDiagnostic; +use pglt_workspace::settings::Settings; use pulldown_cmark::{CodeBlockKind, Event, Parser, Tag, TagEnd}; pub fn check_rules() -> anyhow::Result<()> { @@ -48,7 +48,7 @@ pub fn check_rules() -> anyhow::Result<()> { } let mut visitor = LintRulesVisitor::default(); - pg_analyser::visit_registry(&mut visitor); + pglt_analyser::visit_registry(&mut visitor); let LintRulesVisitor { groups } = visitor; @@ -74,16 +74,16 @@ fn assert_lint( let mut diagnostic_count = 0; let mut all_diagnostics = vec![]; let mut has_error = false; - let mut write_diagnostic = |code: &str, diag: pg_diagnostics::Error| { + let mut write_diagnostic = |code: &str, diag: pglt_diagnostics::Error| { all_diagnostics.push(diag); // Fail the test if the analysis returns more diagnostics than expected if test.expect_diagnostic { // Print all diagnostics to help the user if all_diagnostics.len() > 1 { - let mut console = pg_console::EnvConsole::default(); + let mut console = pglt_console::EnvConsole::default(); for diag in all_diagnostics.iter() { console.println( - pg_console::LogLevel::Error, + pglt_console::LogLevel::Error, markup! { {PrintDiagnostic::verbose(diag)} }, @@ -94,10 +94,10 @@ fn assert_lint( } } else { // Print all diagnostics to help the user - let mut console = pg_console::EnvConsole::default(); + let mut console = pglt_console::EnvConsole::default(); for diag in all_diagnostics.iter() { console.println( - pg_console::LogLevel::Error, + pglt_console::LogLevel::Error, markup! { {PrintDiagnostic::verbose(diag)} }, @@ -127,12 +127,12 @@ fn assert_lint( }); // split and parse each statement - let stmts = pg_statement_splitter::split(code); + let stmts = pglt_statement_splitter::split(code); for stmt in stmts.ranges { - match pg_query_ext::parse(&code[stmt]) { + match pglt_query_ext::parse(&code[stmt]) { Ok(ast) => { - for rule_diag in analyser.run(pg_analyser::AnalyserContext { root: &ast }) { - let diag = pg_diagnostics::serde::Diagnostic::new(rule_diag); + for rule_diag in analyser.run(pglt_analyser::AnalyserContext { root: &ast }) { + let diag = pglt_diagnostics::serde::Diagnostic::new(rule_diag); let category = diag.category().expect("linter diagnostic has no code"); let severity = settings.get_severity_from_rule_code(category).expect( diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 457722f60..227170089 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs @@ -137,7 +137,7 @@ fn install_client(sh: &Shell, client_opt: ClientOpt) -> anyhow::Result<()> { } fn install_server(sh: &Shell) -> anyhow::Result<()> { - let cmd = cmd!(sh, "cargo install --path crates/pg_cli --locked --force"); + let cmd = cmd!(sh, "cargo install --path crates/pglt_cli --locked --force"); cmd.run()?; Ok(()) }