Skip to content

Commit b8ec48f

Browse files
authored
chore: cleanup feature gates (#236)
* chore: add our own text-size * fix: test * chore: cleanup feature gates * chore: cleanup remaining feature gates
1 parent a597279 commit b8ec48f

File tree

28 files changed

+83
-96
lines changed

28 files changed

+83
-96
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pglt_analyse/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ schemars = { workspace = true, optional = true }
2727
serde = { workspace = true, features = ["derive"], optional = true }
2828

2929
[features]
30-
serde = ["dep:serde", "dep:schemars", "dep:biome_deserialize", "dep:biome_deserialize_macros"]
30+
schema = ["dep:schemars"]
31+
serde = ["dep:serde", "dep:biome_deserialize", "dep:biome_deserialize_macros"]

crates/pglt_analyse/src/categories.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use enumflags2::{BitFlags, bitflags};
22
use std::borrow::Cow;
33

44
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5-
#[cfg_attr(
6-
feature = "serde",
7-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
8-
)]
5+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
97
pub enum RuleCategory {
108
/// This rule performs static analysis of the source code to detect
119
/// invalid or error-prone patterns, and emits diagnostics along with
@@ -26,10 +24,8 @@ pub const SUPPRESSION_ACTION_CATEGORY: &str = "quickfix.suppressRule";
2624
///
2725
/// [CodeActionKind]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind
2826
#[derive(Clone, Debug, PartialEq, Eq)]
29-
#[cfg_attr(
30-
feature = "serde",
31-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
32-
)]
27+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
28+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
3329
pub enum ActionCategory {
3430
/// Base kind for quickfix actions: 'quickfix'.
3531
///
@@ -110,10 +106,8 @@ impl ActionCategory {
110106
///
111107
/// [Check the LSP spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionKind) for more information:
112108
#[derive(Clone, Debug, PartialEq, Eq)]
113-
#[cfg_attr(
114-
feature = "serde",
115-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
116-
)]
109+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
110+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
117111
pub enum RefactorKind {
118112
/// This action describes a refactor with no particular sub-category
119113
None,
@@ -150,10 +144,8 @@ pub enum RefactorKind {
150144

151145
/// The sub-category of a source code action
152146
#[derive(Clone, Debug, PartialEq, Eq)]
153-
#[cfg_attr(
154-
feature = "serde",
155-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
156-
)]
147+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
148+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
157149
pub enum SourceActionKind {
158150
/// This action describes a source action with no particular sub-category
159151
None,
@@ -282,7 +274,7 @@ impl<'de> serde::Deserialize<'de> for RuleCategories {
282274
}
283275
}
284276

285-
#[cfg(feature = "serde")]
277+
#[cfg(feature = "schema")]
286278
impl schemars::JsonSchema for RuleCategories {
287279
fn schema_name() -> String {
288280
String::from("RuleCategories")

crates/pglt_analyse/src/rule.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ impl RuleDiagnostic {
271271
}
272272

273273
#[derive(Debug, Clone, Eq)]
274-
#[cfg_attr(feature = "serde", derive(serde::Serialize, schemars::JsonSchema))]
275-
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
274+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
275+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
276276
pub enum RuleSource {
277277
/// Rules from [Squawk](https://squawkhq.com)
278278
Squawk(&'static str),

crates/pglt_cli/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ tikv-jemallocator = "0.6.0"
5555
[lib]
5656
doctest = false
5757

58-
[features]
59-
6058
[[bin]]
6159
name = "pglt"
6260
path = "src/main.rs"

crates/pglt_commands/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ sqlx.workspace = true
1919

2020
[lib]
2121
doctest = false
22-
23-
[features]

crates/pglt_completions/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,3 @@ pglt_test_utils.workspace = true
3333

3434
[lib]
3535
doctest = false
36-
37-
[features]

crates/pglt_console/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ unicode-width = { workspace = true }
2525
trybuild = "1.0.99"
2626

2727
[features]
28-
serde_markup = ["serde", "schemars"]
28+
schema = ["dep:schemars", "pglt_text_size/schema"]
29+
serde = ["dep:serde"]
2930

3031
[lib]
3132
doctest = false

crates/pglt_console/src/markup.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ use crate::fmt::{Display, Formatter, MarkupElements, Write};
1111

1212
/// Enumeration of all the supported markup elements
1313
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
14-
#[cfg_attr(
15-
feature = "serde",
16-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
17-
)]
14+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
1816
pub enum MarkupElement<'fmt> {
1917
Emphasis,
2018
Dim,
@@ -122,10 +120,8 @@ pub struct MarkupNode<'fmt> {
122120
}
123121

124122
#[derive(Clone, PartialEq, Eq, Hash)]
125-
#[cfg_attr(
126-
feature = "serde",
127-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
128-
)]
123+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
124+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
129125
pub struct MarkupNodeBuf {
130126
pub elements: Vec<MarkupElement<'static>>,
131127
pub content: String,
@@ -181,10 +177,8 @@ impl Markup<'_> {
181177
}
182178

