Skip to content

chore: cleanup feature gates #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/pglt_analyse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"], optional = true }

[features]
serde = ["dep:serde", "dep:schemars", "dep:biome_deserialize", "dep:biome_deserialize_macros"]
schema = ["dep:schemars"]
serde = ["dep:serde", "dep:biome_deserialize", "dep:biome_deserialize_macros"]
26 changes: 9 additions & 17 deletions crates/pglt_analyse/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use enumflags2::{BitFlags, bitflags};
use std::borrow::Cow;

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum RuleCategory {
/// This rule performs static analysis of the source code to detect
/// invalid or error-prone patterns, and emits diagnostics along with
Expand All @@ -26,10 +24,8 @@ pub const SUPPRESSION_ACTION_CATEGORY: &str = "quickfix.suppressRule";
///
/// [CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum ActionCategory {
/// Base kind for quickfix actions: 'quickfix'.
///
Expand Down Expand Up @@ -110,10 +106,8 @@ impl ActionCategory {
///
/// [Check the LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) for more information:
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum RefactorKind {
/// This action describes a refactor with no particular sub-category
None,
Expand Down Expand Up @@ -150,10 +144,8 @@ pub enum RefactorKind {

/// The sub-category of a source code action
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum SourceActionKind {
/// This action describes a source action with no particular sub-category
None,
Expand Down Expand Up @@ -282,7 +274,7 @@ impl<'de> serde::Deserialize<'de> for RuleCategories {
}
}

#[cfg(feature = "serde")]
#[cfg(feature = "schema")]
impl schemars::JsonSchema for RuleCategories {
fn schema_name() -> String {
String::from("RuleCategories")
Expand Down
4 changes: 2 additions & 2 deletions crates/pglt_analyse/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ impl RuleDiagnostic {
}

#[derive(Debug, Clone, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, schemars::JsonSchema))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum RuleSource {
/// Rules from [Squawk](https://squawkhq.com)
Squawk(&'static str),
Expand Down
2 changes: 0 additions & 2 deletions crates/pglt_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ tikv-jemallocator = "0.6.0"
[lib]
doctest = false

[features]

[[bin]]
name = "pglt"
path = "src/main.rs"
2 changes: 0 additions & 2 deletions crates/pglt_commands/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ sqlx.workspace = true

[lib]
doctest = false

[features]
2 changes: 0 additions & 2 deletions crates/pglt_completions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ pglt_test_utils.workspace = true

[lib]
doctest = false

[features]
3 changes: 2 additions & 1 deletion crates/pglt_console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ unicode-width = { workspace = true }
trybuild = "1.0.99"

[features]
serde_markup = ["serde", "schemars"]
schema = ["dep:schemars", "pglt_text_size/schema"]
serde = ["dep:serde"]

[lib]
doctest = false
18 changes: 6 additions & 12 deletions crates/pglt_console/src/markup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ use crate::fmt::{Display, Formatter, MarkupElements, Write};

/// Enumeration of all the supported markup elements
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub enum MarkupElement<'fmt> {
Emphasis,
Dim,
Expand Down Expand Up @@ -122,10 +120,8 @@ pub struct MarkupNode<'fmt> {
}

#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct MarkupNodeBuf {
pub elements: Vec<MarkupElement<'static>>,
pub content: String,
Expand Down Expand Up @@ -181,10 +177,8 @@ impl Markup<'_> {
}

#[derive(Clone, Default, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct MarkupBuf(pub Vec<MarkupNodeBuf>);

impl MarkupBuf {
Expand Down
6 changes: 3 additions & 3 deletions crates/pglt_diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ version = "0.0.0"
backtrace = "0.3.74"
bpaf = { workspace = true }
enumflags2 = { workspace = true }
pglt_console = { workspace = true, features = ["serde_markup"] }
pglt_console = { workspace = true, features = ["serde"] }
pglt_diagnostics_categories = { workspace = true, features = ["serde"] }
pglt_diagnostics_macros = { workspace = true }
pglt_text_edit = { workspace = true }
pglt_text_edit = { workspace = true, features = ["serde"] }
pglt_text_size.workspace = true
schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
Expand All @@ -27,7 +27,7 @@ termcolor = { workspace = true }
unicode-width = { workspace = true }

[features]
schema = ["schemars", "pglt_text_edit/schemars", "pglt_diagnostics_categories/schemars"]
schema = ["dep:schemars", "pglt_text_edit/schema", "pglt_diagnostics_categories/schema", "pglt_console/schema"]

[dev-dependencies]

Expand Down
4 changes: 4 additions & 0 deletions crates/pglt_diagnostics_categories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ version = "0.0.0"
schemars = { workspace = true, optional = true }
serde = { workspace = true, optional = true }

[features]
schema = ["dep:schemars"]
serde = ["dep:serde"]

[build-dependencies]
quote = "1.0.14"
2 changes: 1 addition & 1 deletion crates/pglt_diagnostics_categories/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub fn main() -> io::Result<()> {
}
}

#[cfg(feature = "schemars")]
#[cfg(feature = "schema")]
impl schemars::JsonSchema for &'static Category {
fn schema_name() -> String {
String::from("Category")
Expand Down
2 changes: 0 additions & 2 deletions crates/pglt_diagnostics_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ quote = { workspace = true }
syn = { workspace = true }

[dev-dependencies]

[features]
2 changes: 0 additions & 2 deletions crates/pglt_flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ version = "0.0.0"
pglt_console = { workspace = true }

[dev-dependencies]

[features]
7 changes: 3 additions & 4 deletions crates/pglt_fs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ pglt_diagnostics = { workspace = true }
rayon = { workspace = true }
rustc-hash = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true }
serde = { workspace = true, optional = true }
smallvec = { workspace = true }
tracing = { workspace = true }

[features]
serde = ["schemars", "pglt_diagnostics/schema"]

[dev-dependencies]
schema = ["dep:schemars", "pglt_diagnostics/schema"]
serde = ["dep:serde"]

[lib]
doctest = false
14 changes: 5 additions & 9 deletions crates/pglt_fs/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ use crate::ConfigName;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[repr(u8)]
#[bitflags]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
// NOTE: The order of the variants is important, the one on the top has the highest priority
pub enum FileKind {
/// A configuration file has the highest priority. It's usually `pglt.toml`
Expand Down Expand Up @@ -85,10 +83,8 @@ impl From<FileKind> for FileKinds {
}

#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PgLTPath {
path: PathBuf,
/// Determines the kind of the file inside PgLT. Some files are considered as configuration files, others as manifest files, and others as files to handle
Expand Down Expand Up @@ -201,7 +197,7 @@ impl PgLTPath {
}
}

#[cfg(feature = "serde")]
#[cfg(feature = "schema")]
impl schemars::JsonSchema for FileKinds {
fn schema_name() -> String {
String::from("FileKind")
Expand Down
2 changes: 0 additions & 2 deletions crates/pglt_lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,3 @@ tower = { version = "0.4.13", features = ["timeout"] }

[lib]
doctest = false

[features]
2 changes: 0 additions & 2 deletions crates/pglt_lsp_converters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ tower-lsp = { version = "0.20.0" }

[lib]
doctest = false

[features]
2 changes: 0 additions & 2 deletions crates/pglt_markup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ quote = "1.0.14"

[lib]
proc-macro = true

[features]
7 changes: 4 additions & 3 deletions crates/pglt_text_edit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ version = "0.0.0"


[dependencies]
pglt_text_size = { workspace = true, features = ["serde"] }
pglt_text_size = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde = { workspace = true, features = ["derive"], optional = true }
similar = { workspace = true, features = ["unicode"] }

[features]
schemars = ["dep:schemars"]
schema = ["dep:schemars", "pglt_text_size/schema"]
serde = ["dep:serde", "pglt_text_size/serde"]

[dev-dependencies]

Expand Down
28 changes: 21 additions & 7 deletions crates/pglt_text_edit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,40 @@
use std::{cmp::Ordering, num::NonZeroU32};

use pglt_text_size::{TextRange, TextSize};
use serde::{Deserialize, Serialize};
pub use similar::ChangeTag;
use similar::{TextDiff, utils::TextDiffRemapper};

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "camelCase")
)]
pub struct TextEdit {
dictionary: String,
ops: Vec<CompressedOp>,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "camelCase")
)]
pub enum CompressedOp {
DiffOp(DiffOp),
EqualLines { line_count: NonZeroU32 },
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "camelCase")
)]
pub enum DiffOp {
Equal { range: TextRange },
Insert { range: TextRange },
Expand Down
2 changes: 1 addition & 1 deletion crates/pglt_text_size/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ schemars = { workspace = true, optional = true }
serde = { workspace = true, optional = true }

[features]
schema = ["dep:schemars", "serde"]
schema = ["dep:schemars"]
serde = ["dep:serde"]

[dev-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions crates/pglt_text_size/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ mod traits;
#[cfg(feature = "serde")]
mod serde_impls;

#[cfg(feature = "schema")]
mod schemars_impls;

pub use crate::{range::TextRange, size::TextSize, traits::TextLen};

#[cfg(target_pointer_width = "16")]
Expand Down
2 changes: 0 additions & 2 deletions crates/pglt_treesitter_queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ tree_sitter_sql.workspace = true

[lib]
doctest = false

[features]
2 changes: 0 additions & 2 deletions crates/pglt_type_resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ pglt_schema_cache.workspace = true

[lib]
doctest = false

[features]
2 changes: 0 additions & 2 deletions crates/pglt_typecheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ pglt_test_utils.workspace = true

[lib]
doctest = false

[features]
Loading