Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/lsp-async-stub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl CancelToken {
self.cancelled.load(Ordering::SeqCst)
}

pub fn as_err(&mut self) -> CancelTokenErr {
pub fn as_err(&mut self) -> CancelTokenErr<'_> {
CancelTokenErr(self)
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/taplo-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
clippy::missing_fields_in_debug,
clippy::similar_names,
clippy::too_many_lines,
clippy::needless_continue
clippy::needless_continue,
clippy::struct_field_names
)]

pub mod config;
Expand Down
4 changes: 2 additions & 2 deletions crates/taplo-common/src/schema/associations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use taplo::dom::Node;
use tokio::sync::Semaphore;
use url::Url;

pub const DEFAULT_CATALOGS: &[&str] = &["https://json.schemastore.org/api/json/catalog.json"];
pub const DEFAULT_CATALOGS: &[&str] = &["https://www.schemastore.org/api/json/catalog.json"];

pub mod priority {
pub const BUILTIN: usize = 10;
Expand Down Expand Up @@ -504,7 +504,7 @@ pub struct SchemaStoreSchemaMeta {
}

pub const SCHEMA_STORE_CATALOG_SCHEMA_URL: &str =
"https://json.schemastore.org/schema-catalog.json";
"https://www.schemastore.org/schema-catalog.json";

#[derive(Debug, Clone, Copy)]
pub struct SchemaStoreCatalogSchema;
Expand Down
2 changes: 1 addition & 1 deletion crates/taplo-common/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Normalize for PathBuf {
}
}

