Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

Revert "feat(harper-lib): move some things into harper_lib and adjust everything accordingly"

Elijah Potter2eeee7fa4598
diff --git a/Cargo.lock b/Cargo.lock
index 7181cd2ce..b43018a8a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -570,7 +570,6 @@ version = "0.12.0"
dependencies = [
"harper-core",
"harper-html",
- "harper-lib",
"harper-tree-sitter",
"itertools 0.13.0",
"paste",
@@ -600,7 +599,6 @@ dependencies = [
"criterion",
"fst",
"harper-dictionary-parsing",
- "harper-lib",
"hashbrown 0.15.0",
"is-macro",
"itertools 0.13.0",
@@ -621,8 +619,8 @@ dependencies = [
name = "harper-dictionary-parsing"
version = "0.12.0"
dependencies = [
- "harper-lib",
"hashbrown 0.15.0",
+ "is-macro",
"serde",
"serde_json",
"smallvec",
@@ -640,15 +638,6 @@ dependencies = [
"tree-sitter-html",
]
-[[package]]
-name = "harper-lib"
-version = "0.12.0"
-dependencies = [
- "is-macro",
- "serde",
- "smallvec",
-]
-
[[package]]
name = "harper-ls"
version = "0.12.0"
@@ -660,7 +649,6 @@ dependencies = [
"harper-comments",
"harper-core",
"harper-html",
- "harper-lib",
"itertools 0.13.0",
"once_cell",
"open",
@@ -678,7 +666,6 @@ name = "harper-tree-sitter"
version = "0.12.0"
dependencies = [
"harper-core",
- "harper-lib",
"tree-sitter",
]
@@ -688,7 +675,6 @@ version = "0.1.0"
dependencies = [
"console_error_panic_hook",
"harper-core",
- "harper-lib",
"once_cell",
"serde-wasm-bindgen",
"tracing",
diff --git a/harper-comments/Cargo.toml b/harper-comments/Cargo.toml
index 34bbf5d6f..108ca51fa 100644
--- a/harper-comments/Cargo.toml
+++ b/harper-comments/Cargo.toml
@@ -8,7 +8,6 @@ readme = "README.md"
repository = "https://github.com/elijah-potter/harper"
[dependencies]
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-core = { path = "../harper-core", version = "0.12.0" }
harper-html = { path = "../harper-html", version = "0.12.0" }
harper-tree-sitter = { path = "../harper-tree-sitter", version = "0.12.0" }
diff --git a/harper-comments/src/comment_parsers/jsdoc.rs b/harper-comments/src/comment_parsers/jsdoc.rs
index b53d3b9a2..33e4858ae 100644
--- a/harper-comments/src/comment_parsers/jsdoc.rs
+++ b/harper-comments/src/comment_parsers/jsdoc.rs
@@ -1,6 +1,5 @@
use harper_core::parsers::{Markdown, Parser};
-use harper_core::{Punctuation, Token, TokenKind};
-use harper_lib::Span;
+use harper_core::{Punctuation, Span, Token, TokenKind};
use itertools::Itertools;
use super::without_initiators;
diff --git a/harper-comments/src/comment_parsers/mod.rs b/harper-comments/src/comment_parsers/mod.rs
index af7adca38..f39c5bd24 100644
--- a/harper-comments/src/comment_parsers/mod.rs
+++ b/harper-comments/src/comment_parsers/mod.rs
@@ -4,7 +4,7 @@ mod jsdoc;
mod unit;
pub use go::Go;
-use harper_lib::Span;
+use harper_core::Span;
pub use javadoc::JavaDoc;
pub use jsdoc::JsDoc;
pub use unit::Unit;
diff --git a/harper-comments/src/comment_parsers/unit.rs b/harper-comments/src/comment_parsers/unit.rs
index 9735e8705..324225ca5 100644
--- a/harper-comments/src/comment_parsers/unit.rs
+++ b/harper-comments/src/comment_parsers/unit.rs
@@ -1,6 +1,5 @@
use harper_core::parsers::{Markdown, Parser};
-use harper_core::Token;
-use harper_lib::Span;
+use harper_core::{Span, Token};
use super::without_initiators;
diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.toml
index 7eb641d72..7ad5162ac 100644
--- a/harper-core/Cargo.toml
+++ b/harper-core/Cargo.toml
@@ -12,7 +12,6 @@ name = "force-build"
path = "build.rs"
[dependencies]
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-dictionary-parsing = { path = "../harper-dictionary-parsing", version = "0.12.0" }
blanket = "0.4.0"
fst = "0.4.7"
@@ -36,7 +35,6 @@ rand = "0.8.5"
[build-dependencies]
fst = "0.4.7"
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-dictionary-parsing = { path = "../harper-dictionary-parsing", version = "0.12.0" }
hashbrown = { version = "0.15.0" }
itertools = "0.13.0"
diff --git a/harper-core/build.rs b/harper-core/build.rs
index fddb69a0a..996df9bd9 100644
--- a/harper-core/build.rs
+++ b/harper-core/build.rs
@@ -2,8 +2,9 @@ use std::fs::File;
use std::io;
use fst::MapBuilder;
-use harper_dictionary_parsing::{parse_default_attribute_list, parse_default_word_list};
-use harper_lib::CharString;
+use harper_dictionary_parsing::{
+ parse_default_attribute_list, parse_default_word_list, CharString,
+};
use hashbrown::HashMap;
use itertools::Itertools;
diff --git a/harper-core/src/lib.rs b/harper-core/src/lib.rs
index 493cae690..ac55825b7 100644
--- a/harper-core/src/lib.rs
+++ b/harper-core/src/lib.rs
@@ -18,6 +18,9 @@ mod vec_ext;
use std::collections::VecDeque;
pub use document::Document;
+pub use harper_dictionary_parsing::char_string::{CharString, CharStringExt};
+pub use harper_dictionary_parsing::span::Span;
+pub use harper_dictionary_parsing::{word_metadata::Tense, WordMetadata};
use linting::Lint;
pub use mask::{Mask, Masker};
pub use punctuation::{Punctuation, Quote};
@@ -26,10 +29,6 @@ pub use sync::Lrc;
pub use token::{FatToken, Token, TokenKind, TokenStringExt};
pub use vec_ext::VecExt;
-use harper_lib::Span;
-use harper_lib::WordMetadata;
-use harper_lib::{CharString, CharStringExt};
-
/// A utility function that removes overlapping lints in a vector,
/// keeping the more important ones.
///
diff --git a/harper-core/src/spell/fst_dictionary.rs b/harper-core/src/spell/fst_dictionary.rs
index 59cea11aa..9ae2dcc03 100644
--- a/harper-core/src/spell/fst_dictionary.rs
+++ b/harper-core/src/spell/fst_dictionary.rs
@@ -1,12 +1,11 @@
use super::{seq_to_normalized, FullDictionary};
use fst::{map::StreamWithState, IntoStreamer, Map as FstMap, Streamer};
-use harper_lib::CharStringExt;
use hashbrown::HashMap;
use itertools::Itertools;
use levenshtein_automata::{LevenshteinAutomatonBuilder, DFA};
use std::{cell::RefCell, sync::Arc};
-use crate::{CharString, WordMetadata};
+use crate::{CharString, CharStringExt, WordMetadata};
use super::Dictionary;
@@ -186,10 +185,9 @@ impl Dictionary for FstDictionary {
#[cfg(test)]
mod tests {
- use harper_lib::CharStringExt;
use itertools::Itertools;
- use crate::{spell::seq_to_normalized, Dictionary};
+ use crate::{spell::seq_to_normalized, CharStringExt, Dictionary};
use super::FstDictionary;
diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rs
index 43d318121..fd9fc9772 100644
--- a/harper-core/src/spell/full_dictionary.rs
+++ b/harper-core/src/spell/full_dictionary.rs
@@ -1,12 +1,11 @@
use super::{edit_distance_min_alloc, seq_to_normalized};
-use harper_lib::CharStringExt;
use hashbrown::HashMap;
use itertools::Itertools;
use smallvec::{SmallVec, ToSmallVec};
use std::sync::Arc;
use super::dictionary::Dictionary;
-use crate::{CharString, WordMetadata};
+use crate::{CharString, CharStringExt, WordMetadata};
use harper_dictionary_parsing::{parse_default_attribute_list, parse_default_word_list};
/// A full, fat dictionary.
@@ -249,7 +248,7 @@ impl Dictionary for FullDictionary {
#[cfg(test)]
mod tests {
- use harper_lib::CharString;
+ use harper_dictionary_parsing::CharString;
use itertools::Itertools;
use crate::{Dictionary, FullDictionary};
diff --git a/harper-core/src/spell/merged_dictionary.rs b/harper-core/src/spell/merged_dictionary.rs
index 717e064f3..6569b3ab3 100644
--- a/harper-core/src/spell/merged_dictionary.rs
+++ b/harper-core/src/spell/merged_dictionary.rs
@@ -1,6 +1,5 @@
-use std::sync::Arc;
-
use itertools::Itertools;
+use std::sync::Arc;
use super::dictionary::Dictionary;
use crate::{CharString, WordMetadata};
diff --git a/harper-core/src/token.rs b/harper-core/src/token.rs
index dd0ca2fc6..74efdcc5e 100644
--- a/harper-core/src/token.rs
+++ b/harper-core/src/token.rs
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::punctuation::Punctuation;
use crate::Span;
use crate::{Quote, WordMetadata};
-use harper_lib::word_metadata::{ConjunctionData, NounData};
+use harper_dictionary_parsing::word_metadata::{ConjunctionData, NounData};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Default)]
pub struct Token {
diff --git a/harper-dictionary-parsing/Cargo.toml b/harper-dictionary-parsing/Cargo.toml
index 06254e3dc..1b6de9a07 100644
--- a/harper-dictionary-parsing/Cargo.toml
+++ b/harper-dictionary-parsing/Cargo.toml
@@ -7,8 +7,8 @@ license = "Apache-2.0"
repository = "https://github.com/elijah-potter/harper"
[dependencies]
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
hashbrown = { version = "0.15.0", features = ["serde"] }
+is-macro = "0.3.6"
serde = { version = "1.0.209", features = ["derive"] }
serde_json = "1.0.132"
smallvec = { version = "1.13.2", features = ["serde"] }
diff --git a/harper-dictionary-parsing/src/attribute_list.rs b/harper-dictionary-parsing/src/attribute_list.rs
index eabe0ce68..182d29fbb 100644
--- a/harper-dictionary-parsing/src/attribute_list.rs
+++ b/harper-dictionary-parsing/src/attribute_list.rs
@@ -6,7 +6,7 @@ use super::affix_replacement::AffixReplacement;
use super::expansion::{Expansion, HumanReadableExpansion};
use super::word_list::MarkedWord;
use super::Error;
-use harper_lib::{CharString, Span, WordMetadata};
+use crate::{CharString, Span, WordMetadata};
#[derive(Debug, Clone)]
pub struct AttributeList {
diff --git a/harper-lib/src/char_string.rs b/harper-dictionary-parsing/src/char_string.rs
similarity index 100%
rename from harper-lib/src/char_string.rs
rename to harper-dictionary-parsing/src/char_string.rs
diff --git a/harper-dictionary-parsing/src/expansion.rs b/harper-dictionary-parsing/src/expansion.rs
index c0f22dc28..3711681b9 100644
--- a/harper-dictionary-parsing/src/expansion.rs
+++ b/harper-dictionary-parsing/src/expansion.rs
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use super::affix_replacement::{AffixReplacement, HumanReadableAffixReplacement};
use super::Error;
-use harper_lib::WordMetadata;
+use crate::WordMetadata;
#[derive(Debug, Clone)]
pub struct Expansion {
diff --git a/harper-dictionary-parsing/src/lib.rs b/harper-dictionary-parsing/src/lib.rs
index 1d0b0efd9..f3f132f4a 100644
--- a/harper-dictionary-parsing/src/lib.rs
+++ b/harper-dictionary-parsing/src/lib.rs
@@ -1,14 +1,22 @@
mod affix_replacement;
mod attribute_list;
+pub mod char_string;
mod error;
mod expansion;
mod matcher;
-mod word_list;
+pub mod span;
+pub mod word_list;
+pub mod word_metadata;
pub use attribute_list::AttributeList;
use attribute_list::HumanReadableAttributeList;
+pub use char_string::{CharString, CharStringExt};
pub use error::Error;
-pub use word_list::{parse_word_list, MarkedWord};
+pub use span::Span;
+pub use word_metadata::WordMetadata;
+
+use self::word_list::parse_word_list;
+pub use self::word_list::MarkedWord;
pub fn parse_default_word_list() -> Result<Vec<MarkedWord>, Error> {
parse_word_list(include_str!("../dictionary.dict"))
@@ -32,7 +40,7 @@ mod tests {
use super::word_list::parse_word_list;
use super::{parse_default_attribute_list, parse_default_word_list};
use crate::attribute_list::HumanReadableAttributeList;
- use harper_lib::{CharString, WordMetadata};
+ use crate::{CharString, WordMetadata};
pub const TEST_WORD_LIST: &str = "3\nhello\ntry/B\nwork/AB";
diff --git a/harper-lib/src/span.rs b/harper-dictionary-parsing/src/span.rs
similarity index 100%
rename from harper-lib/src/span.rs
rename to harper-dictionary-parsing/src/span.rs
diff --git a/harper-dictionary-parsing/src/word_list.rs b/harper-dictionary-parsing/src/word_list.rs
index 03155b408..7d7240f95 100644
--- a/harper-dictionary-parsing/src/word_list.rs
+++ b/harper-dictionary-parsing/src/word_list.rs
@@ -1,5 +1,5 @@
use super::Error;
-use harper_lib::CharString;
+use crate::CharString;
#[derive(Debug, Clone)]
pub struct MarkedWord {
diff --git a/harper-lib/src/word_metadata.rs b/harper-dictionary-parsing/src/word_metadata.rs
similarity index 100%
rename from harper-lib/src/word_metadata.rs
rename to harper-dictionary-parsing/src/word_metadata.rs
diff --git a/harper-lib/Cargo.toml b/harper-lib/Cargo.toml
index b5f028c1d..18de14d36 100644
--- a/harper-lib/Cargo.toml
+++ b/harper-lib/Cargo.toml
@@ -1,9 +1,6 @@
[package]
name = "harper-lib"
-version = "0.12.0"
+version = "0.1.0"
edition = "2021"
[dependencies]
-is-macro = "0.3.6"
-serde = { version = "1.0.209", features = ["derive"] }
-smallvec = { version = "1.13.2", features = ["serde"] }
diff --git a/harper-lib/src/lib.rs b/harper-lib/src/lib.rs
index 3fddb6303..b93cf3ffd 100644
--- a/harper-lib/src/lib.rs
+++ b/harper-lib/src/lib.rs
@@ -1,7 +1,14 @@
-mod char_string;
-mod span;
-pub mod word_metadata;
+pub fn add(left: u64, right: u64) -> u64 {
+ left + right
+}
-pub use char_string::{CharString, CharStringExt};
-pub use span::Span;
-pub use word_metadata::WordMetadata;
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn it_works() {
+ let result = add(2, 2);
+ assert_eq!(result, 4);
+ }
+}
diff --git a/harper-ls/Cargo.toml b/harper-ls/Cargo.toml
index dd671b9af..5003c6068 100644
--- a/harper-ls/Cargo.toml
+++ b/harper-ls/Cargo.toml
@@ -8,7 +8,6 @@ readme = "README.md"
repository = "https://github.com/elijah-potter/harper"
[dependencies]
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-core = { path = "../harper-core", version = "0.12.0", features = ["concurrent"] }
harper-comments = { path = "../harper-comments", version = "0.12.0" }
harper-html = { path = "../harper-html", version = "0.12.0" }
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 170a54dbc..7c914479f 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -8,9 +8,9 @@ use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::{CollapseIdentifiers, IsolateEnglish, Markdown, Parser, PlainEnglish};
use harper_core::{
Dictionary, Document, FstDictionary, FullDictionary, MergedDictionary, Token, TokenKind,
+ WordMetadata,
};
use harper_html::HtmlParser;
-use harper_lib::WordMetadata;
use serde_json::Value;
use tokio::sync::{Mutex, RwLock};
use tower_lsp::jsonrpc::Result;
diff --git a/harper-ls/src/dictionary_io.rs b/harper-ls/src/dictionary_io.rs
index 2c001274a..0884a911e 100644
--- a/harper-ls/src/dictionary_io.rs
+++ b/harper-ls/src/dictionary_io.rs
@@ -1,7 +1,6 @@
use std::path::Path;
-use harper_core::{Dictionary, FullDictionary};
-use harper_lib::WordMetadata;
+use harper_core::{Dictionary, FullDictionary, WordMetadata};
use tokio::fs::{self, File};
use tokio::io::{self, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufReader, BufWriter};
diff --git a/harper-ls/src/pos_conv.rs b/harper-ls/src/pos_conv.rs
index 062b5c644..93b9e11c0 100644
--- a/harper-ls/src/pos_conv.rs
+++ b/harper-ls/src/pos_conv.rs
@@ -1,4 +1,4 @@
-use harper_lib::Span;
+use harper_core::Span;
use tower_lsp::lsp_types::{Position, Range};
/// This module includes various conversions from the index-based [`Span`]s that
diff --git a/harper-tree-sitter/Cargo.toml b/harper-tree-sitter/Cargo.toml
index 5ef613b58..bec99fc23 100644
--- a/harper-tree-sitter/Cargo.toml
+++ b/harper-tree-sitter/Cargo.toml
@@ -7,6 +7,5 @@ license = "Apache-2.0"
repository = "https://github.com/elijah-potter/harper"
[dependencies]
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-core = { path = "../harper-core", version = "0.12.0" }
tree-sitter = "0.20.10"
diff --git a/harper-tree-sitter/src/lib.rs b/harper-tree-sitter/src/lib.rs
index 037974b5e..abb09aa88 100644
--- a/harper-tree-sitter/src/lib.rs
+++ b/harper-tree-sitter/src/lib.rs
@@ -1,7 +1,6 @@
use std::collections::HashSet;
-use harper_core::{FullDictionary, Mask, Masker};
-use harper_lib::{Span, WordMetadata};
+use harper_core::{FullDictionary, Mask, Masker, Span, WordMetadata};
use tree_sitter::{Language, Node, Tree, TreeCursor};
/// A Harper [`Masker`] that wraps a given tree-sitter language and a condition,
diff --git a/harper-wasm/Cargo.toml b/harper-wasm/Cargo.toml
index dc88ecc96..6a79bc160 100644
--- a/harper-wasm/Cargo.toml
+++ b/harper-wasm/Cargo.toml
@@ -14,7 +14,6 @@ console_error_panic_hook = "0.1.7"
tracing = "0.1.40"
tracing-wasm = "0.2.1"
wasm-bindgen = "0.2.95"
-harper-lib = { path = "../harper-lib", version = "0.12.0" }
harper-core = { path = "../harper-core", version = "0.12.0", features = ["concurrent"] }
once_cell = "1.20.2"
serde-wasm-bindgen = "0.6.5"
diff --git a/harper-wasm/src/lib.rs b/harper-wasm/src/lib.rs
index 895dd5b7e..7a404504c 100644
--- a/harper-wasm/src/lib.rs
+++ b/harper-wasm/src/lib.rs
@@ -6,7 +6,6 @@ use harper_core::language_detection::is_doc_likely_english;
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
use harper_core::parsers::{IsolateEnglish, Markdown, PlainEnglish};
use harper_core::{remove_overlaps, Document, FstDictionary, Lrc};
-use harper_lib::Span as HarperSpan;
use once_cell::sync::Lazy;
use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsValue;
@@ -87,7 +86,7 @@ pub fn apply_suggestion(
suggestion: &Suggestion,
) -> Result<String, String> {
let mut source: Vec<_> = text.chars().collect();
- let span: HarperSpan = span.into();
+ let span: harper_core::Span = span.into();
suggestion.inner.apply(span, &mut source);
@@ -185,14 +184,14 @@ impl Span {
}
}
-impl From<HarperSpan> for Span {
- fn from(value: HarperSpan) -> Self {
- Span::new(value.start, value.end)
+impl From<Span> for harper_core::Span {
+ fn from(value: Span) -> Self {
+ harper_core::Span::new(value.start, value.end)
}
}
-impl From<Span> for HarperSpan {
- fn from(value: Span) -> Self {
- HarperSpan::new(value.start, value.end)
+impl From<harper_core::Span> for Span {
+ fn from(value: harper_core::Span) -> Self {
+ Span::new(value.start, value.end)
}
}