@spyglassmc/core 0.4.5 → 0.4.6

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.
Files changed (91) hide show
  1. package/lib/common/Dev.js +2 -5
  2. package/lib/common/ReadonlyProxy.js +1 -3
  3. package/lib/common/StateProxy.js +2 -8
  4. package/lib/common/externals/BrowserExternals.js +7 -12
  5. package/lib/common/externals/NodeJsExternals.js +12 -8
  6. package/lib/common/externals/index.d.ts +8 -1
  7. package/lib/common/util.js +3 -10
  8. package/lib/node/AstNode.js +7 -9
  9. package/lib/node/BooleanNode.js +1 -4
  10. package/lib/node/FloatNode.js +1 -5
  11. package/lib/node/IntegerNode.js +1 -5
  12. package/lib/node/ListNode.d.ts +1 -1
  13. package/lib/node/LiteralNode.js +1 -6
  14. package/lib/node/LongNode.js +1 -5
  15. package/lib/node/PrefixedNode.d.ts +13 -0
  16. package/lib/node/PrefixedNode.js +22 -0
  17. package/lib/node/ResourceLocationNode.d.ts +1 -1
  18. package/lib/node/ResourceLocationNode.js +2 -8
  19. package/lib/node/StringNode.d.ts +2 -1
  20. package/lib/node/StringNode.js +1 -4
  21. package/lib/node/SymbolNode.js +1 -6
  22. package/lib/node/index.d.ts +1 -0
  23. package/lib/node/index.js +1 -0
  24. package/lib/parser/comment.d.ts +1 -1
  25. package/lib/parser/comment.js +2 -6
  26. package/lib/parser/error.js +1 -4
  27. package/lib/parser/file.d.ts +2 -2
  28. package/lib/parser/file.js +1 -2
  29. package/lib/parser/float.js +2 -7
  30. package/lib/parser/index.d.ts +1 -0
  31. package/lib/parser/index.js +1 -0
  32. package/lib/parser/integer.js +3 -7
  33. package/lib/parser/list.d.ts +1 -1
  34. package/lib/parser/list.js +2 -6
  35. package/lib/parser/literal.js +2 -9
  36. package/lib/parser/long.js +2 -7
  37. package/lib/parser/prefixed.d.ts +8 -0
  38. package/lib/parser/prefixed.js +23 -0
  39. package/lib/parser/record.d.ts +1 -1
  40. package/lib/parser/record.js +11 -17
  41. package/lib/parser/resourceLocation.d.ts +1 -0
  42. package/lib/parser/resourceLocation.js +6 -4
  43. package/lib/parser/string.js +6 -9
  44. package/lib/parser/util.d.ts +14 -3
  45. package/lib/parser/util.js +48 -26
  46. package/lib/processor/ColorInfoProvider.js +8 -25
  47. package/lib/processor/binder/builtin.d.ts +1 -0
  48. package/lib/processor/binder/builtin.js +20 -30
  49. package/lib/processor/checker/builtin.d.ts +1 -0
  50. package/lib/processor/checker/builtin.js +13 -7
  51. package/lib/processor/colorizer/Colorizer.d.ts +1 -1
  52. package/lib/processor/colorizer/Colorizer.js +4 -7
  53. package/lib/processor/colorizer/builtin.js +2 -2
  54. package/lib/processor/completer/Completer.js +1 -3
  55. package/lib/processor/completer/builtin.d.ts +3 -2
  56. package/lib/processor/completer/builtin.js +67 -23
  57. package/lib/processor/formatter/Formatter.js +1 -3
  58. package/lib/processor/formatter/builtin.js +2 -4
  59. package/lib/processor/linter/builtin/undeclaredSymbol.js +27 -40
  60. package/lib/service/CacheService.d.ts +1 -1
  61. package/lib/service/CacheService.js +12 -13
  62. package/lib/service/Config.d.ts +36 -0
  63. package/lib/service/Config.js +28 -45
  64. package/lib/service/Context.d.ts +2 -0
  65. package/lib/service/Context.js +4 -12
  66. package/lib/service/Downloader.d.ts +3 -0
  67. package/lib/service/Downloader.js +9 -3
  68. package/lib/service/ErrorReporter.js +3 -0
  69. package/lib/service/FileService.js +10 -29
  70. package/lib/service/Hover.js +1 -4
  71. package/lib/service/MetaRegistry.d.ts +4 -2
  72. package/lib/service/MetaRegistry.js +16 -8
  73. package/lib/service/Project.d.ts +9 -3
  74. package/lib/service/Project.js +71 -48
  75. package/lib/service/Service.d.ts +1 -1
  76. package/lib/service/Service.js +11 -36
  77. package/lib/service/SymbolLocations.js +1 -4
  78. package/lib/service/fileUtil.d.ts +7 -0
  79. package/lib/service/fileUtil.js +29 -4
  80. package/lib/source/IndexMap.js +1 -4
  81. package/lib/source/Location.js +3 -9
  82. package/lib/source/Position.js +1 -2
  83. package/lib/source/PositionRange.js +2 -2
  84. package/lib/source/Range.js +9 -21
  85. package/lib/source/Source.d.ts +11 -1
  86. package/lib/source/Source.js +31 -5
  87. package/lib/symbol/Symbol.d.ts +14 -9
  88. package/lib/symbol/Symbol.js +80 -61
  89. package/lib/symbol/SymbolUtil.d.ts +3 -3
  90. package/lib/symbol/SymbolUtil.js +48 -72
  91. package/package.json +3 -2
