mirror of
https://github.com/crate-ci/typos.git
synced 2026-10-19 02:15:10 +02:00
fix(misspell): Update for golangci fork
Pulled from https://github.com/golangci/misspell/tree/e78f9b6cd537559a24525b6ea7e182794edfd31f
This commit is contained in:
Generated
+10
-3
@@ -807,6 +807,7 @@ dependencies = [
|
||||
"codegenrs",
|
||||
"dictgen",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"snapbox",
|
||||
]
|
||||
|
||||
@@ -1255,16 +1256,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.145"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1997,3 +1998,9 @@ dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fc5a66a20078bf1251bde995aa2fdcc4b800c70b5d92dd2c62abc5c60f679f8"
|
||||
|
||||
@@ -21,6 +21,7 @@ codegenrs = "3.0"
|
||||
regex = "1"
|
||||
dictgen = { version = "^0.5", path = "../dictgen", features = ["codegen"] }
|
||||
snapbox = "0.6.21"
|
||||
serde_json = "1.0.149"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
+44468
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Vendored
-31158
File diff suppressed because it is too large
Load Diff
+32491
-56389
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub const DICT: &str = include_str!("../assets/words.go");
|
||||
pub const MAIN: &str = include_str!("../assets/internal/gen/sources/main.json");
|
||||
pub const US: &str = include_str!("../assets/internal/gen/sources/us.json");
|
||||
pub const UK: &str = include_str!("../assets/internal/gen/sources/uk.json");
|
||||
|
||||
#[test]
|
||||
fn codegen() {
|
||||
@@ -25,7 +27,7 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||
main,
|
||||
american,
|
||||
british,
|
||||
} = parse_dict(DICT);
|
||||
} = parse_dict();
|
||||
|
||||
dictgen::DictGen::new()
|
||||
.name("MAIN_DICTIONARY")
|
||||
@@ -60,53 +62,16 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
struct Words<'s> {
|
||||
main: HashMap<&'s str, Vec<&'s str>>,
|
||||
american: HashMap<&'s str, Vec<&'s str>>,
|
||||
british: HashMap<&'s str, Vec<&'s str>>,
|
||||
struct Words {
|
||||
main: HashMap<String, Vec<String>>,
|
||||
american: HashMap<String, Vec<String>>,
|
||||
british: HashMap<String, Vec<String>>,
|
||||
}
|
||||
|
||||
fn parse_dict(raw: &str) -> Words<'_> {
|
||||
let mut bad = HashMap::new();
|
||||
let mut main = HashMap::new();
|
||||
let mut american = HashMap::new();
|
||||
let mut british = HashMap::new();
|
||||
|
||||
let mapping = regex::Regex::new(r#"^"(.*)", "(.*)",$"#).unwrap();
|
||||
|
||||
let mut current = &mut bad;
|
||||
for line in raw.lines() {
|
||||
let line = line.split_once("//").map(|l| l.0).unwrap_or(line).trim();
|
||||
if line.is_empty() || line.starts_with("package") {
|
||||
continue;
|
||||
} else if line.contains("DictMain") {
|
||||
current = &mut main;
|
||||
} else if line.contains("DictAmerican") {
|
||||
current = &mut american;
|
||||
} else if line.contains("DictBritish") {
|
||||
current = &mut british;
|
||||
} else if line.contains('}') {
|
||||
current = &mut bad;
|
||||
} else {
|
||||
let captures = mapping.captures(line);
|
||||
if let Some(captures) = captures {
|
||||
current.insert(
|
||||
captures.get(1).unwrap().as_str(),
|
||||
vec![captures.get(2).unwrap().as_str()],
|
||||
);
|
||||
} else {
|
||||
eprintln!("Unknown line: {line}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !bad.is_empty() {
|
||||
panic!("Failed parsing; found extra words: {bad:#?}");
|
||||
}
|
||||
|
||||
fn parse_dict() -> Words {
|
||||
Words {
|
||||
main,
|
||||
american,
|
||||
british,
|
||||
main: serde_json::from_str(MAIN).unwrap(),
|
||||
american: serde_json::from_str(US).unwrap(),
|
||||
british: serde_json::from_str(UK).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user