Expand description
Shared JSONC-AST helpers for recovering exact dependency source positions (#613).
deps-npm and deps-composer each parse a JSON manifest’s semantic content
(dependency names, version requirement strings, minimum-stability, …) via
serde_json/crate::parse_json_checked, as before — this module is never a
replacement for that.
What it replaces is how each crate previously recovered a dependency’s position:
substring-scanning the raw manifest text for a section’s byte range, then for each
name/version pattern within it (removed by #613, since it broke down for duplicate keys and
same-named nested values — see find_json_section_byte_range’s removal in this same
change). Reading positions directly off a position-preserving parse tree is correct by
construction regardless of serde_json::Map iteration order, duplicate keys, or nested
value shapes, mirroring crates/deps-deno/src/parser.rs’s original D6 design — generalized
here for the “several named top-level sections” shape (dependencies/devDependencies,
require/require-dev) that deno.json’s single flat imports map doesn’t have.
JsonSection keeps jsonc-parser’s own AST types out of every downstream crate’s public
(and Cargo.toml direct-dependency) surface — only deps-core names jsonc_parser::ast
types directly.
Structs§
- JsonAst
- A parsed JSON/JSONC document, used only to recover a named top-level section’s exact
source positions — never a substitute for a caller’s own
serde_jsonparse of the document’s semantic content. - Json
Section - One top-level section’s direct properties, indexed by name.
Functions§
- find_
last_ prop - Finds the property named
keyamongobject’s own direct children, taking the last one ifkeyoccurs more than once.