From 9066469381ad52b1e7819165f07e781a4450a58f Mon Sep 17 00:00:00 2001
From: Misode
Date: Thu, 24 Oct 2024 05:02:37 +0200
Subject: [PATCH] Add error indicators
---
.../components/generator/McdocRenderer.tsx | 43 ++++++++++++++++++-
src/app/components/generator/Tree.tsx | 12 ++++--
src/app/services/Spyglass.ts | 3 +-
src/locales/en.json | 1 +
src/styles/nodes.css | 11 +++++
5 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx
index 222f44d4..c382bfa0 100644
--- a/src/app/components/generator/McdocRenderer.tsx
+++ b/src/app/components/generator/McdocRenderer.tsx
@@ -9,6 +9,7 @@ import { simplify } from '@spyglassmc/mcdoc/lib/runtime/checker/index.js'
import { getValues } from '@spyglassmc/mcdoc/lib/runtime/completer/index.js'
import { useCallback, useMemo } from 'preact/hooks'
import { useLocale } from '../../contexts/Locale.jsx'
+import { useFocus } from '../../hooks/useFocus.js'
import { generateColor, hexId } from '../../Utils.js'
import { Octicon } from '../Octicon.jsx'
@@ -22,14 +23,17 @@ interface Props {
ctx: McdocContext
}
export function McdocRoot({ node, makeEdit, ctx } : Props) {
+ const { locale } = useLocale()
const type = node?.typeDef ?? { kind: 'unsafe' }
- if (type.kind === 'struct') {
+ if (type.kind === 'struct' && JsonObjectNode.is(node)) {
return
}
return <>
@@ -369,6 +373,9 @@ function Body({ type, optional, node, makeEdit, ctx }: BodyProps) {
return
}
if (type.kind === 'struct') {
+ if (!JsonObjectNode.is(node)) {
+ return <>>
+ }
if (type.fields.length === 0) {
return <>>
}
@@ -470,6 +477,7 @@ function StructBody({ type: outerType, node, makeEdit, ctx }: StructBodyProps) {
}
return
@@ -517,6 +525,7 @@ function ListBody({ type: outerType, node, makeEdit, ctx }: ListBodyProps) {
}
return