@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/node/index.js
CHANGED
|
@@ -1,275 +1,277 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
exports.UseStatementNode = exports.TypeAliasNode = exports.StructInjectionNode = exports.EnumInjectionNode = exports.InjectionNode = exports.UnionTypeNode = exports.DispatcherTypeNode = exports.StructSpreadFieldNode = exports.StructMapKeyNode = exports.StructKeyNode = exports.StructPairFieldNode = exports.StructFieldNode = exports.StructBlockNode = exports.PathNode = exports.TypeParamNode = exports.TypeParamBlockNode = exports.StructNode = exports.PrelimNode = exports.EnumValueNode = exports.EnumFieldNode = exports.EnumBlockNode = exports.DocCommentsNode = exports.EnumNode = exports.TupleTypeNode = exports.ListTypeNode = exports.PrimitiveArrayTypeNode = exports.FloatRangeNode = exports.NumericTypeNode = exports.TypedNumberNode = exports.LiteralTypeNode = exports.IntRangeNode = exports.StringTypeNode = exports.BooleanTypeNode = exports.AnyTypeNode = exports.AttributeTreeNamedValuesNode = exports.AttributeTreePosValuesNode = exports.AttributeTreeNode = exports.AttributeValueNode = exports.AttributeNode = exports.TypeNode = exports.AccessorKeyNode = exports.DynamicIndexNode = exports.IdentifierNode = exports.StaticIndexNode = exports.IndexNode = exports.IndexBodyNode = exports.LiteralNode = exports.DispatchStatementNode = exports.TopLevelNode = exports.ModuleNode = void 0;
|
|
4
|
-
const core_1 = require("@spyglassmc/core");
|
|
5
|
-
exports.ModuleNode = Object.freeze({
|
|
1
|
+
import { CommentNode, ResourceLocationNode, StringNode } from '@spyglassmc/core';
|
|
2
|
+
export const ModuleNode = Object.freeze({
|
|
6
3
|
is(node) {
|
|
7
4
|
return node?.type === 'mcdoc:module';
|
|
8
5
|
},
|
|
9
6
|
});
|
|
10
|
-
|
|
7
|
+
export const TopLevelNode = Object.freeze({
|
|
11
8
|
is(node) {
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
return (CommentNode.is(node) ||
|
|
10
|
+
DispatchStatementNode.is(node) ||
|
|
11
|
+
EnumNode.is(node) ||
|
|
12
|
+
InjectionNode.is(node) ||
|
|
13
|
+
StructNode.is(node) ||
|
|
14
|
+
TypeAliasNode.is(node) ||
|
|
15
|
+
UseStatementNode.is(node));
|
|
19
16
|
},
|
|
20
17
|
});
|
|
21
|
-
|
|
18
|
+
export const DispatchStatementNode = Object.freeze({
|
|
22
19
|
is(node) {
|
|
23
20
|
return node?.type === 'mcdoc:dispatch_statement';
|
|
24
21
|
},
|
|
25
22
|
});
|
|
26
|
-
|
|
23
|
+
export const LiteralNode = Object.freeze({
|
|
27
24
|
is(node) {
|
|
28
25
|
return node?.type === 'mcdoc:literal';
|
|
29
26
|
},
|
|
30
27
|
});
|
|
31
|
-
|
|
28
|
+
export const IndexBodyNode = Object.freeze({
|
|
32
29
|
is(node) {
|
|
33
30
|
return node?.type === 'mcdoc:index_body';
|
|
34
31
|
},
|
|
35
32
|
});
|
|
36
|
-
|
|
33
|
+
export const IndexNode = Object.freeze({
|
|
37
34
|
is(node) {
|
|
38
|
-
return
|
|
35
|
+
return StaticIndexNode.is(node) || DynamicIndexNode.is(node);
|
|
39
36
|
},
|
|
40
37
|
});
|
|
41
|
-
|
|
38
|
+
export const StaticIndexNode = Object.freeze({
|
|
42
39
|
is(node) {
|
|
43
|
-
return
|
|
40
|
+
return LiteralNode.is(node) || IdentifierNode.is(node) || StringNode.is(node) || ResourceLocationNode.is(node);
|
|
44
41
|
},
|
|
45
42
|
});
|
|
46
|
-
|
|
43
|
+
export const IdentifierNode = Object.freeze({
|
|
47
44
|
is(node) {
|
|
48
45
|
return node?.type === 'mcdoc:identifier';
|
|
49
46
|
},
|
|
50
47
|
});
|
|
51
|
-
|
|
48
|
+
export const DynamicIndexNode = Object.freeze({
|
|
52
49
|
is(node) {
|
|
53
50
|
return node?.type === 'mcdoc:dynamic_index';
|
|
54
51
|
},
|
|
55
52
|
});
|
|
56
|
-
|
|
53
|
+
export const AccessorKeyNode = Object.freeze({
|
|
57
54
|
is(node) {
|
|
58
|
-
return
|
|
55
|
+
return LiteralNode.is(node) || IdentifierNode.is(node) || StringNode.is(node);
|
|
59
56
|
},
|
|
60
57
|
});
|
|
61
|
-
|
|
58
|
+
export const TypeNode = Object.freeze({
|
|
62
59
|
is(node) {
|
|
63
|
-
return (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
return (AnyTypeNode.is(node) ||
|
|
61
|
+
BooleanTypeNode.is(node) ||
|
|
62
|
+
StringTypeNode.is(node) ||
|
|
63
|
+
LiteralTypeNode.is(node) ||
|
|
64
|
+
NumericTypeNode.is(node) ||
|
|
65
|
+
PrimitiveArrayTypeNode.is(node) ||
|
|
66
|
+
ListTypeNode.is(node) ||
|
|
67
|
+
TupleTypeNode.is(node) ||
|
|
68
|
+
EnumNode.is(node) ||
|
|
69
|
+
StructNode.is(node) ||
|
|
70
|
+
PathNode.is(node) ||
|
|
71
|
+
DispatcherTypeNode.is(node) ||
|
|
72
|
+
UnionTypeNode.is(node));
|
|
76
73
|
},
|
|
77
74
|
asType(node) {
|
|
78
75
|
throw '// TODO';
|
|
79
76
|
},
|
|
80
77
|
});
|
|
81
|
-
|
|
78
|
+
export const AttributeNode = Object.freeze({
|
|
82
79
|
is(node) {
|
|
83
80
|
return node?.type === 'mcdoc:attribute';
|
|
84
81
|
},
|
|
85
82
|
});
|
|
86
|
-
|
|
83
|
+
export const AttributeValueNode = Object.freeze({
|
|
87
84
|
is(node) {
|
|
88
|
-
return
|
|
85
|
+
return TypeNode.is(node) || AttributeTreeNode.is(node);
|
|
89
86
|
},
|
|
90
87
|
});
|
|
91
|
-
|
|
88
|
+
export const AttributeTreeNode = Object.freeze({
|
|
92
89
|
is(node) {
|
|
93
90
|
return node?.type === 'mcdoc:attribute/tree';
|
|
94
91
|
},
|
|
95
92
|
});
|
|
96
|
-
|
|
93
|
+
export const AttributeTreePosValuesNode = Object.freeze({
|
|
97
94
|
is(node) {
|
|
98
95
|
return node?.type === 'mcdoc:attribute/tree/pos';
|
|
99
96
|
},
|
|
100
97
|
});
|
|
101
|
-
|
|
98
|
+
export const AttributeTreeNamedValuesNode = Object.freeze({
|
|
102
99
|
is(node) {
|
|
103
100
|
return node?.type === 'mcdoc:attribute/tree/named';
|
|
104
101
|
},
|
|
105
102
|
});
|
|
106
|
-
|
|
103
|
+
export const AnyTypeNode = Object.freeze({
|
|
107
104
|
is(node) {
|
|
108
105
|
return node?.type === 'mcdoc:type/any';
|
|
109
106
|
},
|
|
110
107
|
});
|
|
111
|
-
|
|
108
|
+
export const BooleanTypeNode = Object.freeze({
|
|
112
109
|
is(node) {
|
|
113
110
|
return node?.type === 'mcdoc:type/boolean';
|
|
114
111
|
},
|
|
115
112
|
});
|
|
116
|
-
|
|
113
|
+
export const StringTypeNode = Object.freeze({
|
|
117
114
|
is(node) {
|
|
118
115
|
return node?.type === 'mcdoc:type/string';
|
|
119
116
|
},
|
|
120
117
|
});
|
|
121
|
-
|
|
118
|
+
export const IntRangeNode = Object.freeze({
|
|
122
119
|
is(node) {
|
|
123
120
|
return node?.type === 'mcdoc:int_range';
|
|
124
121
|
},
|
|
125
122
|
});
|
|
126
|
-
|
|
123
|
+
export const LiteralTypeNode = Object.freeze({
|
|
127
124
|
is(node) {
|
|
128
125
|
return node?.type === 'mcdoc:type/literal';
|
|
129
126
|
},
|
|
130
127
|
});
|
|
131
|
-
|
|
128
|
+
export const TypedNumberNode = Object.freeze({
|
|
132
129
|
is(node) {
|
|
133
130
|
return node?.type === 'mcdoc:typed_number';
|
|
134
131
|
},
|
|
135
132
|
});
|
|
136
|
-
|
|
133
|
+
export const NumericTypeNode = Object.freeze({
|
|
137
134
|
is(node) {
|
|
138
135
|
return node?.type === 'mcdoc:type/numeric_type';
|
|
139
136
|
},
|
|
140
137
|
});
|
|
141
|
-
|
|
138
|
+
export const FloatRangeNode = Object.freeze({
|
|
142
139
|
is(node) {
|
|
143
140
|
return node?.type === 'mcdoc:float_range';
|
|
144
141
|
},
|
|
145
142
|
});
|
|
146
|
-
|
|
143
|
+
export const PrimitiveArrayTypeNode = Object.freeze({
|
|
147
144
|
is(node) {
|
|
148
145
|
return node?.type === 'mcdoc:type/primitive_array';
|
|
149
146
|
},
|
|
150
147
|
});
|
|
151
|
-
|
|
148
|
+
export const ListTypeNode = Object.freeze({
|
|
152
149
|
is(node) {
|
|
153
150
|
return node?.type === 'mcdoc:type/list';
|
|
154
151
|
},
|
|
155
152
|
});
|
|
156
|
-
|
|
153
|
+
export const TupleTypeNode = Object.freeze({
|
|
157
154
|
is(node) {
|
|
158
155
|
return node?.type === 'mcdoc:type/tuple';
|
|
159
156
|
},
|
|
160
157
|
});
|
|
161
|
-
|
|
158
|
+
export const EnumNode = Object.freeze({
|
|
162
159
|
is(node) {
|
|
163
160
|
return node?.type === 'mcdoc:enum';
|
|
164
161
|
},
|
|
165
162
|
kinds: new Set(['byte', 'short', 'int', 'long', 'float', 'double', 'string']),
|
|
166
163
|
});
|
|
167
|
-
|
|
164
|
+
export const DocCommentsNode = Object.freeze({
|
|
168
165
|
is(node) {
|
|
169
166
|
return node?.type === 'mcdoc:doc_comments';
|
|
170
167
|
},
|
|
171
168
|
});
|
|
172
|
-
|
|
169
|
+
export const EnumBlockNode = Object.freeze({
|
|
173
170
|
is(node) {
|
|
174
171
|
return node?.type === 'mcdoc:enum/block';
|
|
175
172
|
},
|
|
176
173
|
});
|
|
177
|
-
|
|
174
|
+
export const EnumFieldNode = Object.freeze({
|
|
178
175
|
is(node) {
|
|
179
176
|
return node?.type === 'mcdoc:enum/field';
|
|
180
177
|
},
|
|
181
178
|
});
|
|
182
|
-
|
|
179
|
+
export const EnumValueNode = Object.freeze({
|
|
183
180
|
is(node) {
|
|
184
|
-
return
|
|
181
|
+
return TypedNumberNode.is(node) || StringNode.is(node);
|
|
185
182
|
},
|
|
186
183
|
});
|
|
187
|
-
|
|
184
|
+
export const PrelimNode = Object.freeze({
|
|
188
185
|
is(node) {
|
|
189
|
-
return
|
|
186
|
+
return AttributeNode.is(node) || DocCommentsNode.is(node);
|
|
190
187
|
},
|
|
191
188
|
});
|
|
192
|
-
|
|
189
|
+
export const StructNode = Object.freeze({
|
|
193
190
|
is(node) {
|
|
194
191
|
return node?.type === 'mcdoc:struct';
|
|
195
192
|
},
|
|
196
193
|
});
|
|
197
|
-
|
|
194
|
+
export const PathTypeNode = Object.freeze({
|
|
195
|
+
is(node) {
|
|
196
|
+
return node?.type === 'mcdoc:type/path';
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
export const TypeParamBlockNode = Object.freeze({
|
|
198
200
|
is(node) {
|
|
199
201
|
return node?.type === 'mcdoc:type_param_block';
|
|
200
202
|
},
|
|
201
203
|
});
|
|
202
|
-
|
|
204
|
+
export const TypeParamNode = Object.freeze({
|
|
203
205
|
is(node) {
|
|
204
206
|
return node?.type === 'mcdoc:type_param';
|
|
205
207
|
},
|
|
206
208
|
});
|
|
207
|
-
|
|
209
|
+
export const PathNode = Object.freeze({
|
|
208
210
|
is(node) {
|
|
209
211
|
return node?.type === 'mcdoc:path';
|
|
210
212
|
},
|
|
211
213
|
});
|
|
212
|
-
|
|
214
|
+
export const StructBlockNode = Object.freeze({
|
|
213
215
|
is(node) {
|
|
214
216
|
return node?.type === 'mcdoc:struct/block';
|
|
215
217
|
},
|
|
216
218
|
});
|
|
217
|
-
|
|
219
|
+
export const StructFieldNode = Object.freeze({
|
|
218
220
|
is(node) {
|
|
219
|
-
return
|
|
221
|
+
return StructPairFieldNode.is(node) || StructSpreadFieldNode.is(node);
|
|
220
222
|
},
|
|
221
223
|
});
|
|
222
|
-
|
|
224
|
+
export const StructPairFieldNode = Object.freeze({
|
|
223
225
|
is(node) {
|
|
224
226
|
return node?.type === 'mcdoc:struct/field/pair';
|
|
225
227
|
},
|
|
226
228
|
});
|
|
227
|
-
|
|
229
|
+
export const StructKeyNode = Object.freeze({
|
|
228
230
|
is(node) {
|
|
229
|
-
return
|
|
231
|
+
return StringNode.is(node) || IdentifierNode.is(node) || StructMapKeyNode.is(node);
|
|
230
232
|
},
|
|
231
233
|
});
|
|
232
|
-
|
|
234
|
+
export const StructMapKeyNode = Object.freeze({
|
|
233
235
|
is(node) {
|
|
234
236
|
return node?.type === 'mcdoc:struct/map_key';
|
|
235
237
|
},
|
|
236
238
|
});
|
|
237
|
-
|
|
239
|
+
export const StructSpreadFieldNode = Object.freeze({
|
|
238
240
|
is(node) {
|
|
239
241
|
return node?.type === 'mcdoc:struct/field/spread';
|
|
240
242
|
},
|
|
241
243
|
});
|
|
242
|
-
|
|
244
|
+
export const DispatcherTypeNode = Object.freeze({
|
|
243
245
|
is(node) {
|
|
244
246
|
return node?.type === 'mcdoc:type/dispatcher';
|
|
245
247
|
},
|
|
246
248
|
});
|
|
247
|
-
|
|
249
|
+
export const UnionTypeNode = Object.freeze({
|
|
248
250
|
is(node) {
|
|
249
251
|
return node?.type === 'mcdoc:type/union';
|
|
250
252
|
},
|
|
251
253
|
});
|
|
252
|
-
|
|
254
|
+
export const InjectionNode = Object.freeze({
|
|
253
255
|
is(node) {
|
|
254
256
|
return node?.type === 'mcdoc:injection';
|
|
255
257
|
},
|
|
256
258
|
});
|
|
257
|
-
|
|
259
|
+
export const EnumInjectionNode = Object.freeze({
|
|
258
260
|
is(node) {
|
|
259
261
|
return node?.type === 'mcdoc:injection/enum';
|
|
260
262
|
},
|
|
261
263
|
});
|
|
262
|
-
|
|
264
|
+
export const StructInjectionNode = Object.freeze({
|
|
263
265
|
is(node) {
|
|
264
266
|
return node?.type === 'mcdoc:injection/struct';
|
|
265
267
|
},
|
|
266
268
|
});
|
|
267
|
-
|
|
269
|
+
export const TypeAliasNode = Object.freeze({
|
|
268
270
|
is(node) {
|
|
269
271
|
return node?.type === 'mcdoc:type_alias';
|
|
270
272
|
},
|
|
271
273
|
});
|
|
272
|
-
|
|
274
|
+
export const UseStatementNode = Object.freeze({
|
|
273
275
|
is(node) {
|
|
274
276
|
return node?.type === 'mcdoc:use_statement';
|
|
275
277
|
},
|
package/lib/parser/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColorTokenType, CommentNode, FloatNode, InfallibleParser, IntegerNode, Parser, ResourceLocationNode, ResourceLocationOptions, StringNode } from '@spyglassmc/core';
|
|
2
2
|
import { Arrayable } from '@spyglassmc/core';
|
|
3
|
-
import type { AnyTypeNode, AttributeNode, BooleanTypeNode, DispatcherTypeNode, DispatchStatementNode, DocCommentsNode, EnumNode, IdentifierNode, InjectionNode, ListTypeNode, LiteralNode, LiteralTypeNode, ModuleNode, NumericTypeNode, PathNode, PathTypeNode, PrimitiveArrayTypeNode, StringTypeNode, StructNode, TupleTypeNode, TypeAliasNode, TypedNumberNode, TypeNode, UnionTypeNode, UseStatementNode } from '../node';
|
|
3
|
+
import type { AnyTypeNode, AttributeNode, BooleanTypeNode, DispatcherTypeNode, DispatchStatementNode, DocCommentsNode, EnumNode, IdentifierNode, InjectionNode, ListTypeNode, LiteralNode, LiteralTypeNode, ModuleNode, NumericTypeNode, PathNode, PathTypeNode, PrimitiveArrayTypeNode, StringTypeNode, StructNode, TupleTypeNode, TypeAliasNode, TypedNumberNode, TypeNode, UnionTypeNode, UseStatementNode } from '../node/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* @returns A comment parser that accepts normal comments (`//`) and reports an error if it's a doc comment (`///`).
|
|
6
6
|
*
|