Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit c95011c

Browse files
oppiliappanHendrik van Antwerpen
authored andcommitted
rename filtered_stack_graph to serde
- this new `serde` module will be responsible for defining everything related to ser/de in this crate, code from `json` can live in `serde` instead - introduces `crate::serde::Error` for load errors - adds a minimal test to ensure that accidental merges and inconsistent states are unreachable - turns the `serde` feature flag into an explicit flag
1 parent fc67b4b commit c95011c

File tree

5 files changed

+167
-145
lines changed

5 files changed

+167
-145
lines changed

stack-graphs/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ edition = "2018"
1414

1515
[features]
1616
copious-debugging = []
17+
serde = ["dep:serde", "lsp-positions/serde"]
1718
json = ["serde", "serde_json", "lsp-positions/serde"]
1819

1920
[lib]
@@ -40,4 +41,4 @@ maplit = "1.0"
4041
pretty_assertions = "0.7"
4142

4243
[package.metadata.docs.rs]
43-
all-features = true
44+
all-features = true

stack-graphs/src/json.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ use crate::partial::ScopeStackVariable;
3737
use crate::partial::SymbolStackVariable;
3838
use crate::stitching::Database;
3939

40-
#[path = "filtered_stack_graph.rs"]
41-
mod filtered_stack_graph;
42-
4340
#[derive(Debug, Error)]
4441
#[error(transparent)]
4542
pub struct JsonError(#[from] serde_json::error::Error);
@@ -203,6 +200,14 @@ impl<'a> StackGraph {
203200
pub fn to_json(&'a self, f: &'a dyn Filter) -> JsonStackGraph {
204201
JsonStackGraph(self, f)
205202
}
203+
204+
pub fn to_serializable(&self) -> crate::serde::StackGraph {
205+
self.to_serializable_with_filter(&NoFilter)
206+
}
207+
208+
pub fn to_serializable_with_filter(&self, f: &'a dyn Filter) -> crate::serde::StackGraph {
209+
crate::serde::StackGraph::from_graph(self, f)
210+
}
206211
}
207212

208213
pub struct JsonStackGraph<'a>(&'a StackGraph, &'a dyn Filter);

stack-graphs/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ pub mod graph;
7070
pub mod json;
7171
pub mod partial;
7272
pub mod paths;
73+
#[cfg(feature = "serde")]
74+
pub mod serde;
7375
pub mod stitching;
7476
pub(crate) mod utils;
7577
#[cfg(feature = "json")]

0 commit comments

Comments
 (0)