Skip to content

Commit

Permalink
Fix minor bugs & add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NeunEinser committed Jul 7, 2024
1 parent b5ffbb2 commit 27751ce
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions packages/mcdoc/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ export const numericType: Parser<NumericTypeNode> = 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),
}]),
Expand All @@ -928,10 +928,12 @@ export const numericType: Parser<NumericTypeNode> = typeBase(
export const primitiveArrayType: Parser<PrimitiveArrayTypeNode> = 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,
]),
Expand Down
3 changes: 2 additions & 1 deletion packages/mcdoc/src/runtime/completer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type * as core from '@spyglassmc/core'
import { TypeDefSymbolData } from '../../binder/index.js'
import type {
LiteralType,
LongType,
McdocType,
NumericType,
StringType,
Expand Down Expand Up @@ -174,7 +175,7 @@ function getStringCompletions(
}

function getNumericCompletions(
typeDef: core.DeepReadonly<NumericType>,
typeDef: core.DeepReadonly<NumericType | LongType>,
ctx: McdocCompleterContext,
) {
const ans: SimpleCompletionValue[] = []
Expand Down
3 changes: 3 additions & 0 deletions packages/mcdoc/test/parser/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ const Suites: Record<
'int @ 4..',
'int @ ..4',
'int @ 0..1',
'int @ 10000000000000001',
'long @ 10000000000000001',
'[email protected]',
'double[]',
],
Expand All @@ -189,6 +191,7 @@ const Suites: Record<
'[email protected][]',
'int[] @ 4',
'byte @ 0..1 [] @ 0..',
'long @ 10000000000000001.. [] @ 0..',
],
},
referenceType: { content: ['', '#[uuid] UuidMostLeast', 'MinMaxBounds<float @ 1..2>'] },
Expand Down

0 comments on commit 27751ce

Please sign in to comment.