pub(crate) fn normalize_str(s: &str) -> Cow<str> {
pub(crate) fn normalize_str(s: &str) -> Cow<'_, str> {
let Some(percent_decoded) = percent_decode_str(s).decode_utf8().ok() else {
return s.into();
};
Expand Down
5 changes: 1 addition & 4 deletions crates/taplo-lsp/src/handlers/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ pub async fn configuration_change<E: Environment>(
context: Context<World<E>>,
params: Params<DidChangeConfigurationParams>,
) {
let p = match params.optional() {
None => return,
Some(p) => p,
};
let Some(p) = params.optional() else { return };

let mut workspaces = context.workspaces.write().await;

Expand Down
20 changes: 6 additions & 14 deletions crates/taplo-lsp/src/handlers/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ pub(crate) async fn document_open<E: Environment>(
mut context: Context<World<E>>,
params: Params<DidOpenTextDocumentParams>,
) {
let p = match params.optional() {
None => return,
Some(p) => p,
};
let Some(p) = params.optional() else { return };

let mut workspaces = context.workspaces.write().await;
let ws = workspaces.by_document_mut(&p.text_document.uri);
Expand Down Expand Up @@ -91,15 +88,13 @@ pub(crate) async fn document_change<E: Environment>(
mut context: Context<World<E>>,
params: Params<DidChangeTextDocumentParams>,
) {
let mut p = match params.optional() {
None => return,
Some(p) => p,
let Some(mut p) = params.optional() else {
return;
};

// We expect one full change
let change = match p.content_changes.pop() {
None => return,
Some(c) => c,
let Some(change) = p.content_changes.pop() else {
return;
};

let mut workspaces = context.workspaces.write().await;
Expand Down Expand Up @@ -167,10 +162,7 @@ pub(crate) async fn document_close<E: Environment>(
context: Context<World<E>>,
params: Params<DidCloseTextDocumentParams>,
) {
let p = match params.optional() {
None => return,
Some(p) => p,
};
let Some(p) = params.optional() else { return };

let mut workspaces = context.workspaces.write().await;
let ws = workspaces.by_document_mut(&p.text_document.uri);
Expand Down
5 changes: 1 addition & 4 deletions crates/taplo-lsp/src/handlers/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ pub async fn workspace_change<E: Environment>(
context: Context<World<E>>,
params: Params<DidChangeWorkspaceFoldersParams>,
) {
let p = match params.optional() {
None => return,
Some(p) => p,
};
let Some(p) = params.optional() else { return };

let mut workspaces = context.workspaces.write().await;
let init_config = context.init_config.load();
Expand Down
10 changes: 4 additions & 6 deletions crates/taplo-wasm/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ impl AsyncRead for JsAsyncRead {
let ret: JsValue = match self.f.call1(&this, &JsValue::from(buf.remaining())) {
Ok(val) => val,
Err(error) => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
return Poll::Ready(Err(io::Error::other(
format!("{:?}", error),
)));
}
Expand All @@ -58,7 +57,7 @@ impl AsyncRead for JsAsyncRead {

Ok(())
}
Err(err) => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", err))),
Err(err) => Err(io::Error::other(format!("{:?}", err))),
};

self.fut = None;
Expand Down Expand Up @@ -96,8 +95,7 @@ impl AsyncWrite for JsAsyncWrite {
let ret: JsValue = match self.f.call1(&this, &Uint8Array::from(buf).into()) {
Ok(val) => val,
Err(error) => {
return Poll::Ready(Err(io::Error::new(
io::ErrorKind::Other,
return Poll::Ready(Err(io::Error::other(
format!("{:?}", error),
)));
}
Expand All @@ -114,7 +112,7 @@ impl AsyncWrite for JsAsyncWrite {
let n = num_written.as_f64().unwrap_or(0.0).floor() as usize;
Ok(n)
}
Err(err) => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", err))),
Err(err) => Err(io::Error::other(format!("{:?}", err))),
};

self.fut = None;
Expand Down
4 changes: 3 additions & 1 deletion crates/taplo/src/dom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Node {
Node::Table(t) => {
let entries = t.entries().read();
for (key, node) in entries.iter() {
if glob.is_match(pattern) {
if glob.is_match(key.value()) {
matched.push((KeyOrIndex::from(key.clone()), node.clone()));
}
}
Expand Down Expand Up @@ -663,3 +663,5 @@ impl From<Invalid> for Node {
Self::Invalid(v)
}
}


6 changes: 3 additions & 3 deletions crates/taplo/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ pub enum SyntaxKind {
#[regex(r"true|false")]
BOOL,

#[regex(r#"(?:[1-9]\d\d\d-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)-02-29)(?:T|t| )(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(?:\.|,)\d+)?(?:[Zz]|[+-][01]\d:[0-5]\d)"#)]
#[regex(r#"(?:[0-9][0-9][0-9][0-9]-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:(?:[0-9][0-9](?:0[48]|[2468][048]|[13579][26]))|(?:[2468][048]|[13579][26])00)-02-29)(?:T|t| )(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(?:\.|,)\d+)?(?:[Zz]|[+-][01]\d:[0-5]\d)"#)]
DATE_TIME_OFFSET,

#[regex(r#"(?:[1-9]\d\d\d-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)-02-29)(?:T|t| )(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(?:\.|,)\d+)?"#)]
#[regex(r#"(?:[0-9][0-9][0-9][0-9]-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:(?:[0-9][0-9](?:0[48]|[2468][048]|[13579][26]))|(?:[2468][048]|[13579][26])00)-02-29)(?:T|t| )(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(?:\.|,)\d+)?"#)]
DATE_TIME_LOCAL,

#[regex(r#"(?:[1-9]\d\d\d-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00)-02-29)"#)]
#[regex(r#"(?:[0-9][0-9][0-9][0-9]-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1\d|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:(?:[0-9][0-9](?:0[48]|[2468][048]|[13579][26]))|(?:[2468][048]|[13579][26])00)-02-29)"#)]
DATE,

#[regex(r#"(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:(?:\.|,)\d+)?"#)]
Expand Down
32 changes: 32 additions & 0 deletions crates/taplo/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,35 @@ cooldowns = {

assert!(errors.is_empty(), "{:#?}", errors);
}

#[test]
fn get_matches_table_key() {
let src = r#"
name1 = "v"
other = "v2"
"#;

let root = parse(src).into_dom();

let matched: Vec<String> = root
.get_matches("na*")
.unwrap()
.map(|(k, _)| match k {
crate::dom::KeyOrIndex::Key(key) => key.value().to_string(),
crate::dom::KeyOrIndex::Index(idx) => idx.to_string(),
})
.collect();

assert_eq!(matched, vec!["name1"]);
}

#[test]
fn datetime_with_leading_zeros() {
let src = r#"
token_expires_at = 0001-01-01T00:00:00Z
"#;

let errors = parse(src).errors;

assert!(errors.is_empty(), "{:#?}", errors);
}
2 changes: 1 addition & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"type": "string"
},
"default": [
"https://json.schemastore.org/api/json/catalog.json"
"https://www.schemastore.org/api/json/catalog.json"
]
},
"evenBetterToml.schema.associations": {
Expand Down
2 changes: 1 addition & 1 deletion site/site/configuration/developing-schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Other than `fileMatch`, it is also possible to specify `regexMatch` that is matc
"tomlValidation": [
{
"regexMatch": "^.*foo.toml$",
"url": "https://json.schemastore.org/foo.json"
"url": "https://www.schemastore.org/foo.json"
}
]
}
Expand Down