183179
#[derive(Clone, Default, PartialEq, Eq, Hash)]
184-
#[cfg_attr(
185-
feature = "serde",
186-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
187-
)]
180+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
181+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
188182
pub struct MarkupBuf(pub Vec<MarkupNodeBuf>);
189183

190184
impl MarkupBuf {

crates/pglt_diagnostics/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ version = "0.0.0"
1515
backtrace = "0.3.74"
1616
bpaf = { workspace = true }
1717
enumflags2 = { workspace = true }
18-
pglt_console = { workspace = true, features = ["serde_markup"] }
18+
pglt_console = { workspace = true, features = ["serde"] }
1919
pglt_diagnostics_categories = { workspace = true, features = ["serde"] }
2020
pglt_diagnostics_macros = { workspace = true }
21-
pglt_text_edit = { workspace = true }
21+
pglt_text_edit = { workspace = true, features = ["serde"] }
2222
pglt_text_size.workspace = true
2323
schemars = { workspace = true, optional = true }
2424
serde = { workspace = true, features = ["derive"] }
@@ -27,7 +27,7 @@ termcolor = { workspace = true }
2727
unicode-width = { workspace = true }
2828

2929
[features]
30-
schema = ["schemars", "pglt_text_edit/schemars", "pglt_diagnostics_categories/schemars"]
30+
schema = ["dep:schemars", "pglt_text_edit/schema", "pglt_diagnostics_categories/schema", "pglt_console/schema"]
3131

3232
[dev-dependencies]
3333

crates/pglt_diagnostics_categories/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ version = "0.0.0"
1515
schemars = { workspace = true, optional = true }
1616
serde = { workspace = true, optional = true }
1717

18+
[features]
19+
schema = ["dep:schemars"]
20+
serde = ["dep:serde"]
21+
1822
[build-dependencies]
1923
quote = "1.0.14"

crates/pglt_diagnostics_categories/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn main() -> io::Result<()> {
6464
}
6565
}
6666

67-
#[cfg(feature = "schemars")]
67+
#[cfg(feature = "schema")]
6868
impl schemars::JsonSchema for &'static Category {
6969
fn schema_name() -> String {
7070
String::from("Category")

crates/pglt_diagnostics_macros/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ quote = { workspace = true }
2121
syn = { workspace = true }
2222

2323
[dev-dependencies]
24-
25-
[features]

crates/pglt_flags/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ version = "0.0.0"
1515
pglt_console = { workspace = true }
1616

1717
[dev-dependencies]
18-
19-
[features]

crates/pglt_fs/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ pglt_diagnostics = { workspace = true }
2020
rayon = { workspace = true }
2121
rustc-hash = { workspace = true }
2222
schemars = { workspace = true, optional = true }
23-
serde = { workspace = true }
23+
serde = { workspace = true, optional = true }
2424
smallvec = { workspace = true }
2525
tracing = { workspace = true }
2626

2727
[features]
28-
serde = ["schemars", "pglt_diagnostics/schema"]
29-
30-
[dev-dependencies]
28+
schema = ["dep:schemars", "pglt_diagnostics/schema"]
29+
serde = ["dep:serde"]
3130

3231
[lib]
3332
doctest = false

crates/pglt_fs/src/path.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ use crate::ConfigName;
1717
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Ord, PartialOrd, Hash)]
1818
#[repr(u8)]
1919
#[bitflags]
20-
#[cfg_attr(
21-
feature = "serde",
22-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
23-
)]
20+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
21+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2422
// NOTE: The order of the variants is important, the one on the top has the highest priority
2523
pub enum FileKind {
2624
/// A configuration file has the highest priority. It's usually `pglt.toml`
@@ -85,10 +83,8 @@ impl From<FileKind> for FileKinds {
8583
}
8684

8785
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
88-
#[cfg_attr(
89-
feature = "serde",
90-
derive(serde::Serialize, serde::Deserialize, schemars::JsonSchema)
91-
)]
86+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
87+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9288
pub struct PgLTPath {
9389
path: PathBuf,
9490
/// 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
@@ -201,7 +197,7 @@ impl PgLTPath {
201197
}
202198
}
203199

