Skip to content

Commit

Permalink
fix: update jsonc-parser to 0.26 (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Oct 21, 2024
1 parent 05dd3e3 commit 23782b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tracing = ["dprint-core/tracing"]
anyhow = "1.0.64"
dprint-core = { version = "0.66.2", features = ["formatting"] }
dprint-core-macros = "0.1.0"
jsonc-parser = { version = "0.23.0" }
jsonc-parser = { version = "0.26.0" }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
text_lines = "0.6.0"
Expand Down
7 changes: 4 additions & 3 deletions src/format_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dprint_core::configuration::resolve_new_line_kind;
use dprint_core::formatting::PrintOptions;
use jsonc_parser::parse_to_ast;
use jsonc_parser::CollectOptions;
use jsonc_parser::CommentCollectionStrategy;
use jsonc_parser::ParseResult;

use super::configuration::Configuration;
Expand Down Expand Up @@ -48,16 +49,16 @@ fn parse(text: &str) -> Result<ParseResult<'_>> {
let parse_result = parse_to_ast(
text,
&CollectOptions {
comments: true,
comments: CommentCollectionStrategy::Separate,
tokens: true,
},
&Default::default(),
);
match parse_result {
Ok(result) => Ok(result),
Err(err) => bail!(dprint_core::formatting::utils::string_utils::format_diagnostic(
Some((err.range.start, err.range.end)),
&err.message,
Some((err.range().start, err.range().end)),
&err.kind().to_string(),
text,
)),
}
Expand Down
10 changes: 5 additions & 5 deletions src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn gen_object<'a>(obj: &'a Object, context: &mut Context<'a, '_>) -> PrintItems
open_token: sc!("{"),
close_token: sc!("}"),
range: obj.range,
first_member: obj.properties.first().map(|f| &f.range),
first_member: obj.properties.first().map(|f| f.range()),
prefer_single_line_when_empty: false,
},
context,
Expand Down Expand Up @@ -276,7 +276,7 @@ fn gen_comma_separated_values<'a>(
|| match context.config.trailing_commas {
TrailingCommaKind::Always => true,
TrailingCommaKind::Maintain => match &value {
Some(value) => context.token_finder.get_next_token_if_comma(value.range()).is_some(),
Some(value) => context.token_finder.get_next_token_if_comma(&value.range()).is_some(),
None => false,
},
TrailingCommaKind::Jsonc => context.is_jsonc,
Expand Down Expand Up @@ -356,17 +356,17 @@ fn gen_comma_separated_value<'a>(
}
}

struct GenSurroundedByTokensOptions<'a> {
struct GenSurroundedByTokensOptions {
open_token: &'static StringContainer,
close_token: &'static StringContainer,
range: Range,
first_member: Option<&'a Range>,
first_member: Option<Range>,
prefer_single_line_when_empty: bool,
}

fn gen_surrounded_by_tokens<'a, 'b>(
gen_inner: impl FnOnce(&mut Context<'a, 'b>) -> PrintItems,
opts: GenSurroundedByTokensOptions<'a>,
opts: GenSurroundedByTokensOptions,
context: &mut Context<'a, 'b>,
) -> PrintItems {
let open_token_end = opts.range.start + opts.open_token.text.len();
Expand Down

0 comments on commit 23782b7

Please sign in to comment.