From 53800ab77565de1c16fb8a95e047eba1cb3a160c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 03:17:01 +0900 Subject: feat(json-lint): port ParsingException details into a typed struct Replace the Phase B stub that discarded ParsingException details with a dedicated ParsingExceptionDetails struct (text/token/line/loc/expected), modeling the PHP string|int token union as a ParsingExceptionToken enum. Wire JsonFile::validate_syntax to forward the source details and let Application read the error line from the typed accessor. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/seld/json_lint/parsing_exception.rs | 37 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'crates/shirabe-external-packages/src') diff --git a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs index b756c1b..5dca8b6 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs @@ -1,21 +1,48 @@ +#[derive(Debug, Clone, Default)] +pub struct ParsingExceptionLoc { + pub first_line: i64, + pub first_column: i64, + pub last_line: i64, + pub last_column: i64, +} + +#[derive(Debug, Clone)] +pub enum ParsingExceptionToken { + Name(String), + Symbol(i64), +} + +#[derive(Debug, Clone, Default)] +pub struct ParsingExceptionDetails { + pub text: Option, + pub token: Option, + pub line: Option, + pub loc: Option, + pub expected: Option>, +} + #[derive(Debug)] pub struct ParsingException { pub message: String, pub code: i64, + pub(crate) details: ParsingExceptionDetails, } impl ParsingException { - pub fn new(message: String, _details: Option) -> Self { - Self { message, code: 0 } + pub fn new(message: String, details: ParsingExceptionDetails) -> Self { + Self { + message, + code: 0, + details, + } } pub fn get_message(&self) -> &str { &self.message } - pub fn get_details(&self) -> indexmap::IndexMap { - // TODO(phase-b): PHP ParsingException exposes ['text', 'line', 'token'] details - indexmap::IndexMap::new() + pub fn get_details(&self) -> &ParsingExceptionDetails { + &self.details } } -- cgit v1.3.1