diff --git a/__snapshots__/packages/mcdoc/test-out/__fixture__/simple_types.spec.js b/__snapshots__/packages/mcdoc/test-out/__fixture__/simple_types.spec.js index 20330916f..cd16b9e89 100644 --- a/__snapshots__/packages/mcdoc/test-out/__fixture__/simple_types.spec.js +++ b/__snapshots__/packages/mcdoc/test-out/__fixture__/simple_types.spec.js @@ -577,7 +577,7 @@ exports['mcdoc __fixture__ simple types 1'] = { "kind": "long_array", "valueRange": { "kind": 0, - "min": 1 + "min": "1" } } }, @@ -1777,15 +1777,15 @@ exports['mcdoc __fixture__ simple types 1'] = { "value": "long" }, { - "type": "mcdoc:int_range", + "type": "mcdoc:long_range", "children": [ { - "type": "integer", + "type": "long", "range": { "start": 380, "end": 381 }, - "value": 1 + "value": "1" }, { "type": "mcdoc:literal", diff --git a/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/numericType.spec.js b/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/numericType.spec.js index 0ddf235f9..adb03561f 100644 --- a/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/numericType.spec.js +++ b/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/numericType.spec.js @@ -213,6 +213,45 @@ exports['mcdoc numericType Parse "int @ 0..1" 1'] = { "errors": [] } +exports['mcdoc numericType Parse "int @ 10000000000000001" 1'] = { + "node": { + "type": "mcdoc:type/numeric_type", + "children": [ + { + "type": "mcdoc:literal", + "range": { + "start": 0, + "end": 3 + }, + "value": "int", + "colorTokenType": "type" + }, + { + "type": "mcdoc:int_range", + "children": [ + { + "type": "integer", + "range": { + "start": 6, + "end": 23 + }, + "value": 10000000000000000 + } + ], + "range": { + "start": 6, + "end": 23 + } + } + ], + "range": { + "start": 0, + "end": 23 + } + }, + "errors": [] +} + exports['mcdoc numericType Parse "int @ 4" 1'] = { "node": { "type": "mcdoc:type/numeric_type", @@ -299,6 +338,45 @@ exports['mcdoc numericType Parse "int @ 4.." 1'] = { "errors": [] } +exports['mcdoc numericType Parse "long @ 10000000000000001" 1'] = { + "node": { + "type": "mcdoc:type/numeric_type", + "children": [ + { + "type": "mcdoc:literal", + "range": { + "start": 0, + "end": 4 + }, + "value": "long", + "colorTokenType": "type" + }, + { + "type": "mcdoc:long_range", + "children": [ + { + "type": "long", + "range": { + "start": 7, + "end": 24 + }, + "value": "10000000000000001" + } + ], + "range": { + "start": 7, + "end": 24 + } + } + ], + "range": { + "start": 0, + "end": 24 + } + }, + "errors": [] +} + exports['mcdoc numericType Parse "other" 1'] = { "node": "FAILURE", "errors": [ diff --git a/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/primitiveArrayType.spec.js b/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/primitiveArrayType.spec.js index 61b0bef16..1b6913cd0 100644 --- a/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/primitiveArrayType.spec.js +++ b/__snapshots__/packages/mcdoc/test-out/parser/syntax/type/primitiveArrayType.spec.js @@ -262,6 +262,86 @@ exports['mcdoc primitiveArrayType Parse "int[] @ 4" 1'] = { "errors": [] } +exports['mcdoc primitiveArrayType Parse "long @ 10000000000000001.. [] @ 0.." 1'] = { + "node": { + "type": "mcdoc:type/primitive_array", + "children": [ + { + "type": "mcdoc:literal", + "range": { + "start": 0, + "end": 4 + }, + "value": "long" + }, + { + "type": "mcdoc:long_range", + "children": [ + { + "type": "long", + "range": { + "start": 7, + "end": 24 + }, + "value": "10000000000000001" + }, + { + "type": "mcdoc:literal", + "range": { + "start": 24, + "end": 26 + }, + "value": ".." + } + ], + "range": { + "start": 7, + "end": 26 + } + }, + { + "type": "mcdoc:literal", + "range": { + "start": 27, + "end": 29 + }, + "value": "[]", + "colorTokenType": "type" + }, + { + "type": "mcdoc:int_range", + "children": [ + { + "type": "integer", + "range": { + "start": 32, + "end": 33 + }, + "value": 0 + }, + { + "type": "mcdoc:literal", + "range": { + "start": 33, + "end": 35 + }, + "value": ".." + } + ], + "range": { + "start": 32, + "end": 35 + } + } + ], + "range": { + "start": 0, + "end": 35 + } + }, + "errors": [] +} + exports['mcdoc primitiveArrayType Parse "other[]" 1'] = { "node": { "type": "mcdoc:type/primitive_array", diff --git a/packages/mcdoc/src/parser/index.ts b/packages/mcdoc/src/parser/index.ts index e4be0d79a..c78e04d0c 100644 --- a/packages/mcdoc/src/parser/index.ts +++ b/packages/mcdoc/src/parser/index.ts @@ -919,7 +919,7 @@ export const numericType: Parser = typeBase( ), }, { predicate: (src) => src.tryPeek('long'), - parser: syntax([keyword(NumericTypeIntKinds, { colorTokenType: 'type' }), atLongRange], true), + parser: syntax([keyword('long', { colorTokenType: 'type' }), atLongRange], true), }, { parser: syntax([keyword(NumericTypeIntKinds, { colorTokenType: 'type' }), atIntRange], true), }]), @@ -928,10 +928,12 @@ export const numericType: Parser = typeBase( export const primitiveArrayType: Parser = typeBase( 'mcdoc:type/primitive_array', syntax([ - any([ - sequence([literal('long'), atLongRange]), - sequence([literal(PrimitiveArrayValueKinds), atIntRange]), - ]), + select([{ + predicate: (src) => src.tryPeek('long'), + parser: syntax([literal('long'), atLongRange], true), + }, { + parser: syntax([literal(PrimitiveArrayValueKinds), atIntRange], true), + }]), keyword('[]', { allowedChars: new Set(['[', ']']), colorTokenType: 'type' }), atIntRange, ]), diff --git a/packages/mcdoc/src/runtime/completer/index.ts b/packages/mcdoc/src/runtime/completer/index.ts index ac17091c5..2259fae92 100644 --- a/packages/mcdoc/src/runtime/completer/index.ts +++ b/packages/mcdoc/src/runtime/completer/index.ts @@ -2,6 +2,7 @@ import type * as core from '@spyglassmc/core' import { TypeDefSymbolData } from '../../binder/index.js' import type { LiteralType, + LongType, McdocType, NumericType, StringType, @@ -174,7 +175,7 @@ function getStringCompletions( } function getNumericCompletions( - typeDef: core.DeepReadonly, + typeDef: core.DeepReadonly, ctx: McdocCompleterContext, ) { const ans: SimpleCompletionValue[] = [] diff --git a/packages/mcdoc/test/parser/index.spec.ts b/packages/mcdoc/test/parser/index.spec.ts index 400d83ce5..755cf4c25 100644 --- a/packages/mcdoc/test/parser/index.spec.ts +++ b/packages/mcdoc/test/parser/index.spec.ts @@ -176,6 +176,8 @@ const Suites: Record< 'int @ 4..', 'int @ ..4', 'int @ 0..1', + 'int @ 10000000000000001', + 'long @ 10000000000000001', 'double@4.2..5.5', 'double[]', ], @@ -189,6 +191,7 @@ const Suites: Record< 'byte@0..1[]', 'int[] @ 4', 'byte @ 0..1 [] @ 0..', + 'long @ 10000000000000001.. [] @ 0..', ], }, referenceType: { content: ['', '#[uuid] UuidMostLeast', 'MinMaxBounds'] },