@spyglassmc/mcdoc 0.1.1 → 0.2.0
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 +2 -2
- package/lib/binder/index.js +2 -18
- package/lib/binder/uriBinder.js +5 -9
- package/lib/binder/util.js +2 -7
- package/lib/checker/CheckerContext.d.ts +1 -1
- package/lib/checker/CheckerContext.js +1 -2
- package/lib/checker/entry.d.ts +1 -1
- package/lib/checker/entry.js +4 -8
- package/lib/checker/index.d.ts +1 -1
- package/lib/checker/index.js +1 -17
- package/lib/colorizer/index.d.ts +1 -1
- package/lib/colorizer/index.js +8 -14
- package/lib/index.d.ts +5 -5
- package/lib/index.js +10 -40
- package/lib/node/index.d.ts +5 -2
- package/lib/node/index.js +84 -82
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.js +184 -214
- package/lib/type/index.d.ts +1 -1
- package/lib/type/index.js +24 -35
- package/package.json +4 -3
package/lib/binder/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './uriBinder';
|
|
2
|
-
export * from './util';
|
|
1
|
+
export * from './uriBinder.js';
|
|
2
|
+
export * from './util.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/binder/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./uriBinder"), exports);
|
|
18
|
-
__exportStar(require("./util"), exports);
|
|
1
|
+
export * from './uriBinder.js';
|
|
2
|
+
export * from './util.js';
|
|
19
3
|
//# sourceMappingURL=index.js.map
|
package/lib/binder/uriBinder.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.uriBinder = void 0;
|
|
4
|
-
const core_1 = require("@spyglassmc/core");
|
|
5
|
-
const util_1 = require("./util");
|
|
1
|
+
import { fileUtil } from '@spyglassmc/core';
|
|
2
|
+
import { segToIdentifier } from './util.js';
|
|
6
3
|
const Extension = '.mcdoc';
|
|
7
4
|
const McdocRootPrefix = 'mcdoc/';
|
|
8
|
-
const uriBinder = (uris, ctx) => {
|
|
5
|
+
export const uriBinder = (uris, ctx) => {
|
|
9
6
|
let urisAndRels = [];
|
|
10
7
|
for (const uri of uris) {
|
|
11
8
|
if (!uri.endsWith(Extension)) {
|
|
12
9
|
continue;
|
|
13
10
|
}
|
|
14
|
-
let rel =
|
|
11
|
+
let rel = fileUtil.getRel(uri, ctx.roots);
|
|
15
12
|
if (!rel) {
|
|
16
13
|
continue;
|
|
17
14
|
}
|
|
@@ -34,7 +31,7 @@ const uriBinder = (uris, ctx) => {
|
|
|
34
31
|
// file:///root/mcdoc/foo/bar.mcdoc -> foo/bar
|
|
35
32
|
for (const [uri, rel] of urisAndRels) {
|
|
36
33
|
ctx.symbols
|
|
37
|
-
.query(uri, 'mcdoc',
|
|
34
|
+
.query(uri, 'mcdoc', segToIdentifier(rel.split('/')))
|
|
38
35
|
.ifKnown(() => { })
|
|
39
36
|
.elseEnter({
|
|
40
37
|
data: {
|
|
@@ -46,5 +43,4 @@ const uriBinder = (uris, ctx) => {
|
|
|
46
43
|
});
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
exports.uriBinder = uriBinder;
|
|
50
46
|
//# sourceMappingURL=uriBinder.js.map
|
package/lib/binder/util.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.segToIdentifier = exports.identifierToSeg = void 0;
|
|
4
|
-
function identifierToSeg(identifier) {
|
|
1
|
+
export function identifierToSeg(identifier) {
|
|
5
2
|
const ans = identifier.slice(2).split('::');
|
|
6
3
|
if (ans.length === 1 && ans[0] === '') {
|
|
7
4
|
return [];
|
|
8
5
|
}
|
|
9
6
|
return ans;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
function segToIdentifier(seg) {
|
|
8
|
+
export function segToIdentifier(seg) {
|
|
13
9
|
return `::${seg.join('::')}`;
|
|
14
10
|
}
|
|
15
|
-
exports.segToIdentifier = segToIdentifier;
|
|
16
11
|
//# sourceMappingURL=util.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as core from '@spyglassmc/core';
|
|
2
2
|
import type { Symbol } from '@spyglassmc/core';
|
|
3
|
-
import type { Segments } from '../binder';
|
|
3
|
+
import type { Segments } from '../binder/index.js';
|
|
4
4
|
export interface CheckerContext extends core.CheckerContext {
|
|
5
5
|
/**
|
|
6
6
|
* The current module's identifier.
|
package/lib/checker/entry.d.ts
CHANGED
package/lib/checker/entry.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.module_ = void 0;
|
|
4
1
|
// import type * as core from '@spyglassmc/core'
|
|
5
2
|
// import type { Checker, RangeLike, Symbol, SymbolQuery } from '@spyglassmc/core'
|
|
6
3
|
// import { ErrorSeverity, Range, ResourceLocationNode, SymbolPath, SymbolUtil } from '@spyglassmc/core'
|
|
7
4
|
// import { localeQuote, localize } from '@spyglassmc/locales'
|
|
8
5
|
// import type { Segments } from '../binder'
|
|
9
6
|
// import { identifierToSeg, segToIdentifier } from '../binder'
|
|
10
|
-
// import type { DispatchStatementNode, IdentPathToken, InjectClauseNode, MainNode, UseStatementNode } from '../node'
|
|
11
|
-
// import { CompoundFieldNode, EnumFieldNode, EnumNode, ExtendableRootRegistryMap, StructNode } from '../node'
|
|
12
|
-
// import type { CheckerContext } from './CheckerContext'
|
|
13
|
-
const module_ = async (node, ctx) => {
|
|
7
|
+
// import type { DispatchStatementNode, IdentPathToken, InjectClauseNode, MainNode, UseStatementNode } from '../node/index.js'
|
|
8
|
+
// import { CompoundFieldNode, EnumFieldNode, EnumNode, ExtendableRootRegistryMap, StructNode } from '../node/index.js'
|
|
9
|
+
// import type { CheckerContext } from './CheckerContext.js'
|
|
10
|
+
export const module_ = async (node, ctx) => {
|
|
14
11
|
// const modSeg = uriToSeg(ctx.doc.uri, ctx)
|
|
15
12
|
// if (modSeg === undefined) {
|
|
16
13
|
// ctx.err.report(localize('mcdoc.checker.entry.undefined-mod-seg'), 0, ErrorSeverity.Warning)
|
|
@@ -90,7 +87,6 @@ const module_ = async (node, ctx) => {
|
|
|
90
87
|
// }
|
|
91
88
|
// }
|
|
92
89
|
};
|
|
93
|
-
exports.module_ = module_;
|
|
94
90
|
// async function compoundFields<N extends { fields: CompoundFieldNode[] }>(definitionQuery: core.SymbolQuery, node: N, ctx: CheckerContext) {
|
|
95
91
|
// const promises: Promise<void>[] = []
|
|
96
92
|
// definitionQuery.onEach(node.fields, field => {
|
package/lib/checker/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './entry';
|
|
1
|
+
export * from './entry.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/checker/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./entry"), exports);
|
|
1
|
+
export * from './entry.js';
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
package/lib/colorizer/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Colorizer, MetaRegistry } from '@spyglassmc/core';
|
|
2
|
-
import type { IdentifierNode, LiteralNode } from '../node';
|
|
2
|
+
import type { IdentifierNode, LiteralNode } from '../node/index.js';
|
|
3
3
|
export declare const identifier: Colorizer<IdentifierNode>;
|
|
4
4
|
export declare const literal: Colorizer<LiteralNode>;
|
|
5
5
|
export declare function registerMcdocColorizer(meta: MetaRegistry): void;
|
package/lib/colorizer/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@spyglassmc/core");
|
|
5
|
-
const identifier = node => {
|
|
6
|
-
return [core_1.ColorToken.create(node, 'variable')];
|
|
1
|
+
import { ColorToken } from '@spyglassmc/core';
|
|
2
|
+
export const identifier = node => {
|
|
3
|
+
return [ColorToken.create(node, 'variable')];
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return [core_1.ColorToken.create(node, node.colorTokenType ?? 'literal')];
|
|
5
|
+
export const literal = node => {
|
|
6
|
+
return [ColorToken.create(node, node.colorTokenType ?? 'literal')];
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
meta.registerColorizer('mcdoc:
|
|
15
|
-
meta.registerColorizer('mcdoc:identifier', exports.identifier);
|
|
8
|
+
export function registerMcdocColorizer(meta) {
|
|
9
|
+
meta.registerColorizer('mcdoc:literal', literal);
|
|
10
|
+
meta.registerColorizer('mcdoc:identifier', identifier);
|
|
16
11
|
}
|
|
17
|
-
exports.registerMcdocColorizer = registerMcdocColorizer;
|
|
18
12
|
//# sourceMappingURL=index.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type * as core from '@spyglassmc/core';
|
|
2
|
-
export * as checker from './checker';
|
|
3
|
-
export * as colorizer from './colorizer';
|
|
4
|
-
export * from './node';
|
|
5
|
-
export * from './parser';
|
|
6
|
-
export * from './type';
|
|
2
|
+
export * as checker from './checker/index.js';
|
|
3
|
+
export * as colorizer from './colorizer/index.js';
|
|
4
|
+
export * from './node/index.js';
|
|
5
|
+
export * from './parser/index.js';
|
|
6
|
+
export * from './type/index.js';
|
|
7
7
|
export declare const initialize: core.ProjectInitializer;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -1,43 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.initialize = exports.colorizer = exports.checker = void 0;
|
|
30
|
-
const binder = __importStar(require("./binder"));
|
|
31
|
-
const checker = __importStar(require("./checker"));
|
|
32
|
-
const colorizer = __importStar(require("./colorizer"));
|
|
33
|
-
const parser = __importStar(require("./parser"));
|
|
34
|
-
exports.checker = __importStar(require("./checker"));
|
|
35
|
-
exports.colorizer = __importStar(require("./colorizer"));
|
|
36
|
-
__exportStar(require("./node"), exports);
|
|
37
|
-
__exportStar(require("./parser"), exports);
|
|
38
|
-
__exportStar(require("./type"), exports);
|
|
1
|
+
import * as binder from './binder/index.js';
|
|
2
|
+
import * as checker from './checker/index.js';
|
|
3
|
+
import * as colorizer from './colorizer/index.js';
|
|
4
|
+
import * as parser from './parser/index.js';
|
|
5
|
+
export * as checker from './checker/index.js';
|
|
6
|
+
export * as colorizer from './colorizer/index.js';
|
|
7
|
+
export * from './node/index.js';
|
|
8
|
+
export * from './parser/index.js';
|
|
9
|
+
export * from './type/index.js';
|
|
39
10
|
/* istanbul ignore next */
|
|
40
|
-
const initialize = ({ meta }) => {
|
|
11
|
+
export const initialize = ({ meta }) => {
|
|
41
12
|
meta.registerLanguage('mcdoc', {
|
|
42
13
|
extensions: ['.mcdoc'],
|
|
43
14
|
parser: parser.module_,
|
|
@@ -46,5 +17,4 @@ const initialize = ({ meta }) => {
|
|
|
46
17
|
meta.registerUriBinder(binder.uriBinder);
|
|
47
18
|
colorizer.registerMcdocColorizer(meta);
|
|
48
19
|
};
|
|
49
|
-
exports.initialize = initialize;
|
|
50
20
|
//# sourceMappingURL=index.js.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AstNode, ColorTokenType, FloatNode, IntegerNode, SymbolBaseNode } from '@spyglassmc/core';
|
|
2
2
|
import { CommentNode, ResourceLocationNode, StringNode } from '@spyglassmc/core';
|
|
3
|
-
import type { McdocType } from '../type';
|
|
3
|
+
import type { McdocType } from '../type/index.js';
|
|
4
4
|
export interface ModuleNode extends AstNode {
|
|
5
5
|
type: 'mcdoc:module';
|
|
6
6
|
children: TopLevelNode[];
|
|
@@ -176,7 +176,7 @@ export interface EnumNode extends TypeBaseNode<DocCommentsNode | LiteralNode | I
|
|
|
176
176
|
}
|
|
177
177
|
export declare const EnumNode: Readonly<{
|
|
178
178
|
is(node: AstNode | undefined): node is EnumNode;
|
|
179
|
-
kinds: Set<"string" | "
|
|
179
|
+
kinds: Set<"string" | "byte" | "short" | "int" | "long" | "float" | "double">;
|
|
180
180
|
}>;
|
|
181
181
|
export declare type EnumKind = typeof EnumNode['kinds'] extends Set<infer V> ? V : never;
|
|
182
182
|
export interface DocCommentsNode extends AstNode {
|
|
@@ -217,6 +217,9 @@ export declare const StructNode: Readonly<{
|
|
|
217
217
|
export interface PathTypeNode extends TypeBaseNode<PathNode | TypeNode> {
|
|
218
218
|
type: 'mcdoc:type/path';
|
|
219
219
|
}
|
|
220
|
+
export declare const PathTypeNode: Readonly<{
|
|
221
|
+
is(node: AstNode | undefined): node is PathTypeNode;
|
|
222
|
+
}>;
|
|
220
223
|
export interface TypeParamBlockNode extends AstNode {
|
|
221
224
|
type: 'mcdoc:type_param_block';
|
|
222
225
|
children: (CommentNode | TypeParamNode)[];
|