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

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pglt_analyse/Cargo.toml

Lines changed: 2 additions & 1 deletion
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

Lines changed: 9 additions & 17 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 6 additions & 12 deletions
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

Lines changed: 3 additions & 3 deletions
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

0 commit comments

Comments
 (0)