Skip to content

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

feat(fst-dict): use FstDictionary as the curated dictionary

Grant Lemons42da7e5cf20d
diff --git a/harper-comments/tests/language_support.rs b/harper-comments/tests/language_support.rs
index f6d9fb580..ca9df0a3e 100644
--- a/harper-comments/tests/language_support.rs
+++ b/harper-comments/tests/language_support.rs
@@ -2,7 +2,7 @@ use std::path::Path;
use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
-use harper_core::{Document, FullDictionary};
+use harper_core::{Document, FstDictionary};
/// Creates a unit test checking that the linting of a source file in
/// `language_support_sources` produces the expected number of lints.
@@ -21,7 +21,7 @@ macro_rules! create_test {
);
let mut parser = CommentParser::new_from_filename(Path::new(filename)).unwrap();
- let dict = FullDictionary::curated();
+ let dict = FstDictionary::curated();
let document = Document::new(&source, &mut parser, &dict);
let mut linter = LintGroup::new(
diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rs
index 7aca024aa..a0b90f870 100644
--- a/harper-core/src/spell/full_dictionary.rs
+++ b/harper-core/src/spell/full_dictionary.rs
@@ -67,7 +67,7 @@ impl FullDictionary {
/// Create a dictionary from the curated dictionary included
/// in the Harper binary.
- pub fn curated() -> Arc<Self> {
+ pub(super) fn curated() -> Arc<Self> {
DICT.with(|v| v.clone())
}
diff --git a/harper-core/tests/run_tests.rs b/harper-core/tests/run_tests.rs
index a4da51d67..058b039d7 100644
--- a/harper-core/tests/run_tests.rs
+++ b/harper-core/tests/run_tests.rs
@@ -1,5 +1,5 @@
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
-use harper_core::{Document, FullDictionary};
+use harper_core::{Document, FstDictionary};
/// Creates a unit test checking that the linting of a Markdown document (in
/// `tests_sources`) produces the expected number of lints.
@@ -15,7 +15,7 @@ macro_rules! create_test {
)
);
- let dict = FullDictionary::curated();
+ let dict = FstDictionary::curated();
let document = Document::new_markdown(&source, &dict);
let mut linter = LintGroup::new(
diff --git a/harper-html/tests/run_tests.rs b/harper-html/tests/run_tests.rs
index 94c9e7313..7d6aec2bc 100644
--- a/harper-html/tests/run_tests.rs
+++ b/harper-html/tests/run_tests.rs
@@ -1,5 +1,5 @@
use harper_core::linting::{LintGroup, LintGroupConfig, Linter};
-use harper_core::{Document, FullDictionary};
+use harper_core::{Document, FstDictionary};
/// Creates a unit test checking that the linting of a Markdown document (in
/// `tests_sources`) produces the expected number of lints.
@@ -15,7 +15,7 @@ macro_rules! create_test {
)
);
- let dict = FullDictionary::curated();
+ let dict = FstDictionary::curated();
let document = Document::new_markdown(&source, &dict);
let mut linter = LintGroup::new(
diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs
index 533729ce1..7c914479f 100644
--- a/harper-ls/src/backend.rs
+++ b/harper-ls/src/backend.rs
@@ -7,7 +7,8 @@ use harper_comments::CommentParser;
use harper_core::linting::{LintGroup, Linter};
use harper_core::parsers::{CollapseIdentifiers, IsolateEnglish, Markdown, Parser, PlainEnglish};
use harper_core::{
- Dictionary, Document, FullDictionary, MergedDictionary, Token, TokenKind, WordMetadata,
+ Dictionary, Document, FstDictionary, FullDictionary, MergedDictionary, Token, TokenKind,
+ WordMetadata,
};
use harper_html::HtmlParser;
use serde_json::Value;
@@ -106,7 +107,7 @@ impl Backend {
async fn generate_global_dictionary(&self) -> anyhow::Result<MergedDictionary> {
let mut dict = MergedDictionary::new();
- dict.add_dictionary(FullDictionary::curated());
+ dict.add_dictionary(FstDictionary::curated());
let user_dict = self.load_user_dictionary().await;
dict.add_dictionary(Arc::new(user_dict));
Ok(dict)