@spyglassmc/mcdoc 0.3.0 → 0.3.1
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.js +10 -10
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/package.json +2 -2
package/lib/binder/index.js
CHANGED
|
@@ -110,7 +110,7 @@ function hoist(node, ctx) {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
function hoistFor(subcategory, node, destructor, getData) {
|
|
113
|
-
const { docComments, identifier } = destructor(node);
|
|
113
|
+
const { docComments, identifier, keyword } = destructor(node);
|
|
114
114
|
const name = identifier?.value ?? nextAnonymousIdentifier(node, ctx);
|
|
115
115
|
ctx.symbols
|
|
116
116
|
.query({ doc: ctx.doc, node }, 'mcdoc', `${ctx.moduleIdentifier}::${name}`)
|
|
@@ -118,8 +118,8 @@ function hoist(node, ctx) {
|
|
|
118
118
|
.elseEnter({
|
|
119
119
|
data: { data: getData(node), desc: DocCommentsNode.asText(docComments), subcategory },
|
|
120
120
|
// If the current syntax structure is named, then the identifier node is entered as a definition;
|
|
121
|
-
// otherwise, an anonymous identifier is generated for the symbol and the
|
|
122
|
-
usage: { type: 'definition', node: identifier ??
|
|
121
|
+
// otherwise, an anonymous identifier is generated for the symbol and the keyword node is entered as a definition.
|
|
122
|
+
usage: { type: 'definition', node: identifier ?? keyword, fullRange: identifier && node },
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
function nextAnonymousIndex(node, ctx) {
|
|
@@ -154,7 +154,7 @@ async function bindDispatchStatement(node, ctx) {
|
|
|
154
154
|
}
|
|
155
155
|
ctx.symbols
|
|
156
156
|
.query(ctx.doc, 'mcdoc/dispatcher', locationStr, asString(key))
|
|
157
|
-
.ifDeclared(symbol => reportDuplicatedDeclaration(ctx, symbol, key, { localeString: 'mcdoc.binder.dispatcher-statement.duplicated-key
|
|
157
|
+
.ifDeclared(symbol => reportDuplicatedDeclaration(ctx, symbol, key, { localeString: 'mcdoc.binder.dispatcher-statement.duplicated-key' }))
|
|
158
158
|
.elseEnter({
|
|
159
159
|
data: {
|
|
160
160
|
data: {
|
|
@@ -226,7 +226,7 @@ async function bindPath(node, ctx) {
|
|
|
226
226
|
const referencedModuleFile = pathArrayToString(identifiers);
|
|
227
227
|
const referencedModuleUri = identifierToUri(referencedModuleFile, ctx);
|
|
228
228
|
if (!referencedModuleUri) {
|
|
229
|
-
ctx.err.report(localize('mcdoc.binder.path.unknown-module', localeQuote(referencedModuleFile)), node);
|
|
229
|
+
ctx.err.report(localize('mcdoc.binder.path.unknown-module', localeQuote(referencedModuleFile)), node, 2 /* ErrorSeverity.Warning */);
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
232
|
await ctx.ensureBindingStarted(referencedModuleUri);
|
|
@@ -238,14 +238,14 @@ async function bindPath(node, ctx) {
|
|
|
238
238
|
}))
|
|
239
239
|
.else(() => {
|
|
240
240
|
if (indexRight === 0) {
|
|
241
|
-
ctx.err.report(localize('mcdoc.binder.path.unknown-identifier', localeQuote(atArray(identifiers, -1)), localeQuote(pathArrayToString(identifiers.slice(0, -1)))), node);
|
|
241
|
+
ctx.err.report(localize('mcdoc.binder.path.unknown-identifier', localeQuote(atArray(identifiers, -1)), localeQuote(pathArrayToString(identifiers.slice(0, -1)))), node, 2 /* ErrorSeverity.Warning */);
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
function bindEnum(node, ctx) {
|
|
247
|
-
const { block, identifier } = EnumNode.destruct(node);
|
|
248
|
-
const symbol = identifier?.symbol ??
|
|
247
|
+
const { block, identifier, keyword } = EnumNode.destruct(node);
|
|
248
|
+
const symbol = identifier?.symbol ?? keyword.symbol;
|
|
249
249
|
if (symbol?.subcategory !== 'enum') {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
@@ -271,8 +271,8 @@ async function bindInjection(node, ctx) {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
async function bindStruct(node, ctx) {
|
|
274
|
-
const { block, identifier } = StructNode.destruct(node);
|
|
275
|
-
const symbol = identifier?.symbol ??
|
|
274
|
+
const { block, identifier, keyword } = StructNode.destruct(node);
|
|
275
|
+
const symbol = identifier?.symbol ?? keyword.symbol;
|
|
276
276
|
if (symbol?.subcategory !== 'struct') {
|
|
277
277
|
return;
|
|
278
278
|
}
|
package/lib/node/index.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ export declare const EnumNode: Readonly<{
|
|
|
264
264
|
docComments?: DocCommentsNode;
|
|
265
265
|
enumKind?: EnumKind;
|
|
266
266
|
identifier?: IdentifierNode;
|
|
267
|
+
keyword: LiteralNode;
|
|
267
268
|
};
|
|
268
269
|
is(node: AstNode | undefined): node is EnumNode;
|
|
269
270
|
}>;
|
|
@@ -316,6 +317,7 @@ export declare const StructNode: Readonly<{
|
|
|
316
317
|
block: StructBlockNode;
|
|
317
318
|
docComments?: DocCommentsNode;
|
|
318
319
|
identifier?: IdentifierNode;
|
|
320
|
+
keyword: LiteralNode;
|
|
319
321
|
};
|
|
320
322
|
is(node: AstNode | undefined): node is StructNode;
|
|
321
323
|
}>;
|
|
@@ -470,6 +472,7 @@ export declare const TypeAliasNode: Readonly<{
|
|
|
470
472
|
destruct(node: TypeAliasNode): {
|
|
471
473
|
docComments?: DocCommentsNode;
|
|
472
474
|
identifier?: IdentifierNode;
|
|
475
|
+
keyword: LiteralNode;
|
|
473
476
|
typeParams?: TypeParamBlockNode;
|
|
474
477
|
rhs?: TypeNode;
|
|
475
478
|
};
|
package/lib/node/index.js
CHANGED
|
@@ -337,6 +337,7 @@ export const EnumNode = Object.freeze({
|
|
|
337
337
|
docComments: node.children.find(DocCommentsNode.is),
|
|
338
338
|
enumKind: getEnumKind(node),
|
|
339
339
|
identifier: node.children.find(IdentifierNode.is),
|
|
340
|
+
keyword: node.children.find(LiteralNode.is),
|
|
340
341
|
};
|
|
341
342
|
function getEnumKind(node) {
|
|
342
343
|
for (const literal of node.children.filter(LiteralNode.is)) {
|
|
@@ -412,6 +413,7 @@ export const StructNode = Object.freeze({
|
|
|
412
413
|
block: node.children.find(StructBlockNode.is),
|
|
413
414
|
docComments: node.children.find(DocCommentsNode.is),
|
|
414
415
|
identifier: node.children.find(IdentifierNode.is),
|
|
416
|
+
keyword: node.children.find(LiteralNode.is),
|
|
415
417
|
};
|
|
416
418
|
},
|
|
417
419
|
is(node) {
|
|
@@ -568,6 +570,7 @@ export const TypeAliasNode = Object.freeze({
|
|
|
568
570
|
return {
|
|
569
571
|
docComments: node.children.find(DocCommentsNode.is),
|
|
570
572
|
identifier: node.children.find(IdentifierNode.is),
|
|
573
|
+
keyword: node.children.find(LiteralNode.is),
|
|
571
574
|
typeParams: node.children.find(TypeParamBlockNode.is),
|
|
572
575
|
rhs: node.children.find(TypeNode.is),
|
|
573
576
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/mcdoc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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.
|
|
28
|
+
"@spyglassmc/core": "0.4.0",
|
|
29
29
|
"@spyglassmc/locales": "0.3.0"
|
|
30
30
|
}
|
|
31
31
|
}
|