204-
#[cfg(feature = "serde")]
200+
#[cfg(feature = "schema")]
205201
impl schemars::JsonSchema for FileKinds {
206202
fn schema_name() -> String {
207203
String::from("FileKind")

crates/pglt_lsp/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ tower = { version = "0.4.13", features = ["timeout"] }
4141

4242
[lib]
4343
doctest = false
44-
45-
[features]

crates/pglt_lsp_converters/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ tower-lsp = { version = "0.20.0" }
2121

2222
[lib]
2323
doctest = false
24-
25-
[features]

crates/pglt_markup/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ quote = "1.0.14"
2020

2121
[lib]
2222
proc-macro = true
23-
24-
[features]

crates/pglt_text_edit/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ version = "0.0.0"
1212

1313

1414
[dependencies]
15-
pglt_text_size = { workspace = true, features = ["serde"] }
15+
pglt_text_size = { workspace = true }
1616
schemars = { workspace = true, optional = true }
17-
serde = { workspace = true, features = ["derive"] }
17+
serde = { workspace = true, features = ["derive"], optional = true }
1818
similar = { workspace = true, features = ["unicode"] }
1919

2020
[features]
21-
schemars = ["dep:schemars"]
21+
schema = ["dep:schemars", "pglt_text_size/schema"]
22+
serde = ["dep:serde", "pglt_text_size/serde"]
2223

2324
[dev-dependencies]
2425

crates/pglt_text_edit/src/lib.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,40 @@
1111
use std::{cmp::Ordering, num::NonZeroU32};
1212

1313
use pglt_text_size::{TextRange, TextSize};
14-
use serde::{Deserialize, Serialize};
1514
pub use similar::ChangeTag;
1615
use similar::{TextDiff, utils::TextDiffRemapper};
1716

18-
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
19-
#[serde(rename_all = "snake_case")]
17+
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
18+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
19+
#[cfg_attr(
20+
feature = "serde",
21+
derive(serde::Serialize, serde::Deserialize),
22+
serde(rename_all = "camelCase")
23+
)]
2024
pub struct TextEdit {
2125
dictionary: String,
2226
ops: Vec<CompressedOp>,
2327
}
2428

25-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
26-
#[serde(rename_all = "snake_case")]
29+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
30+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
31+
#[cfg_attr(
32+
feature = "serde",
33+
derive(serde::Serialize, serde::Deserialize),
34+
serde(rename_all = "camelCase")
35+
)]
2736
pub enum CompressedOp {
2837
DiffOp(DiffOp),
2938
EqualLines { line_count: NonZeroU32 },
3039
}
3140

32-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
33-
#[serde(rename_all = "snake_case")]
41+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
42+
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
43+
#[cfg_attr(
44+
feature = "serde",
45+
derive(serde::Serialize, serde::Deserialize),
46+
serde(rename_all = "camelCase")
47+
)]
3448
pub enum DiffOp {
3549
Equal { range: TextRange },
3650
Insert { range: TextRange },

crates/pglt_text_size/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ schemars = { workspace = true, optional = true }
1515
serde = { workspace = true, optional = true }
1616

1717
[features]
18-
schema = ["dep:schemars", "serde"]
18+
schema = ["dep:schemars"]
1919
serde = ["dep:serde"]
2020

2121
[dev-dependencies]

crates/pglt_text_size/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ mod traits;
2626
#[cfg(feature = "serde")]
2727
mod serde_impls;
2828

29+
#[cfg(feature = "schema")]
30+
mod schemars_impls;
31+
2932
pub use crate::{range::TextRange, size::TextSize, traits::TextLen};
3033

3134
#[cfg(target_pointer_width = "16")]

crates/pglt_treesitter_queries/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ tree_sitter_sql.workspace = true
2020

2121
[lib]
2222
doctest = false
23-
24-
[features]

crates/pglt_type_resolver/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ pglt_schema_cache.workspace = true
1919

2020
[lib]
2121
doctest = false
22-
23-
[features]

crates/pglt_typecheck/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,3 @@ pglt_test_utils.workspace = true
2828

2929
[lib]
3030
doctest = false
31-
32-
[features]

0 commit comments

Comments
 (0)