Skip to content

Commit 3a0bd03

Browse files
feat: suppressions
1 parent 8a8b4c6 commit 3a0bd03

File tree

12 files changed

+692
-12
lines changed

12 files changed

+692
-12
lines changed

Cargo.lock

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pgt_query_ext_codegen = { path = "./crates/pgt_query_ext_codegen", version
7676
pgt_query_proto_parser = { path = "./crates/pgt_query_proto_parser", version = "0.0.0" }
7777
pgt_schema_cache = { path = "./crates/pgt_schema_cache", version = "0.0.0" }
7878
pgt_statement_splitter = { path = "./crates/pgt_statement_splitter", version = "0.0.0" }
79+
pgt_suppressions = { path = "./crates/pgt_suppressions", version = "0.0.0"}
7980
pgt_text_edit = { path = "./crates/pgt_text_edit", version = "0.0.0" }
8081
pgt_text_size = { path = "./crates/pgt_text_size", version = "0.0.0" }
8182
pgt_treesitter_queries = { path = "./crates/pgt_treesitter_queries", version = "0.0.0" }

crates/pgt_analyse/src/categories.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ pub enum RuleCategory {
1616
Transformation,
1717
}
1818

19+
impl TryFrom<String> for RuleCategory {
20+
type Error = String;
21+
22+
fn try_from(value: String) -> Result<Self, Self::Error> {
23+
value.as_str().try_into()
24+
}
25+
}
26+
27+
impl TryFrom<&str> for RuleCategory {
28+
type Error = String;
29+
30+
fn try_from(value: &str) -> Result<Self, Self::Error> {
31+
match value {
32+
"lint" => Ok(Self::Lint),
33+
"action" => Ok(Self::Action),
34+
"transformation" => Ok(Self::Transformation),
35+
_ => Err(format!("Invalid Rule Category: {}", value)),
36+
}
37+
}
38+
}
39+
1940
/// Actions that suppress rules should start with this string
2041
pub const SUPPRESSION_ACTION_CATEGORY: &str = "quickfix.suppressRule";
2142

crates/pgt_diagnostics/src/location.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ impl Eq for Location<'_> {}
4141
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
4242
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
4343
#[serde(rename_all = "camelCase")]
44-
pub enum Resource<P> {
44+
pub enum Resource<Path> {
4545
/// The diagnostic is related to the content of the command line arguments.
4646
Argv,
4747
/// The diagnostic is related to the content of a memory buffer.
4848
Memory,
4949
/// The diagnostic is related to a file on the filesystem.
50-
File(P),
50+
File(Path),
5151
}
5252

5353
impl<P> Resource<P> {

crates/pgt_suppressions/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ name = "pgt_suppressions"
1111
repository.workspace = true
1212
version = "0.0.0"
1313

14+
[dependencies]
15+
pgt_text_size = {workspace = true }
16+
pgt_diagnostics = {workspace = true }
17+
pgt_analyse = {workspace = true }
18+
1419

0 commit comments

Comments
 (0)