diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx
index a1787746..0dee0329 100644
--- a/src/app/components/generator/McdocRenderer.tsx
+++ b/src/app/components/generator/McdocRenderer.tsx
@@ -2,12 +2,14 @@ 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, PrimitiveArrayType, UnionType } from '@spyglassmc/mcdoc'
+import type { ListType, LiteralType, McdocType, NumericType, PrimitiveArrayType, StringType, UnionType } from '@spyglassmc/mcdoc'
import { TypeDefSymbolData } from '@spyglassmc/mcdoc/lib/binder/index.js'
import type { McdocCheckerContext, SimplifiedEnum, SimplifiedMcdocType, SimplifiedMcdocTypeNoUnion, SimplifiedStructType, SimplifyValueNode } from '@spyglassmc/mcdoc/lib/runtime/checker/index.js'
import { simplify } from '@spyglassmc/mcdoc/lib/runtime/checker/index.js'
-import { useCallback } from 'preact/hooks'
+import { getValues } from '@spyglassmc/mcdoc/lib/runtime/completer/index.js'
+import { useCallback, useMemo } from 'preact/hooks'
import { useLocale } from '../../contexts/Locale.jsx'
+import { hexId } from '../../Utils.js'
import { Octicon } from '../Octicon.jsx'
export interface McdocContext extends core.CheckerContext {}
@@ -41,7 +43,7 @@ interface HeadProps extends Props {
function Head({ type, optional, node, makeEdit, ctx }: HeadProps) {
const { locale } = useLocale()
if (type.kind === 'string') {
- return
+ return
}
if (type.kind === 'enum') {
return
@@ -73,7 +75,10 @@ function Head({ type, optional, node, makeEdit, ctx }: HeadProps) {
return <>>
}
-function StringHead({ node, makeEdit }: Props) {
+interface StringHeadProps extends Props {
+ type: StringType
+}
+function StringHead({ type, node, makeEdit, ctx }: StringHeadProps) {
const value = JsonStringNode.is(node) ? node.value : undefined
const onChangeValue = useCallback((newValue: string) => {
@@ -94,7 +99,19 @@ function StringHead({ node, makeEdit }: Props) {
})
}, [node, makeEdit])
- return onChangeValue((e.target as HTMLInputElement).value)} />
+ const completions = useMemo(() => {
+ return getValues(type, { ...ctx, offset: node?.range.start ?? 0 })
+ .filter(c => c.kind === 'string')
+ }, [type, node, ctx])
+
+ const datalistId = `mcdoc_completions_${hexId()}`
+
+ return <>
+ {completions && }
+ onChangeValue((e.target as HTMLInputElement).value)} list={completions ? datalistId : undefined} />
+ >
}
interface EnumHeadProps extends HeadProps {
diff --git a/src/app/services/Spyglass.ts b/src/app/services/Spyglass.ts
index 35ce9416..5fcc512c 100644
--- a/src/app/services/Spyglass.ts
+++ b/src/app/services/Spyglass.ts
@@ -317,13 +317,13 @@ function registerAttributes(meta: core.MetaRegistry, release: ReleaseVersion) {
ctx.err.report(
localize('java-edition.pack-format.unsupported', target),
node,
- core.ErrorSeverity.Warning,
+ 2,
)
} else if (targetVersion.id !== release) {
ctx.err.report(
localize('java-edition.pack-format.not-loaded', target, release),
node,
- core.ErrorSeverity.Warning,
+ 2,
)
}
}