diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx index ad264220..58f4d6d5 100644 --- a/src/app/components/generator/McdocRenderer.tsx +++ b/src/app/components/generator/McdocRenderer.tsx @@ -2,29 +2,37 @@ import * as core from '@spyglassmc/core' import type { JsonNode } from '@spyglassmc/json' import * as json from '@spyglassmc/json' import { JsonArrayNode, JsonBooleanNode, JsonNumberNode, JsonObjectNode, JsonStringNode } from '@spyglassmc/json' -import type { ListType, LiteralType, McdocType, NumericType } from '@spyglassmc/mcdoc' +import type { ListType, LiteralType, McdocType, NumericType, PrimitiveArrayType } from '@spyglassmc/mcdoc' +import { TypeDefSymbolData } from '@spyglassmc/mcdoc/lib/binder/index.js' import type { SimplifiedStructType } from '@spyglassmc/mcdoc/lib/runtime/checker/index.js' import { useCallback } from 'preact/hooks' +import type { TextDocument } from 'vscode-languageserver-textdocument' import { useLocale } from '../../contexts/Locale.jsx' import type { AstEdit } from '../../services/Spyglass.js' import { Octicon } from '../Octicon.jsx' +export interface McdocContext { + doc: TextDocument, + symbols: core.SymbolUtil, +} + interface Props { node: JsonNode | undefined makeEdit: (edit: AstEdit) => void + ctx: McdocContext } -export function McdocRoot({ node, makeEdit } : Props) { +export function McdocRoot({ node, makeEdit, ctx } : Props) { const type = node?.typeDef ?? { kind: 'unsafe' } if (type.kind === 'struct') { - return + return } return <>
- +
- + } @@ -32,11 +40,11 @@ interface HeadProps extends Props { simpleType: McdocType optional?: boolean } -function Head({ simpleType, optional, node, makeEdit }: HeadProps) { +function Head({ simpleType, optional, node, makeEdit, ctx }: HeadProps) { const { locale } = useLocale() const type = node?.typeDef ?? simpleType if (type.kind === 'string') { - return + return } if (type.kind === 'enum') { const value = JsonStringNode.is(node) ? node.value : undefined @@ -48,10 +56,10 @@ function Head({ simpleType, optional, node, makeEdit }: HeadProps) { } if (type.kind === 'byte' || type.kind === 'short' || type.kind === 'int' || type.kind === 'long' || type.kind === 'float' || type.kind === 'double') { - return + return } if (type.kind === 'boolean') { - return + return } if (type.kind === 'union') { return