@@ -2,39 +2,54 @@ import rfdc from 'rfdc';
2
2
  import { isIterable } from '../common/index.js';
3
3
  import { Location, PositionRange, Range } from '../source/index.js';
4
4
  // #region Mcdoc Categories
5
- export const McdocCategories = Object.freeze([
6
- 'mcdoc',
7
- 'mcdoc/dispatcher',
8
- ]);
5
+ export const McdocCategories = Object.freeze(['mcdoc', 'mcdoc/dispatcher']);
9
6
  // #endregion
10
7
  // #region Registry Categories
11
8
  // Data in `java-edition/src/binder/index.ts` may need to be updated when this section is changed.
12
9
  export const RegistryCategories = Object.freeze([
13
10
  'activity',
11
+ 'armor_material',
14
12
  'attribute',
15
13
  'block',
16
14
  'block_entity_type',
17
15
  'block_predicate_type',
16
+ 'block_type',
17
+ 'cat_variant',
18
18
  'chunk_status',
19
+ 'command_argument_type',
20
+ 'creative_mode_tab',
19
21
  'custom_stat',
20
- 'enchantment',
22
+ 'data_component_type',
23
+ 'decorated_pot_pattern',
24
+ 'enchantment_effect_component_type',
25
+ 'enchantment_entity_effect_type',
26
+ 'enchantment_level_based_value_type',
27
+ 'enchantment_location_based_effect_type',
28
+ 'enchantment_provider_type',
29
+ 'enchantment_value_effect_type',
30
+ 'entity_sub_predicate_type',
21
31
  'entity_type',
22
32
  'float_provider_type',
23
33
  'fluid',
34
+ 'frog_variant',
24
35
  'game_event',
25
36
  'height_provider_type',
37
+ 'instrument',
26
38
  'int_provider_type',
27
39
  'item',
40
+ 'item_sub_predicate_type',
28
41
  'loot_condition_type',
29
42
  'loot_function_type',
30
43
  'loot_nbt_provider_type',
31
44
  'loot_number_provider_type',
32
45
  'loot_pool_entry_type',
33
46
  'loot_score_provider_type',
47
+ 'map_decoration_type',
34
48
  'memory_module_type',
35
49
  'menu',
36
50
  'mob_effect',
37
- 'motive',
51
+ 'motive', // Removed
52
+ 'number_format_type',
38
53
  'particle_type',
39
54
  'point_of_interest_type',
40
55
  'pos_rule_test',
@@ -42,94 +57,112 @@ export const RegistryCategories = Object.freeze([
42
57
  'potion',
43
58
  'recipe_serializer',
44
59
  'recipe_type',
60
+ 'rule_block_entity_modifier',
45
61
  'rule_test',
46
62
  'schedule',
47
63
  'sensor_type',
48
64
  'sound_event',
49
65
  'stat_type',
66
+ 'trigger_type',
50
67
  'villager_profession',
51
68
  'villager_type',
52
69
  'worldgen/biome_source',
53
- 'worldgen/block_placer_type', // Removed from Minecraft at some point. Still used by JSON checkers.
70
+ 'worldgen/block_placer_type', // Removed
54
71
  'worldgen/block_state_provider_type',
55
72
  'worldgen/carver',
56
73
  'worldgen/chunk_generator',
57
- 'worldgen/decorator',
74
+ 'worldgen/decorator', // Removed
75
+ 'worldgen/density_function_type',
58
76
  'worldgen/feature',
59
77
  'worldgen/feature_size_type',
60
78
  'worldgen/foliage_placer_type',
61
79
  'worldgen/material_condition',
62
80
  'worldgen/material_rule',
63
81
  'worldgen/placement_modifier_type',
64
- 'worldgen/structure_feature',
82
+ 'worldgen/pool_alias_binding',
83
+ 'worldgen/root_placer_type',
84
+ 'worldgen/structure_feature', // Removed
65
85
  'worldgen/structure_piece',
86
+ 'worldgen/structure_placement',
66
87
  'worldgen/structure_pool_element',
67
88
  'worldgen/structure_processor',
68
- 'worldgen/surface_builder', // Removed from Minecraft at some point. Still used by JSON checkers.
89
+ 'worldgen/structure_type',
90
+ 'worldgen/surface_builder', // Removed
69
91
  'worldgen/tree_decorator_type',
70
92
  'worldgen/trunk_placer_type',
71
93
  ]);
72
94
  // #endregion
73
95
  // #region Data Pack Categories
74
- export const WorldgenFileCategories = Object.freeze([
75
- 'worldgen/biome',
76
- 'worldgen/configured_carver',
77
- 'worldgen/configured_feature',
78
- 'worldgen/configured_structure_feature',
79
- 'worldgen/configured_surface_builder',
80
- 'worldgen/density_function',
81
- 'worldgen/noise',
82
- 'worldgen/noise_settings',
83
- 'worldgen/placed_feature',
84
- 'worldgen/processor_list',
85
- 'worldgen/template_pool',
86
- ]);
87
- export const TaggableResourceLocationCategories = Object.freeze([
88
- 'function',
89
- ...RegistryCategories,
90
- ...WorldgenFileCategories,
91
- ]);
92
- export const TagFileCategories = Object.freeze(TaggableResourceLocationCategories.map((key) => `tag/${key}`));
93
- export const FileCategories = Object.freeze([
96
+ export const NormalFileCategories = Object.freeze([
94
97
  'advancement',
98
+ 'banner_pattern',
95
99
  'chat_type',
96
100
  'damage_type',
97
101
  'dimension',
98
102
  'dimension_type',
103
+ 'enchantment',
104
+ 'enchantment_provider',
99
105
  'function',
100
106
  'item_modifier',
107
+ 'jukebox_song',
101
108
  'loot_table',
109
+ 'painting_variant',
102
110
  'predicate',
103
111
  'recipe',
104
112
  'structure',
105
113
  'trim_material',
106
114
  'trim_pattern',
107
- ...TagFileCategories,
108
- ...WorldgenFileCategories,
115
+ 'wolf_variant',
116
+ ]);
117
+ export const WorldgenFileCategories = Object.freeze([
118
+ 'worldgen/biome',
119
+ 'worldgen/configured_carver',
120
+ 'worldgen/configured_feature',
121
+ 'worldgen/configured_structure_feature',
122
+ 'worldgen/configured_surface_builder',
123
+ 'worldgen/density_function',
124
+ 'worldgen/flat_level_generator_preset',
125
+ 'worldgen/multi_noise_biome_source_parameter_list',
126
+ 'worldgen/noise',
127
+ 'worldgen/noise_settings',
128
+ 'worldgen/placed_feature',
129
+ 'worldgen/processor_list',
130
+ 'worldgen/structure',
131
+ 'worldgen/structure_set',
132
+ 'worldgen/template_pool',
133
+ 'worldgen/world_preset',
109
134
  ]);
135
+ export const TaggableResourceLocationCategories = Object.freeze([...NormalFileCategories, ...RegistryCategories, ...WorldgenFileCategories]);
136
+ export var TaggableResourceLocationCategory;
137
+ (function (TaggableResourceLocationCategory) {
138
+ function is(category) {
139
+ return TaggableResourceLocationCategories.includes(category);
140
+ }
141
+ TaggableResourceLocationCategory.is = is;
142
+ })(TaggableResourceLocationCategory || (TaggableResourceLocationCategory = {}));
143
+ export const TagFileCategories = Object.freeze(TaggableResourceLocationCategories.map((key) => `tag/${key}`));
144
+ export const FileCategories = Object.freeze([...NormalFileCategories, ...TagFileCategories, ...WorldgenFileCategories]);
110
145
  export const MiscCategories = Object.freeze([
111
- 'attribute_modifier_uuid',
146
+ 'attribute_modifier',
112
147
  'bossbar',
148
+ 'jigsaw_block_name',
149
+ 'random_sequence',
150
+ 'storage',
151
+ ]);
152
+ export const DatapackCategories = Object.freeze([
153
+ 'attribute_modifier_uuid',
113
154
  'objective',
114
155
  'score_holder',
115
- 'storage',
116
156
  'tag',
117
157
  'team',
118
- ]);
119
- export const DatapackCategories = Object.freeze([
120
158
  ...FileCategories,
121
159
  ...MiscCategories,
122
160
  ]);
123
161
  // #endregion
124
- export const AllCategories = Object.freeze([
125
- ...DatapackCategories,
126
- ...McdocCategories,
127
- ...RegistryCategories,
128
- ]);
162
+ export const AllCategories = Object.freeze([...DatapackCategories, ...McdocCategories, ...RegistryCategories]);
129
163
  export const ResourceLocationCategories = Object.freeze([
130
- 'bossbar',
131
- 'storage',
132
164
  'mcdoc/dispatcher',
165
+ ...MiscCategories,
133
166
  ...FileCategories,
134
167
  ...RegistryCategories,
135
168
  ]);
@@ -143,9 +176,7 @@ export var ResourceLocationCategory;
143
176
  export var SymbolPath;
144
177
  (function (SymbolPath) {
145
178
  function fromSymbol(symbol) {
146
- return symbol
147
- ? { category: symbol.category, path: symbol.path }
148
- : undefined;
179
+ return symbol ? { category: symbol.category, path: symbol.path } : undefined;
149
180
  }
150
181
  SymbolPath.fromSymbol = fromSymbol;
151
182
  /**
@@ -175,13 +206,7 @@ export class SymbolPathCollector {
175
206
  return [...this.#set].map(SymbolPath.fromString);
176
207
  }
177
208
  }
178
- export const SymbolUsageTypes = Object.freeze([
179
- 'definition',
180
- 'declaration',
181
- 'implementation',
182
- 'reference',
183
- 'typeDefinition',
184
- ]);
209
+ export const SymbolUsageTypes = Object.freeze(['definition', 'declaration', 'implementation', 'reference', 'typeDefinition']);
185
210
  export var SymbolUsageType;
186
211
  (function (SymbolUsageType) {
187
212
  function is(value) {
@@ -215,10 +240,7 @@ export var SymbolLocation;
215
240
  return {
216
241
  ...Location.create(doc, range),
217
242
  ...(fullRange
218
- ? {
219
- fullRange: Range.get(fullRange),
220
- fullPosRange: PositionRange.from(fullRange, doc),
221
- }
243
+ ? { fullRange: Range.get(fullRange), fullPosRange: PositionRange.from(fullRange, doc) }
222
244
  : {}),
223
245
  ...(contributor ? { contributor } : {}),
224
246
  ...(additional ? additional : {}),
@@ -249,10 +271,7 @@ export var SymbolTable;
249
271
  };
250
272
  const linkSymbolMap = (map, parentSymbol, category, path) => {
251
273
  for (const [identifier, childSymbol] of Object.entries(map)) {
252
- linkSymbol(childSymbol, map, parentSymbol, category, [
253
- ...path,
254
- identifier,
255
- ]);
274
+ linkSymbol(childSymbol, map, parentSymbol, category, [...path, identifier]);
256
275
  }
257
276
  };
258
277
  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;
@@ -275,14 +275,14 @@ type QueryMemberCallback = (this: void, query: SymbolQuery) => unknown;
275
275
  export declare class SymbolQuery {
276
276
  #private;
277
277
  readonly category: string;
278
- readonly path: readonly string[];
278
+ path: readonly string[];
279
279
  /**
280
280
  * The {@link SymbolUtil} where this query was created.
281
281
  */
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;
@@ -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;
@@ -37,19 +37,15 @@ export class SymbolUtil {
37
37
  this._inDelayMode = _inDelayMode;
38
38
  this.on('symbolCreated', ({ symbol }) => {
39
39
  this.#trimmableSymbols.add(SymbolPath.toString(symbol));
40
- })
41
- .on('symbolRemoved', ({ symbol }) => {
40
+ }).on('symbolRemoved', ({ symbol }) => {
42
41
  this.#trimmableSymbols.delete(SymbolPath.toString(symbol));
43
- })
44
- .on('symbolLocationCreated', ({ symbol, location }) => {
45
- const cache = (this.#cache[location.contributor ?? 'undefined'] ??= Object
46
- .create(null));
42
+ }).on('symbolLocationCreated', ({ symbol, location }) => {
43
+ const cache = (this.#cache[location.contributor ?? 'undefined'] ??= Object.create(null));
47
44
  const fileSymbols = (cache[location.uri] ??= new Set());
48
45
  const path = SymbolPath.toString(symbol);
49
46
  fileSymbols.add(path);
50
47
  this.#trimmableSymbols.delete(path);
51
- })
52
- .on('symbolLocationRemoved', ({ symbol }) => {
48
+ }).on('symbolLocationRemoved', ({ symbol }) => {
53
49
  const path = SymbolPath.toString(symbol);
54
50
  this.#trimmableSymbols.add(path);
55
51
  });
@@ -123,7 +119,7 @@ export class SymbolUtil {
123
119
  * - `uri` - clear symbol locations associated with this URI.
124
120
  * - `predicate` - clear symbol locations matching this predicate
125
121
  */
126
- clear({ uri, contributor, predicate = () => true, }) {
122
+ clear({ uri, contributor, predicate = () => true }) {
127
123
  const getCaches = () => {
128
124
  if (contributor) {
129
125
  return this.#cache[contributor] ? [this.#cache[contributor]] : [];
@@ -137,10 +133,7 @@ export class SymbolUtil {
137
133
  const sets = uri
138
134
  ? caches.map((cache) => cache[uri] ?? new Set())
139
135
  : caches.map((cache) => Object.values(cache)).flat();
140
- return sets
141
- .map((s) => [...s])
142
- .flat()
143
- .map(SymbolPath.fromString);
136
+ return sets.map((s) => [...s]).flat().map(SymbolPath.fromString);
144
137
  };
145
138
  const getTables = () => {
146
139
  return uri ? [this.#global] : [this.#global];
@@ -153,9 +146,9 @@ export class SymbolUtil {
153
146
  if (!symbol) {
154
147
  continue;
155
148
  }
156
- this.removeLocationsFromSymbol(symbol, uri
157
- ? (data) => data.location.uri === uri && predicate(data)
158
- : predicate);
149
+ this.removeLocationsFromSymbol(symbol, (data) => (!uri || data.location.uri === uri)
150
+ && (!contributor || data.location.contributor === contributor)
151
+ && predicate(data));
159
152
  }
160
153
  this.trim(table);
161
154
  }
@@ -181,7 +174,7 @@ export class SymbolUtil {
181
174
  doc,
182
175
  contributor: this.#currentContributor,
183
176
  map: visible ? parentMap : undefined,
184
- parentSymbol: parentSymbol,
177
+ parentSymbol,
185
178
  path,
186
179
  symbol: visible ? symbol : undefined,
187
180
  util: this,
@@ -278,9 +271,7 @@ export class SymbolUtil {
278
271
  if (result.symbol) {
279
272
  return result;
280
273
  }
281
- if (!parentSymbol &&
282
- !parentMap &&
283
- (result.parentSymbol || result.parentMap)) {
274
+ if (!parentSymbol && !parentMap && (result.parentSymbol || result.parentMap)) {
284
275
  parentSymbol = result.parentSymbol;
285
276
  parentMap = result.parentMap;
286
277
  }
@@ -324,12 +315,9 @@ export class SymbolUtil {
324
315
  if ('visibility' in addition) {
325
316
  // Visibility changes are only accepted if the change wouldn't result in the
326
317
  // symbol being stored in a different symbol table.
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))) {
318
+ const inGlobalTable = (v) => v === undefined || v === 2 /* SymbolVisibility.Public */ || v === 3 /* SymbolVisibility.Restricted */;
319
+ if (symbol.visibility === addition.visibility
320
+ || (inGlobalTable(symbol.visibility) && inGlobalTable(addition.visibility))) {
333
321
  symbol.visibility = addition.visibility;
334
322
  }
335
323
  else {
@@ -345,9 +333,7 @@ export class SymbolUtil {
345
333
  if (addition) {
346
334
  const type = addition.type ?? 'reference';
347
335
  const arr = (symbol[type] ??= []);
348
- const range = Range.get((SymbolAdditionUsageWithNode.is(addition)
349
- ? addition.node
350
- : addition.range) ?? 0);
336
+ const range = Range.get((SymbolAdditionUsageWithNode.is(addition) ? addition.node : addition.range) ?? 0);
351
337
  const location = SymbolLocation.create(doc, range, addition.fullRange, contributor, {
352
338
  accessType: addition.accessType,
353
339
  skipRenaming: addition.skipRenaming,
@@ -380,12 +366,12 @@ export class SymbolUtil {
380
366
  return ans;
381
367
  }
382
368
  static isTrimmable(symbol) {
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);
369
+ return (!Object.keys(symbol.members ?? {}).length
370
+ && !symbol.declaration?.length
371
+ && !symbol.definition?.length
372
+ && !symbol.implementation?.length
373
+ && !symbol.reference?.length
374
+ && !symbol.typeDefinition?.length);
389
375
  }
390
376
  static isVisible(symbol, _uri) {
391
377
  switch (symbol.visibility) {
@@ -408,8 +394,8 @@ export class SymbolUtil {
408
394
  * @returns If the symbol has definitions, or declarations and implementations.
409
395
  */
410
396
  static isDefined(symbol) {
411
- return !!(symbol?.definition?.length ||
412
- (symbol?.definition?.length && symbol?.implementation?.length));
397
+ return !!(symbol?.definition?.length
398
+ || (symbol?.definition?.length && symbol?.implementation?.length));
413
399
  }
414
400
  /**
415
401
  * @returns If the symbol has implementations or definitions.
@@ -433,11 +419,9 @@ export class SymbolUtil {
433
419
  * @throws If the symbol does not have any declarations or definitions.
434
420
  */
435
421
  static getDeclaredLocation(symbol) {
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
+ return (symbol.declaration?.[0] ?? symbol.definition?.[0] ?? (() => {
423
+ throw new Error(`Cannot get declared location of ${JSON.stringify(SymbolPath.fromSymbol(symbol))}`);
424
+ })());
441
425
  }
442
426
  static forEachSymbolInMap(map, fn) {
443
427
  for (const symbol of Object.values(map)) {
@@ -458,14 +442,12 @@ export class SymbolUtil {
458
442
  }
459
443
  }
460
444
  static isVisibilityInGlobal(v) {
461
- return (v === undefined ||
462
- v === 2 /* SymbolVisibility.Public */ ||
463
- v === 3 /* SymbolVisibility.Restricted */);
445
+ return (v === undefined || v === 2 /* SymbolVisibility.Public */ || v === 3 /* SymbolVisibility.Restricted */);
464
446
  }
465
447
  static areVisibilitiesCompatible(v1, v2) {
466
- return ((this.isVisibilityInGlobal(v1) && this.isVisibilityInGlobal(v2)) ||
467
- (v1 === 0 /* SymbolVisibility.Block */ && v2 === 0 /* SymbolVisibility.Block */) ||
468
- (v1 === 1 /* SymbolVisibility.File */ && v2 === 1 /* SymbolVisibility.File */));
448
+ return ((this.isVisibilityInGlobal(v1) && this.isVisibilityInGlobal(v2))
449
+ || (v1 === 0 /* SymbolVisibility.Block */ && v2 === 0 /* SymbolVisibility.Block */)
450
+ || (v1 === 1 /* SymbolVisibility.File */ && v2 === 1 /* SymbolVisibility.File */));
469
451
  }
470
452
  }
471
453
  __decorate([
@@ -526,7 +508,7 @@ export class SymbolQuery {
526
508
  get visibleMembers() {
527
509
  return SymbolUtil.filterVisibleSymbols(this.#doc.uri, this.path.length === 0 ? this.#map : this.#symbol?.members);
528
510
  }
529
- constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util, }) {
511
+ constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util }) {
530
512
  this.category = category;
531
513
  this.path = path;
532
514
  if (typeof doc === 'string') {
@@ -634,14 +616,12 @@ export class SymbolQuery {
634
616
  * * If the visibility is `undefined`, use the visibility of the symbol, or `Public` if unapplicable.
635
617
  */
636
618
  const getAdditionVisibility = (addition) => {
637
- return (addition.data?.visibility ??
638
- this.symbol?.visibility ??
639
- 2 /* SymbolVisibility.Public */);
619
+ return (addition.data?.visibility ?? this.symbol?.visibility ?? 2 /* SymbolVisibility.Public */);
640
620
  };
641
621
  const getMap = (addition) => {
642
622
  const additionVisibility = getAdditionVisibility(addition);
643
- if (this.#map &&
644
- SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#symbol?.visibility)) {
623
+ if (this.#map
624
+ && SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#symbol?.visibility)) {
645
625
  return this.#map;
646
626
  }
647
627
  if (this.path.length > 1) {
@@ -695,8 +675,7 @@ export class SymbolQuery {
695
675
  throw new Error(`Cannot create the symbol map for “${this.getPath()}”`);
696
676
  };
697
677
  // Treat `usage.range` as `[0, 0)` if this class was constructed with a string URI (instead of a `TextDocument`).
698
- if (this.#createdWithUri &&
699
- SymbolAdditionUsageWithRange.is(addition.usage)) {
678
+ if (this.#createdWithUri && SymbolAdditionUsageWithRange.is(addition.usage)) {
700
679
  addition.usage.range = Range.create(0, 0);
701
680
  }
702
681
  this.#map = getMap(addition);
@@ -743,6 +722,8 @@ export class SymbolQuery {
743
722
  }
744
723
  this.#symbol = result;
745
724
  this.#map = result.parentMap;
725
+ this.#parentSymbol = result.parentSymbol;
726
+ this.path = result.path;
746
727
  }
747
728
  return this;
748
729
  }
@@ -763,8 +744,7 @@ export class SymbolQuery {
763
744
  if (this.#symbol === undefined) {
764
745
  throw new Error(`Tried to query member symbol “${identifier}” from an undefined symbol (path “${this.path.join('.')}”)`);
765
746
  }
766
- const memberDoc = typeof doc === 'string' && doc === this.#doc.uri &&
767
- !this.#createdWithUri
747
+ const memberDoc = typeof doc === 'string' && doc === this.#doc.uri && !this.#createdWithUri
768
748
  ? this.#doc
769
749
  : doc;
770
750
  const memberMap = this.#symbol.members;
@@ -815,9 +795,7 @@ export var SymbolFormatter;
815
795
  }
816
796
  }
817
797
  function stringifySymbolStack(stack) {
818
- return stack
819
- .map((table) => stringifySymbolTable(table))
820
- .join('\n------------\n');
798
+ return stack.map((table) => stringifySymbolTable(table)).join('\n------------\n');
821
799
  }
822
800
  SymbolFormatter.stringifySymbolStack = stringifySymbolStack;
823
801
  function stringifySymbolTable(table, indent = '') {
@@ -826,9 +804,8 @@ export var SymbolFormatter;
826
804
  const map = table[category];
827
805
  ans.push([category, stringifySymbolMap(map, `${indent}${IndentChar}`)]);
828
806
  }
829
- return (ans
830
- .map((v) => `CATEGORY ${v[0]}\n${v[1]}`)
831
- .join(`\n${indent}------------\n`) || 'EMPTY TABLE');
807
+ return (ans.map((v) => `CATEGORY ${v[0]}\n${v[1]}`).join(`\n${indent}------------\n`)
808
+ || 'EMPTY TABLE');
832
809
  }
833
810
  SymbolFormatter.stringifySymbolTable = stringifySymbolTable;
834
811
  function stringifySymbolMap(map, indent = '') {
@@ -850,9 +827,9 @@ export var SymbolFormatter;
850
827
  }
851
828
  const ans = [];
852
829
  assertEqual(symbol.path[symbol.path.length - 1], symbol.identifier);
853
- ans.push(`SYMBOL ${symbol.path.join('.')}` +
854
- ` {${symbol.category}${symbol.subcategory ? ` (${symbol.subcategory})` : ''}}` +
855
- ` [${stringifyVisibility(symbol.visibility, symbol.visibilityRestriction)}]`);
830
+ ans.push(`SYMBOL ${symbol.path.join('.')}`
831
+ + ` {${symbol.category}${symbol.subcategory ? ` (${symbol.subcategory})` : ''}}`
832
+ + ` [${stringifyVisibility(symbol.visibility, symbol.visibilityRestriction)}]`);
856
833
  if (symbol.data) {
857
834
  ans.push(`${IndentChar}data: ${JSON.stringify(symbol.data)}`);
858
835
  }
@@ -861,7 +838,8 @@ export var SymbolFormatter;
861
838
  }
862
839
  for (const type of SymbolUsageTypes) {
863
840
  if (symbol[type]) {
864
- ans.push(`${IndentChar}${type}:\n${symbol[type].map((v) => `${indent}${IndentChar.repeat(2)}${JSON.stringify(v)}`).join(`\n${indent}${IndentChar.repeat(2)}------------\n`)}`);
841
+ ans.push(`${IndentChar}${type}:\n${symbol[type].map((v) => `${indent}${IndentChar.repeat(2)}${JSON.stringify(v)}`)
842
+ .join(`\n${indent}${IndentChar.repeat(2)}------------\n`)}`);
865
843
  }
866
844
  }
867
845
  if (symbol.relations) {
@@ -890,9 +868,7 @@ export var SymbolFormatter;
890
868
  stringVisibility = 'Public';
891
869
  break;
892
870
  }
893
- return `${stringVisibility}${visibilityRestriction
894
- ? ` ${visibilityRestriction.map((v) => `“${v}”`).join(', ')}`
895
- : ''}`;
871
+ return `${stringVisibility}${visibilityRestriction ? ` ${visibilityRestriction.map((v) => `“${v}”`).join(', ')}` : ''}`;
896
872
  }
897
873
  SymbolFormatter.stringifyVisibility = stringifyVisibility;
898
874
  function stringifyLookupResult(result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/core",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -20,11 +20,12 @@
20
20
  "decompress": "^4.2.1",
21
21
  "follow-redirects": "^1.14.8",
22
22
  "globby": "^11.0.4",
23
+ "ignore": "^5.3.1",
23
24
  "pako": "^2.0.4",
24
25
  "rfdc": "^1.3.0",
25
26
  "vscode-languageserver-textdocument": "^1.0.4",
26
27
  "whatwg-url": "^14.0.0",
27
- "@spyglassmc/locales": "0.3.5"
28
+ "@spyglassmc/locales": "0.3.6"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/decompress": "^4.2.3",