Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(stats): moved statistics stuff to its own crate
Elijah Potter1f113f46fc35
diff --git a/Cargo.lock b/Cargo.lockindex d591a0e46..d40ac8039 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -713,13 +713,13 @@ version = "0.16.0"dependencies = ["anyhow","clap",- "csv","dirs 6.0.0","futures","harper-comments","harper-core","harper-html","harper-literate-haskell",+ "harper-stats","harper-typst","itertools 0.14.0","once_cell",@@ -731,6 +731,15 @@ dependencies = ["tower-lsp","tracing","tracing-subscriber",+]++[[package]]+name = "harper-stats"+version = "0.16.0"+dependencies = [+ "csv",+ "harper-core",+ "serde","uuid",]diff --git a/Cargo.toml b/Cargo.tomlindex 05f7ccd19..a9a573eae 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,5 +1,5 @@[workspace]-members = [ "harper-cli", "harper-core", "harper-ls", "harper-comments", "harper-wasm", "harper-tree-sitter", "harper-html", "harper-literate-haskell", "harper-typst" ]+members = [ "harper-cli", "harper-core", "harper-ls", "harper-comments", "harper-wasm", "harper-tree-sitter", "harper-html", "harper-literate-haskell", "harper-typst" , "harper-stats"]resolver = "2"[profile.release]diff --git a/harper-ls/Cargo.toml b/harper-ls/Cargo.tomlindex 97841bd1c..1a594448b 100644--- a/harper-ls/Cargo.toml+++ b/harper-ls/Cargo.toml@@ -10,6 +10,7 @@ repository = "https://github.com/automattic/harper"[dependencies]harper-literate-haskell = { path = "../harper-literate-haskell", version = "0.16.0" }harper-core = { path = "../harper-core", version = "0.16.0", features = ["concurrent"] }+harper-stats = { path = "../harper-stats", version = "0.16.0" }harper-comments = { path = "../harper-comments", version = "0.16.0" }harper-typst = { path = "../harper-typst", version = "0.16.0" }harper-html = { path = "../harper-html", version = "0.16.0" }@@ -27,8 +28,6 @@ resolve-path = "0.1.0"open = "5.3.0"futures = "0.3.31"serde = { version = "1.0.214", features = ["derive"] }-uuid = { version = "1.12.0", features = ["serde", "v4"] }-csv = "1.3.1"[features]default = []diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rsindex d493d2ff9..d82f82c4c 100644--- a/harper-ls/src/backend.rs+++ b/harper-ls/src/backend.rs@@ -40,7 +40,7 @@ use crate::dictionary_io::{load_dict, save_dict};use crate::document_state::DocumentState;use crate::git_commit_parser::GitCommitParser;use crate::pos_conv::range_to_span;-use crate::stats::{LintRecord, Stats};+use harper_stats::{LintRecord, Stats};pub struct Backend {client: Client,diff --git a/harper-ls/src/main.rs b/harper-ls/src/main.rsindex ad725e79e..31ed9f372 100644--- a/harper-ls/src/main.rs+++ b/harper-ls/src/main.rs@@ -11,7 +11,6 @@ mod dictionary_io;mod document_state;mod git_commit_parser;mod pos_conv;-mod stats;use backend::Backend;use clap::Parser;@@ -33,7 +32,7 @@ struct Args {stdio: bool,}-// Setting worker threads to 4 means the process will use about 5 threads total+// Setting worker threads to four means the process will use about five threads total// This is because worker threads do not include blocking threads#[tokio::main(worker_threads = 4)]async fn main() -> anyhow::Result<()> {diff --git a/harper-stats/Cargo.toml b/harper-stats/Cargo.tomlnew file mode 100644index 000000000..cde8cccff--- /dev/null+++ b/harper-stats/Cargo.toml@@ -0,0 +1,10 @@+[package]+name = "harper-stats"+version = "0.16.0"+edition = "2021"++[dependencies]+serde = { version = "1.0.217", features = ["derive"] }+harper-core = { path = "../harper-core", version = "0.16.0", features = ["concurrent"] }+uuid = { version = "1.12.0", features = ["serde", "v4"] }+csv = "1.3.1"diff --git a/harper-ls/src/stats/mod.rs b/harper-stats/src/lib.rssimilarity index 95%rename from harper-ls/src/stats/mod.rsrename to harper-stats/src/lib.rsindex 88a5b0dff..0e4db6887 100644--- a/harper-ls/src/stats/mod.rs+++ b/harper-stats/src/lib.rs@@ -1,9 +1,8 @@mod lint_record;-use std::io::Write;+use std::io::{self, Write};pub use lint_record::LintRecord;-use tokio::io;pub struct Stats {/// A record of the lints the user has applied.diff --git a/harper-ls/src/stats/lint_record.rs b/harper-stats/src/lint_record.rssimilarity index 100%rename from harper-ls/src/stats/lint_record.rsrename to harper-stats/src/lint_record.rs