@spyglassmc/mcdoc 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/binder/index.d.ts +3 -2
- package/lib/binder/index.js +11 -2
- package/lib/common.d.ts +0 -3
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.js +1 -0
- package/lib/runtime/completer/index.d.ts +1 -0
- package/lib/runtime/completer/index.js +1 -0
- package/lib/type/index.d.ts +1 -3
- package/package.json +2 -2
package/lib/binder/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { BinderContext, MetaRegistry } from '@spyglassmc/core';
|
|
2
2
|
import { AsyncBinder } from '@spyglassmc/core';
|
|
3
|
-
import type { AdditionalContext } from '../common.js';
|
|
4
3
|
import type { ModuleNode } from '../node/index.js';
|
|
5
4
|
import type { SimplifiedMcdocType } from '../runtime/checker/index.js';
|
|
6
5
|
import type { McdocType } from '../type/index.js';
|
|
7
|
-
interface McdocBinderContext extends BinderContext
|
|
6
|
+
interface McdocBinderContext extends BinderContext {
|
|
7
|
+
moduleIdentifier: string;
|
|
8
|
+
isHoisting?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export interface TypeDefSymbolData {
|
|
10
11
|
typeDef: McdocType;
|
package/lib/binder/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export async function module_(node, ctx) {
|
|
|
33
33
|
ctx.symbols.query({ doc: ctx.doc, node }, 'mcdoc', ctx.moduleIdentifier).amend({
|
|
34
34
|
data: { data },
|
|
35
35
|
});
|
|
36
|
-
hoist(node, ctx);
|
|
36
|
+
hoist(node, { ...ctx, isHoisting: true });
|
|
37
37
|
for (const child of node.children) {
|
|
38
38
|
switch (child.type) {
|
|
39
39
|
case 'mcdoc:dispatch_statement':
|
|
@@ -559,6 +559,10 @@ function convertTypeArgBlock(node, ctx) {
|
|
|
559
559
|
}
|
|
560
560
|
function convertEnum(node, ctx) {
|
|
561
561
|
const { block, enumKind, identifier } = EnumNode.destruct(node);
|
|
562
|
+
// Return reference if the enum has been hoisted
|
|
563
|
+
if (identifier && !ctx.isHoisting) {
|
|
564
|
+
return { kind: 'reference', path: `${ctx.moduleIdentifier}::${identifier.value}` };
|
|
565
|
+
}
|
|
562
566
|
// Shortcut if the typeDef has been added to the enum symbol.
|
|
563
567
|
const symbol = identifier?.symbol ?? node.symbol;
|
|
564
568
|
if (symbol && TypeDefSymbolData.is(symbol.data) && symbol.data.typeDef.kind === 'enum') {
|
|
@@ -571,9 +575,10 @@ function convertEnumBlock(node, ctx) {
|
|
|
571
575
|
return fields.map((n) => convertEnumField(n, ctx));
|
|
572
576
|
}
|
|
573
577
|
function convertEnumField(node, ctx) {
|
|
574
|
-
const { attributes, identifier, value } = EnumFieldNode.destruct(node);
|
|
578
|
+
const { attributes, docComments, identifier, value } = EnumFieldNode.destruct(node);
|
|
575
579
|
return {
|
|
576
580
|
attributes: convertAttributes(attributes, ctx),
|
|
581
|
+
desc: DocCommentsNode.asText(docComments),
|
|
577
582
|
identifier: identifier.value,
|
|
578
583
|
value: convertEnumValue(value, ctx),
|
|
579
584
|
};
|
|
@@ -587,6 +592,10 @@ function convertEnumValue(node, ctx) {
|
|
|
587
592
|
}
|
|
588
593
|
function convertStruct(node, ctx) {
|
|
589
594
|
const { block, identifier } = StructNode.destruct(node);
|
|
595
|
+
// Return reference if the struct has been hoisted
|
|
596
|
+
if (identifier && !ctx.isHoisting) {
|
|
597
|
+
return { kind: 'reference', path: `${ctx.moduleIdentifier}::${identifier.value}` };
|
|
598
|
+
}
|
|
590
599
|
// Shortcut if the typeDef has been added to the struct symbol.
|
|
591
600
|
const symbol = identifier?.symbol ?? node.symbol;
|
|
592
601
|
if (symbol && TypeDefSymbolData.is(symbol.data) && symbol.data.typeDef.kind === 'struct') {
|
package/lib/common.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export type Segments = readonly string[];
|
|
2
2
|
export declare function identifierToSeg(identifier: string): Segments;
|
|
3
3
|
export declare function segToIdentifier(seg: Segments): string;
|
|
4
|
-
export interface AdditionalContext {
|
|
5
|
-
moduleIdentifier: string;
|
|
6
|
-
}
|
|
7
4
|
//# sourceMappingURL=common.d.ts.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -310,6 +310,7 @@ export interface EnumFieldNode extends AstNode {
|
|
|
310
310
|
export declare namespace EnumFieldNode {
|
|
311
311
|
function destruct(node: EnumFieldNode): {
|
|
312
312
|
attributes: AttributeNode[];
|
|
313
|
+
docComments?: DocCommentsNode;
|
|
313
314
|
identifier: IdentifierNode;
|
|
314
315
|
value: EnumValueNode;
|
|
315
316
|
};
|
package/lib/node/index.js
CHANGED
|
@@ -475,6 +475,7 @@ export var EnumFieldNode;
|
|
|
475
475
|
function destruct(node) {
|
|
476
476
|
return {
|
|
477
477
|
attributes: node.children.filter(AttributeNode.is),
|
|
478
|
+
docComments: node.children.find(DocCommentsNode.is),
|
|
478
479
|
identifier: node.children.find(IdentifierNode.is),
|
|
479
480
|
value: node.children.find(EnumValueNode.is),
|
|
480
481
|
};
|
|
@@ -12,6 +12,7 @@ export declare function getFields(typeDef: core.DeepReadonly<SimplifiedMcdocType
|
|
|
12
12
|
export type SimpleCompletionValue = {
|
|
13
13
|
value: string;
|
|
14
14
|
detail?: string;
|
|
15
|
+
documentation?: string;
|
|
15
16
|
labelSuffix?: string;
|
|
16
17
|
kind?: McdocType['kind'];
|
|
17
18
|
completionKind?: core.CompletionKind;
|
package/lib/type/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export interface EnumType extends McdocBaseType {
|
|
|
86
86
|
export interface EnumTypeField extends McdocBaseType {
|
|
87
87
|
identifier: string;
|
|
88
88
|
value: string | number;
|
|
89
|
+
desc?: string;
|
|
89
90
|
}
|
|
90
91
|
export interface ReferenceType extends McdocBaseType {
|
|
91
92
|
kind: 'reference';
|
|
@@ -181,7 +182,4 @@ export declare namespace McdocType {
|
|
|
181
182
|
function equals(a: McdocType, b: McdocType): boolean;
|
|
182
183
|
function toString(type: McdocType | undefined): string;
|
|
183
184
|
}
|
|
184
|
-
export interface UseStatementBindingData {
|
|
185
|
-
target: readonly string[];
|
|
186
|
-
}
|
|
187
185
|
//# sourceMappingURL=index.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/mcdoc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/SpyglassMC/Spyglass/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@spyglassmc/core": "0.4.
|
|
28
|
+
"@spyglassmc/core": "0.4.17",
|
|
29
29
|
"@spyglassmc/locales": "0.3.10"
|
|
30
30
|
}
|
|
31
31
|
}
|