aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-05 03:17:01 +0900
committernsfisis <nsfisis@gmail.com>2026-06-05 03:17:01 +0900
commit53800ab77565de1c16fb8a95e047eba1cb3a160c (patch)
tree9dbfa9f098f7c2b75651c16220d3c57a9bbbd1a1 /crates/shirabe-external-packages/src
parent9a25fcfc82b72f60facd381786ca5490acca032c (diff)
downloadphp-shirabe-53800ab77565de1c16fb8a95e047eba1cb3a160c.tar.gz
php-shirabe-53800ab77565de1c16fb8a95e047eba1cb3a160c.tar.zst
php-shirabe-53800ab77565de1c16fb8a95e047eba1cb3a160c.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src')
-rw-r--r--crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs37
1 files changed, 32 insertions, 5 deletions
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<String>,
+ pub token: Option<ParsingExceptionToken>,
+ pub line: Option<i64>,
+ pub loc: Option<ParsingExceptionLoc>,
+ pub expected: Option<Vec<String>>,
+}
+
#[derive(Debug)]
pub struct ParsingException {
pub message: String,
pub code: i64,
+ pub(crate) details: ParsingExceptionDetails,
}
impl ParsingException {
- pub fn new(message: String, _details: Option<shirabe_php_shim::PhpMixed>) -> 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<String, shirabe_php_shim::PhpMixed> {
- // TODO(phase-b): PHP ParsingException exposes ['text', 'line', 'token'] details
- indexmap::IndexMap::new()
+ pub fn get_details(&self) -> &ParsingExceptionDetails {
+ &self.details
}
}