@spyglassmc/core 0.4.0 → 0.4.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/common/Dev.js +5 -2
- package/lib/common/Operations.js +7 -3
- package/lib/common/ReadonlyProxy.js +3 -1
- package/lib/common/StateProxy.js +18 -7
- package/lib/common/externals/BrowserExternals.js +2 -9
- package/lib/common/externals/NodeJsExternals.js +7 -17
- package/lib/common/externals/index.d.ts +0 -3
- package/lib/common/util.d.ts +1 -0
- package/lib/common/util.js +14 -10
- package/lib/node/AstNode.js +6 -4
- package/lib/node/FileNode.js +6 -1
- package/lib/node/ResourceLocationNode.d.ts +2 -2
- package/lib/node/ResourceLocationNode.js +11 -5
- package/lib/parser/boolean.js +1 -1
- package/lib/parser/comment.d.ts +1 -1
- package/lib/parser/comment.js +1 -1
- package/lib/parser/float.js +2 -1
- package/lib/parser/integer.js +2 -1
- package/lib/parser/list.d.ts +1 -1
- package/lib/parser/list.js +3 -3
- package/lib/parser/long.js +2 -1
- package/lib/parser/record.d.ts +1 -1
- package/lib/parser/record.js +18 -8
- package/lib/parser/resourceLocation.js +61 -8
- package/lib/parser/string.js +75 -7
- package/lib/parser/util.js +7 -3
- package/lib/processor/ColorInfoProvider.js +20 -7
- package/lib/processor/binder/builtin.js +27 -17
- package/lib/processor/checker/builtin.d.ts +1 -2
- package/lib/processor/checker/builtin.js +10 -12
- package/lib/processor/colorizer/builtin.js +8 -7
- package/lib/processor/completer/Completer.js +4 -2
- package/lib/processor/completer/builtin.js +26 -23
- package/lib/processor/formatter/builtin.js +14 -12
- package/lib/processor/linter/builtin/undeclaredSymbol.js +47 -24
- package/lib/processor/linter/builtin.js +7 -8
- package/lib/service/CacheService.js +9 -6
- package/lib/service/Config.d.ts +2 -2
- package/lib/service/Config.js +23 -19
- package/lib/service/Downloader.js +12 -7
- package/lib/service/FileService.js +22 -8
- package/lib/service/MetaRegistry.js +7 -6
- package/lib/service/Profiler.js +10 -5
- package/lib/service/Project.js +36 -30
- package/lib/service/Service.js +19 -9
- package/lib/service/fileUtil.js +2 -1
- package/lib/source/IndexMap.js +1 -1
- package/lib/source/LanguageError.js +1 -1
- package/lib/source/Location.js +4 -1
- package/lib/source/Range.js +6 -3
- package/lib/source/Source.js +3 -1
- package/lib/symbol/Symbol.d.ts +7 -7
- package/lib/symbol/Symbol.js +22 -9
- package/lib/symbol/SymbolUtil.d.ts +2 -2
- package/lib/symbol/SymbolUtil.js +74 -43
- package/package.json +2 -2
package/lib/symbol/Symbol.js
CHANGED
|
@@ -77,6 +77,7 @@ export const WorldgenFileCategories = Object.freeze([
|
|
|
77
77
|
'worldgen/configured_feature',
|
|
78
78
|
'worldgen/configured_structure_feature',
|
|
79
79
|
'worldgen/configured_surface_builder',
|
|
80
|
+
'worldgen/density_function',
|
|
80
81
|
'worldgen/noise',
|
|
81
82
|
'worldgen/noise_settings',
|
|
82
83
|
'worldgen/placed_feature',
|
|
@@ -88,7 +89,7 @@ export const TaggableResourceLocationCategories = Object.freeze([
|
|
|
88
89
|
...RegistryCategories,
|
|
89
90
|
...WorldgenFileCategories,
|
|
90
91
|
]);
|
|
91
|
-
export const TagFileCategories = Object.freeze(TaggableResourceLocationCategories.map(key => `tag/${key}`));
|
|
92
|
+
export const TagFileCategories = Object.freeze(TaggableResourceLocationCategories.map((key) => `tag/${key}`));
|
|
92
93
|
export const FileCategories = Object.freeze([
|
|
93
94
|
'advancement',
|
|
94
95
|
'dimension',
|
|
@@ -138,9 +139,7 @@ export var ResourceLocationCategory;
|
|
|
138
139
|
export var SymbolPath;
|
|
139
140
|
(function (SymbolPath) {
|
|
140
141
|
function fromSymbol(symbol) {
|
|
141
|
-
return symbol
|
|
142
|
-
? { category: symbol.category, path: symbol.path }
|
|
143
|
-
: undefined;
|
|
142
|
+
return symbol ? { category: symbol.category, path: symbol.path } : undefined;
|
|
144
143
|
}
|
|
145
144
|
SymbolPath.fromSymbol = fromSymbol;
|
|
146
145
|
/**
|
|
@@ -170,7 +169,13 @@ export class SymbolPathCollector {
|
|
|
170
169
|
return [...this.#set].map(SymbolPath.fromString);
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
|
-
export const SymbolUsageTypes = Object.freeze([
|
|
172
|
+
export const SymbolUsageTypes = Object.freeze([
|
|
173
|
+
'definition',
|
|
174
|
+
'declaration',
|
|
175
|
+
'implementation',
|
|
176
|
+
'reference',
|
|
177
|
+
'typeDefinition',
|
|
178
|
+
]);
|
|
174
179
|
export var SymbolUsageType;
|
|
175
180
|
(function (SymbolUsageType) {
|
|
176
181
|
function is(value) {
|
|
@@ -203,9 +208,14 @@ export var SymbolLocation;
|
|
|
203
208
|
function create(doc, range, fullRange, contributor, additional) {
|
|
204
209
|
return {
|
|
205
210
|
...Location.create(doc, range),
|
|
206
|
-
...
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
...(fullRange
|
|
212
|
+
? {
|
|
213
|
+
fullRange: Range.get(fullRange),
|
|
214
|
+
fullPosRange: PositionRange.from(fullRange, doc),
|
|
215
|
+
}
|
|
216
|
+
: {}),
|
|
217
|
+
...(contributor ? { contributor } : {}),
|
|
218
|
+
...(additional ? additional : {}),
|
|
209
219
|
};
|
|
210
220
|
}
|
|
211
221
|
SymbolLocation.create = create;
|
|
@@ -233,7 +243,10 @@ export var SymbolTable;
|
|
|
233
243
|
};
|
|
234
244
|
const linkSymbolMap = (map, parentSymbol, category, path) => {
|
|
235
245
|
for (const [identifier, childSymbol] of Object.entries(map)) {
|
|
236
|
-
linkSymbol(childSymbol, map, parentSymbol, category, [
|
|
246
|
+
linkSymbol(childSymbol, map, parentSymbol, category, [
|
|
247
|
+
...path,
|
|
248
|
+
identifier,
|
|
249
|
+
]);
|
|
237
250
|
}
|
|
238
251
|
};
|
|
239
252
|
const ans = rfdc()(table);
|
|
@@ -99,7 +99,7 @@ export declare class SymbolUtil implements ExternalEventEmitter {
|
|
|
99
99
|
* - `uri` - clear symbol locations associated with this URI.
|
|
100
100
|
* - `predicate` - clear symbol locations matching this predicate
|
|
101
101
|
*/
|
|
102
|
-
clear({ uri, contributor, predicate }: {
|
|
102
|
+
clear({ uri, contributor, predicate, }: {
|
|
103
103
|
contributor?: string;
|
|
104
104
|
uri?: string;
|
|
105
105
|
predicate?: (this: void, data: SymbolLocationEvent) => boolean;
|
|
@@ -282,7 +282,7 @@ export declare class SymbolQuery {
|
|
|
282
282
|
util: SymbolUtil;
|
|
283
283
|
get symbol(): Symbol | undefined;
|
|
284
284
|
get visibleMembers(): SymbolMap;
|
|
285
|
-
constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util }: {
|
|
285
|
+
constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util, }: {
|
|
286
286
|
category: string;
|
|
287
287
|
contributor: string | undefined;
|
|
288
288
|
doc: DocAndNode | TextDocument | string;
|
package/lib/symbol/SymbolUtil.js
CHANGED
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
8
8
|
import { Range } from '../source/index.js';
|
|
9
|
-
import { SymbolLocation, SymbolPath, SymbolUsageTypes } from './Symbol.js';
|
|
9
|
+
import { SymbolLocation, SymbolPath, SymbolUsageTypes, } from './Symbol.js';
|
|
10
10
|
export class SymbolUtil {
|
|
11
11
|
#global;
|
|
12
12
|
#eventEmitter;
|
|
@@ -35,16 +35,16 @@ export class SymbolUtil {
|
|
|
35
35
|
this.#global = global;
|
|
36
36
|
this.#currentContributor = _currentContributor;
|
|
37
37
|
this._inDelayMode = _inDelayMode;
|
|
38
|
-
this
|
|
39
|
-
.on('symbolCreated', ({ symbol }) => {
|
|
38
|
+
this.on('symbolCreated', ({ symbol }) => {
|
|
40
39
|
this.#trimmableSymbols.add(SymbolPath.toString(symbol));
|
|
41
40
|
})
|
|
42
41
|
.on('symbolRemoved', ({ symbol }) => {
|
|
43
42
|
this.#trimmableSymbols.delete(SymbolPath.toString(symbol));
|
|
44
43
|
})
|
|
45
44
|
.on('symbolLocationCreated', ({ symbol, location }) => {
|
|
46
|
-
const cache = this.#cache[location.contributor ?? 'undefined'] ??=
|
|
47
|
-
|
|
45
|
+
const cache = (this.#cache[location.contributor ?? 'undefined'] ??=
|
|
46
|
+
Object.create(null));
|
|
47
|
+
const fileSymbols = (cache[location.uri] ??= new Set());
|
|
48
48
|
const path = SymbolPath.toString(symbol);
|
|
49
49
|
fileSymbols.add(path);
|
|
50
50
|
this.#trimmableSymbols.delete(path);
|
|
@@ -69,7 +69,7 @@ export class SymbolUtil {
|
|
|
69
69
|
* Build the internal cache of the SymbolUtil according to the current global symbol table.
|
|
70
70
|
*/
|
|
71
71
|
buildCache() {
|
|
72
|
-
SymbolUtil.forEachSymbol(this.global, symbol => {
|
|
72
|
+
SymbolUtil.forEachSymbol(this.global, (symbol) => {
|
|
73
73
|
this.emit('symbolCreated', { symbol });
|
|
74
74
|
SymbolUtil.forEachLocationOfSymbol(symbol, ({ type, location }) => {
|
|
75
75
|
this.emit('symbolLocationCreated', { symbol, type, location });
|
|
@@ -90,7 +90,7 @@ export class SymbolUtil {
|
|
|
90
90
|
* Apply edits done during the delay mode.
|
|
91
91
|
*/
|
|
92
92
|
applyDelayedEdits() {
|
|
93
|
-
this._delayedOps.forEach(f => f());
|
|
93
|
+
this._delayedOps.forEach((f) => f());
|
|
94
94
|
this._delayedOps = [];
|
|
95
95
|
this._inDelayMode = false;
|
|
96
96
|
}
|
|
@@ -123,7 +123,7 @@ export class SymbolUtil {
|
|
|
123
123
|
* - `uri` - clear symbol locations associated with this URI.
|
|
124
124
|
* - `predicate` - clear symbol locations matching this predicate
|
|
125
125
|
*/
|
|
126
|
-
clear({ uri, contributor, predicate = () => true }) {
|
|
126
|
+
clear({ uri, contributor, predicate = () => true, }) {
|
|
127
127
|
const getCaches = () => {
|
|
128
128
|
if (contributor) {
|
|
129
129
|
return this.#cache[contributor] ? [this.#cache[contributor]] : [];
|
|
@@ -135,14 +135,15 @@ export class SymbolUtil {
|
|
|
135
135
|
const getPaths = () => {
|
|
136
136
|
const caches = getCaches();
|
|
137
137
|
const sets = uri
|
|
138
|
-
? caches.map(cache => cache[uri] ?? new Set())
|
|
139
|
-
: caches.map(cache => Object.values(cache)).flat();
|
|
140
|
-
return sets
|
|
138
|
+
? caches.map((cache) => cache[uri] ?? new Set())
|
|
139
|
+
: caches.map((cache) => Object.values(cache)).flat();
|
|
140
|
+
return sets
|
|
141
|
+
.map((s) => [...s])
|
|
142
|
+
.flat()
|
|
143
|
+
.map(SymbolPath.fromString);
|
|
141
144
|
};
|
|
142
145
|
const getTables = () => {
|
|
143
|
-
return uri
|
|
144
|
-
? [this.#global]
|
|
145
|
-
: [this.#global];
|
|
146
|
+
return uri ? [this.#global] : [this.#global];
|
|
146
147
|
};
|
|
147
148
|
const paths = getPaths();
|
|
148
149
|
const tables = getTables();
|
|
@@ -153,7 +154,7 @@ export class SymbolUtil {
|
|
|
153
154
|
continue;
|
|
154
155
|
}
|
|
155
156
|
this.removeLocationsFromSymbol(symbol, uri
|
|
156
|
-
? data => data.location.uri === uri && predicate(data)
|
|
157
|
+
? (data) => data.location.uri === uri && predicate(data)
|
|
157
158
|
: predicate);
|
|
158
159
|
}
|
|
159
160
|
this.trim(table);
|
|
@@ -277,7 +278,9 @@ export class SymbolUtil {
|
|
|
277
278
|
if (result.symbol) {
|
|
278
279
|
return result;
|
|
279
280
|
}
|
|
280
|
-
if (!parentSymbol &&
|
|
281
|
+
if (!parentSymbol &&
|
|
282
|
+
!parentMap &&
|
|
283
|
+
(result.parentSymbol || result.parentMap)) {
|
|
281
284
|
parentSymbol = result.parentSymbol;
|
|
282
285
|
parentMap = result.parentMap;
|
|
283
286
|
}
|
|
@@ -285,14 +288,14 @@ export class SymbolUtil {
|
|
|
285
288
|
return { parentSymbol, parentMap, symbol: undefined };
|
|
286
289
|
}
|
|
287
290
|
createSymbol(category, parentSymbol, parentMap, path, identifier, addition, doc, contributor) {
|
|
288
|
-
const ans = parentMap[identifier] = {
|
|
291
|
+
const ans = (parentMap[identifier] = {
|
|
289
292
|
category,
|
|
290
293
|
identifier,
|
|
291
|
-
...parentSymbol ? { parentSymbol } : {},
|
|
294
|
+
...(parentSymbol ? { parentSymbol } : {}),
|
|
292
295
|
parentMap,
|
|
293
296
|
path,
|
|
294
297
|
...addition.data,
|
|
295
|
-
};
|
|
298
|
+
});
|
|
296
299
|
this.emit('symbolCreated', { symbol: ans });
|
|
297
300
|
this.amendSymbolUsage(ans, addition.usage, doc, contributor);
|
|
298
301
|
return ans;
|
|
@@ -321,8 +324,12 @@ export class SymbolUtil {
|
|
|
321
324
|
if ('visibility' in addition) {
|
|
322
325
|
// Visibility changes are only accepted if the change wouldn't result in the
|
|
323
326
|
// symbol being stored in a different symbol table.
|
|
324
|
-
const inGlobalTable = (v) => v === undefined ||
|
|
325
|
-
|
|
327
|
+
const inGlobalTable = (v) => v === undefined ||
|
|
328
|
+
v === 2 /* SymbolVisibility.Public */ ||
|
|
329
|
+
v === 3 /* SymbolVisibility.Restricted */;
|
|
330
|
+
if (symbol.visibility === addition.visibility ||
|
|
331
|
+
(inGlobalTable(symbol.visibility) &&
|
|
332
|
+
inGlobalTable(addition.visibility))) {
|
|
326
333
|
symbol.visibility = addition.visibility;
|
|
327
334
|
}
|
|
328
335
|
else {
|
|
@@ -337,8 +344,10 @@ export class SymbolUtil {
|
|
|
337
344
|
amendSymbolUsage(symbol, addition, doc, contributor) {
|
|
338
345
|
if (addition) {
|
|
339
346
|
const type = addition.type ?? 'reference';
|
|
340
|
-
const arr = symbol[type] ??= [];
|
|
341
|
-
const range = Range.get((SymbolAdditionUsageWithNode.is(addition)
|
|
347
|
+
const arr = (symbol[type] ??= []);
|
|
348
|
+
const range = Range.get((SymbolAdditionUsageWithNode.is(addition)
|
|
349
|
+
? addition.node
|
|
350
|
+
: addition.range) ?? 0);
|
|
342
351
|
const location = SymbolLocation.create(doc, range, addition.fullRange, contributor, {
|
|
343
352
|
accessType: addition.accessType,
|
|
344
353
|
skipRenaming: addition.skipRenaming,
|
|
@@ -371,7 +380,12 @@ export class SymbolUtil {
|
|
|
371
380
|
return ans;
|
|
372
381
|
}
|
|
373
382
|
static isTrimmable(symbol) {
|
|
374
|
-
return !Object.keys(symbol.members ?? {}).length &&
|
|
383
|
+
return (!Object.keys(symbol.members ?? {}).length &&
|
|
384
|
+
!symbol.declaration?.length &&
|
|
385
|
+
!symbol.definition?.length &&
|
|
386
|
+
!symbol.implementation?.length &&
|
|
387
|
+
!symbol.reference?.length &&
|
|
388
|
+
!symbol.typeDefinition?.length);
|
|
375
389
|
}
|
|
376
390
|
static isVisible(symbol, _uri) {
|
|
377
391
|
switch (symbol.visibility) {
|
|
@@ -394,7 +408,8 @@ export class SymbolUtil {
|
|
|
394
408
|
* @returns If the symbol has definitions, or declarations and implementations.
|
|
395
409
|
*/
|
|
396
410
|
static isDefined(symbol) {
|
|
397
|
-
return !!(symbol?.definition?.length ||
|
|
411
|
+
return !!(symbol?.definition?.length ||
|
|
412
|
+
(symbol?.definition?.length && symbol?.implementation?.length));
|
|
398
413
|
}
|
|
399
414
|
/**
|
|
400
415
|
* @returns If the symbol has implementations or definitions.
|
|
@@ -418,7 +433,11 @@ export class SymbolUtil {
|
|
|
418
433
|
* @throws If the symbol does not have any declarations or definitions.
|
|
419
434
|
*/
|
|
420
435
|
static getDeclaredLocation(symbol) {
|
|
421
|
-
return symbol.declaration?.[0] ??
|
|
436
|
+
return (symbol.declaration?.[0] ??
|
|
437
|
+
symbol.definition?.[0] ??
|
|
438
|
+
(() => {
|
|
439
|
+
throw new Error(`Cannot get declared location of ${JSON.stringify(SymbolPath.fromSymbol(symbol))}`);
|
|
440
|
+
})());
|
|
422
441
|
}
|
|
423
442
|
static forEachSymbolInMap(map, fn) {
|
|
424
443
|
for (const symbol of Object.values(map)) {
|
|
@@ -435,11 +454,13 @@ export class SymbolUtil {
|
|
|
435
454
|
}
|
|
436
455
|
static forEachLocationOfSymbol(symbol, fn) {
|
|
437
456
|
for (const type of SymbolUsageTypes) {
|
|
438
|
-
symbol[type]?.forEach(location => fn({ type, location }));
|
|
457
|
+
symbol[type]?.forEach((location) => fn({ type, location }));
|
|
439
458
|
}
|
|
440
459
|
}
|
|
441
460
|
static isVisibilityInGlobal(v) {
|
|
442
|
-
return v === undefined ||
|
|
461
|
+
return (v === undefined ||
|
|
462
|
+
v === 2 /* SymbolVisibility.Public */ ||
|
|
463
|
+
v === 3 /* SymbolVisibility.Restricted */);
|
|
443
464
|
}
|
|
444
465
|
static areVisibilitiesCompatible(v1, v2) {
|
|
445
466
|
return ((this.isVisibilityInGlobal(v1) && this.isVisibilityInGlobal(v2)) ||
|
|
@@ -505,7 +526,7 @@ export class SymbolQuery {
|
|
|
505
526
|
get visibleMembers() {
|
|
506
527
|
return SymbolUtil.filterVisibleSymbols(this.#doc.uri, this.path.length === 0 ? this.#map : this.#symbol?.members);
|
|
507
528
|
}
|
|
508
|
-
constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util }) {
|
|
529
|
+
constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util, }) {
|
|
509
530
|
this.category = category;
|
|
510
531
|
this.path = path;
|
|
511
532
|
if (typeof doc === 'string') {
|
|
@@ -545,13 +566,13 @@ export class SymbolQuery {
|
|
|
545
566
|
* Calls `fn` if the queried symbol does not exist.
|
|
546
567
|
*/
|
|
547
568
|
ifUnknown(fn) {
|
|
548
|
-
return this.if(s => s === undefined, fn);
|
|
569
|
+
return this.if((s) => s === undefined, fn);
|
|
549
570
|
}
|
|
550
571
|
/**
|
|
551
572
|
* Calls `fn` if the queried symbol exists (i.e. has any of declarations/definitions/implementations/references/typeDefinitions).
|
|
552
573
|
*/
|
|
553
574
|
ifKnown(fn) {
|
|
554
|
-
return this.if(s => s !== undefined, fn);
|
|
575
|
+
return this.if((s) => s !== undefined, fn);
|
|
555
576
|
}
|
|
556
577
|
/**
|
|
557
578
|
* Calls `fn` if the queried symbol has declarations or definitions.
|
|
@@ -613,11 +634,14 @@ export class SymbolQuery {
|
|
|
613
634
|
* * If the visibility is `undefined`, use the visibility of the symbol, or `Public` if unapplicable.
|
|
614
635
|
*/
|
|
615
636
|
const getAdditionVisibility = (addition) => {
|
|
616
|
-
return addition.data?.visibility ??
|
|
637
|
+
return (addition.data?.visibility ??
|
|
638
|
+
this.symbol?.visibility ??
|
|
639
|
+
2 /* SymbolVisibility.Public */);
|
|
617
640
|
};
|
|
618
641
|
const getMap = (addition) => {
|
|
619
642
|
const additionVisibility = getAdditionVisibility(addition);
|
|
620
|
-
if (this.#map &&
|
|
643
|
+
if (this.#map &&
|
|
644
|
+
SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#symbol?.visibility)) {
|
|
621
645
|
return this.#map;
|
|
622
646
|
}
|
|
623
647
|
if (this.path.length > 1) {
|
|
@@ -625,7 +649,7 @@ export class SymbolQuery {
|
|
|
625
649
|
if (!SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#parentSymbol.visibility)) {
|
|
626
650
|
throw new Error(`Cannot enter member “${this.getPath()}” of ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility to parent of ${SymbolFormatter.stringifyVisibility(this.#parentSymbol.visibility)} visibility`);
|
|
627
651
|
}
|
|
628
|
-
return this.#parentSymbol.members ??= {};
|
|
652
|
+
return (this.#parentSymbol.members ??= {});
|
|
629
653
|
}
|
|
630
654
|
}
|
|
631
655
|
else {
|
|
@@ -666,12 +690,13 @@ export class SymbolQuery {
|
|
|
666
690
|
}
|
|
667
691
|
}
|
|
668
692
|
// TODO: Move part of symbol from global to table.
|
|
669
|
-
return table[this.category] ??= {};
|
|
693
|
+
return (table[this.category] ??= {});
|
|
670
694
|
}
|
|
671
695
|
throw new Error(`Cannot create the symbol map for “${this.getPath()}”`);
|
|
672
696
|
};
|
|
673
697
|
// Treat `usage.range` as `[0, 0)` if this class was constructed with a string URI (instead of a `TextDocument`).
|
|
674
|
-
if (this.#createdWithUri &&
|
|
698
|
+
if (this.#createdWithUri &&
|
|
699
|
+
SymbolAdditionUsageWithRange.is(addition.usage)) {
|
|
675
700
|
addition.usage.range = Range.create(0, 0);
|
|
676
701
|
}
|
|
677
702
|
this.#map = getMap(addition);
|
|
@@ -767,7 +792,7 @@ export class SymbolQuery {
|
|
|
767
792
|
return this;
|
|
768
793
|
}
|
|
769
794
|
forEachMember(fn) {
|
|
770
|
-
return this.onEach(Object.keys(this.visibleMembers), identifier => this.member(identifier, query => fn(identifier, query)));
|
|
795
|
+
return this.onEach(Object.keys(this.visibleMembers), (identifier) => this.member(identifier, (query) => fn(identifier, query)));
|
|
771
796
|
}
|
|
772
797
|
getPath() {
|
|
773
798
|
return `${this.category}.${this.path.join('/')}`;
|
|
@@ -789,7 +814,9 @@ export var SymbolFormatter;
|
|
|
789
814
|
}
|
|
790
815
|
}
|
|
791
816
|
function stringifySymbolStack(stack) {
|
|
792
|
-
return stack
|
|
817
|
+
return stack
|
|
818
|
+
.map((table) => stringifySymbolTable(table))
|
|
819
|
+
.join('\n------------\n');
|
|
793
820
|
}
|
|
794
821
|
SymbolFormatter.stringifySymbolStack = stringifySymbolStack;
|
|
795
822
|
function stringifySymbolTable(table, indent = '') {
|
|
@@ -798,7 +825,9 @@ export var SymbolFormatter;
|
|
|
798
825
|
const map = table[category];
|
|
799
826
|
ans.push([category, stringifySymbolMap(map, `${indent}${IndentChar}`)]);
|
|
800
827
|
}
|
|
801
|
-
return ans
|
|
828
|
+
return (ans
|
|
829
|
+
.map((v) => `CATEGORY ${v[0]}\n${v[1]}`)
|
|
830
|
+
.join(`\n${indent}------------\n`) || 'EMPTY TABLE');
|
|
802
831
|
}
|
|
803
832
|
SymbolFormatter.stringifySymbolTable = stringifySymbolTable;
|
|
804
833
|
function stringifySymbolMap(map, indent = '') {
|
|
@@ -831,7 +860,7 @@ export var SymbolFormatter;
|
|
|
831
860
|
}
|
|
832
861
|
for (const type of SymbolUsageTypes) {
|
|
833
862
|
if (symbol[type]) {
|
|
834
|
-
ans.push(`${IndentChar}${type}:\n${symbol[type].map(v => `${indent}${IndentChar.repeat(2)}${JSON.stringify(v)}`).join(`\n${indent}${IndentChar.repeat(2)}------------\n`)}`);
|
|
863
|
+
ans.push(`${IndentChar}${type}:\n${symbol[type].map((v) => `${indent}${IndentChar.repeat(2)}${JSON.stringify(v)}`).join(`\n${indent}${IndentChar.repeat(2)}------------\n`)}`);
|
|
835
864
|
}
|
|
836
865
|
}
|
|
837
866
|
if (symbol.relations) {
|
|
@@ -840,7 +869,7 @@ export var SymbolFormatter;
|
|
|
840
869
|
if (symbol.members) {
|
|
841
870
|
ans.push(`${IndentChar}members:\n${stringifySymbolMap(symbol.members, `${indent}${IndentChar.repeat(2)}`)}`);
|
|
842
871
|
}
|
|
843
|
-
return ans.map(v => `${indent}${v}`).join('\n');
|
|
872
|
+
return ans.map((v) => `${indent}${v}`).join('\n');
|
|
844
873
|
}
|
|
845
874
|
SymbolFormatter.stringifySymbol = stringifySymbol;
|
|
846
875
|
function stringifyVisibility(visibility, visibilityRestriction) {
|
|
@@ -860,7 +889,9 @@ export var SymbolFormatter;
|
|
|
860
889
|
stringVisibility = 'Public';
|
|
861
890
|
break;
|
|
862
891
|
}
|
|
863
|
-
return `${stringVisibility}${visibilityRestriction
|
|
892
|
+
return `${stringVisibility}${visibilityRestriction
|
|
893
|
+
? ` ${visibilityRestriction.map((v) => `“${v}”`).join(', ')}`
|
|
894
|
+
: ''}`;
|
|
864
895
|
}
|
|
865
896
|
SymbolFormatter.stringifyVisibility = stringifyVisibility;
|
|
866
897
|
function stringifyLookupResult(result) {
|
|
@@ -879,7 +910,7 @@ ${stringifySymbol(result.symbol, IndentChar)}`;
|
|
|
879
910
|
*
|
|
880
911
|
* The decorated method MUST have return type `void`.
|
|
881
912
|
*/
|
|
882
|
-
function DelayModeSupport(getUtil = self => self) {
|
|
913
|
+
function DelayModeSupport(getUtil = (self) => self) {
|
|
883
914
|
return (_target, _key, descripter) => {
|
|
884
915
|
const decoratedMethod = descripter.value;
|
|
885
916
|
// The `function` syntax is used to preserve `this` context from the decorated method.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"pako": "^2.0.4",
|
|
24
24
|
"rfdc": "^1.3.0",
|
|
25
25
|
"vscode-languageserver-textdocument": "^1.0.4",
|
|
26
|
-
"@spyglassmc/locales": "0.3.
|
|
26
|
+
"@spyglassmc/locales": "0.3.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/decompress": "^4.2.3",
|