@spyglassmc/core 0.1.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/README.md +10 -0
- package/lib/common/Heap.d.ts +1 -0
- package/lib/common/Heap.js +2 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +14 -0
- package/lib/common/util.d.ts +120 -0
- package/lib/common/util.js +292 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +20 -0
- package/lib/node/AstNode.d.ts +64 -0
- package/lib/node/AstNode.js +108 -0
- package/lib/node/BooleanNode.d.ts +13 -0
- package/lib/node/BooleanNode.js +20 -0
- package/lib/node/CommentNode.d.ts +12 -0
- package/lib/node/CommentNode.js +11 -0
- package/lib/node/ErrorNode.d.ts +8 -0
- package/lib/node/ErrorNode.js +12 -0
- package/lib/node/FileNode.d.ts +21 -0
- package/lib/node/FileNode.js +11 -0
- package/lib/node/FloatNode.d.ts +13 -0
- package/lib/node/FloatNode.js +21 -0
- package/lib/node/IntegerNode.d.ts +13 -0
- package/lib/node/IntegerNode.js +20 -0
- package/lib/node/ListNode.d.ts +15 -0
- package/lib/node/ListNode.js +11 -0
- package/lib/node/LiteralNode.d.ts +19 -0
- package/lib/node/LiteralNode.js +22 -0
- package/lib/node/LongNode.d.ts +13 -0
- package/lib/node/LongNode.js +20 -0
- package/lib/node/RecordNode.d.ts +20 -0
- package/lib/node/RecordNode.js +11 -0
- package/lib/node/ResourceLocationNode.d.ts +41 -0
- package/lib/node/ResourceLocationNode.js +65 -0
- package/lib/node/Sequence.d.ts +22 -0
- package/lib/node/Sequence.js +11 -0
- package/lib/node/StringNode.d.ts +63 -0
- package/lib/node/StringNode.js +43 -0
- package/lib/node/SymbolNode.d.ts +21 -0
- package/lib/node/SymbolNode.js +22 -0
- package/lib/node/TableNode.d.ts +17 -0
- package/lib/node/TableNode.js +11 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.js +28 -0
- package/lib/parser/Parser.d.ts +16 -0
- package/lib/parser/Parser.js +5 -0
- package/lib/parser/boolean.d.ts +4 -0
- package/lib/parser/boolean.js +11 -0
- package/lib/parser/comment.d.ts +12 -0
- package/lib/parser/comment.js +34 -0
- package/lib/parser/empty.d.ts +3 -0
- package/lib/parser/empty.js +7 -0
- package/lib/parser/error.d.ts +8 -0
- package/lib/parser/error.js +22 -0
- package/lib/parser/file.d.ts +9 -0
- package/lib/parser/file.js +37 -0
- package/lib/parser/float.d.ts +33 -0
- package/lib/parser/float.js +57 -0
- package/lib/parser/index.d.ts +17 -0
- package/lib/parser/index.js +36 -0
- package/lib/parser/integer.d.ts +33 -0
- package/lib/parser/integer.js +46 -0
- package/lib/parser/list.d.ts +12 -0
- package/lib/parser/list.js +70 -0
- package/lib/parser/literal.d.ts +5 -0
- package/lib/parser/literal.js +41 -0
- package/lib/parser/long.d.ts +33 -0
- package/lib/parser/long.js +50 -0
- package/lib/parser/record.d.ts +22 -0
- package/lib/parser/record.js +97 -0
- package/lib/parser/resourceLocation.d.ts +4 -0
- package/lib/parser/resourceLocation.js +67 -0
- package/lib/parser/string.d.ts +18 -0
- package/lib/parser/string.js +129 -0
- package/lib/parser/symbol.d.ts +12 -0
- package/lib/parser/symbol.js +33 -0
- package/lib/parser/table.d.ts +22 -0
- package/lib/parser/table.js +97 -0
- package/lib/parser/util.d.ts +134 -0
- package/lib/parser/util.js +224 -0
- package/lib/processor/ColorInfoProvider.d.ts +87 -0
- package/lib/processor/ColorInfoProvider.js +141 -0
- package/lib/processor/InlayHintProvider.d.ts +8 -0
- package/lib/processor/InlayHintProvider.js +3 -0
- package/lib/processor/SignatureHelpProvider.d.ts +18 -0
- package/lib/processor/SignatureHelpProvider.js +3 -0
- package/lib/processor/checker/Checker.d.ts +7 -0
- package/lib/processor/checker/Checker.js +7 -0
- package/lib/processor/checker/builtin.d.ts +23 -0
- package/lib/processor/checker/builtin.js +83 -0
- package/lib/processor/checker/index.d.ts +3 -0
- package/lib/processor/checker/index.js +28 -0
- package/lib/processor/colorizer/Colorizer.d.ts +23 -0
- package/lib/processor/colorizer/Colorizer.js +70 -0
- package/lib/processor/colorizer/builtin.d.ts +17 -0
- package/lib/processor/colorizer/builtin.js +84 -0
- package/lib/processor/colorizer/index.d.ts +3 -0
- package/lib/processor/colorizer/index.js +28 -0
- package/lib/processor/completer/Completer.d.ts +75 -0
- package/lib/processor/completer/Completer.js +92 -0
- package/lib/processor/completer/builtin.d.ts +30 -0
- package/lib/processor/completer/builtin.js +172 -0
- package/lib/processor/completer/index.d.ts +3 -0
- package/lib/processor/completer/index.js +28 -0
- package/lib/processor/formatter/Formatter.d.ts +6 -0
- package/lib/processor/formatter/Formatter.js +19 -0
- package/lib/processor/formatter/builtin.d.ts +15 -0
- package/lib/processor/formatter/builtin.js +60 -0
- package/lib/processor/formatter/index.d.ts +3 -0
- package/lib/processor/formatter/index.js +28 -0
- package/lib/processor/index.d.ts +10 -0
- package/lib/processor/index.js +22 -0
- package/lib/processor/linter/Linter.d.ts +4 -0
- package/lib/processor/linter/Linter.js +3 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
- package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
- package/lib/processor/linter/builtin.d.ts +15 -0
- package/lib/processor/linter/builtin.js +120 -0
- package/lib/processor/linter/index.d.ts +3 -0
- package/lib/processor/linter/index.js +28 -0
- package/lib/processor/util.d.ts +17 -0
- package/lib/processor/util.js +32 -0
- package/lib/service/CacheService.d.ts +54 -0
- package/lib/service/CacheService.js +195 -0
- package/lib/service/CommandExecutor.d.ts +3 -0
- package/lib/service/CommandExecutor.js +7 -0
- package/lib/service/Config.d.ts +218 -0
- package/lib/service/Config.js +264 -0
- package/lib/service/Context.d.ts +143 -0
- package/lib/service/Context.js +143 -0
- package/lib/service/Dependency.d.ts +10 -0
- package/lib/service/Dependency.js +11 -0
- package/lib/service/Downloader.d.ts +67 -0
- package/lib/service/Downloader.js +185 -0
- package/lib/service/ErrorReporter.d.ts +27 -0
- package/lib/service/ErrorReporter.js +49 -0
- package/lib/service/FileService.d.ts +96 -0
- package/lib/service/FileService.js +224 -0
- package/lib/service/Hover.d.ts +10 -0
- package/lib/service/Hover.js +16 -0
- package/lib/service/Logger.d.ts +31 -0
- package/lib/service/Logger.js +30 -0
- package/lib/service/MetaRegistry.d.ts +106 -0
- package/lib/service/MetaRegistry.js +192 -0
- package/lib/service/Operations.d.ts +8 -0
- package/lib/service/Operations.js +26 -0
- package/lib/service/Profiler.d.ts +33 -0
- package/lib/service/Profiler.js +76 -0
- package/lib/service/Project.d.ts +173 -0
- package/lib/service/Project.js +593 -0
- package/lib/service/Service.d.ts +55 -0
- package/lib/service/Service.js +207 -0
- package/lib/service/SymbolLocations.d.ts +17 -0
- package/lib/service/SymbolLocations.js +16 -0
- package/lib/service/SymbolRegistrar.d.ts +5 -0
- package/lib/service/SymbolRegistrar.js +3 -0
- package/lib/service/fileUtil.d.ts +121 -0
- package/lib/service/fileUtil.js +268 -0
- package/lib/service/index.d.ts +18 -0
- package/lib/service/index.js +33 -0
- package/lib/source/IndexMap.d.ts +16 -0
- package/lib/source/IndexMap.js +46 -0
- package/lib/source/LanguageError.d.ts +27 -0
- package/lib/source/LanguageError.js +15 -0
- package/lib/source/Location.d.ts +19 -0
- package/lib/source/Location.js +25 -0
- package/lib/source/Offset.d.ts +13 -0
- package/lib/source/Offset.js +25 -0
- package/lib/source/Position.d.ts +23 -0
- package/lib/source/Position.js +43 -0
- package/lib/source/PositionRange.d.ts +38 -0
- package/lib/source/PositionRange.js +83 -0
- package/lib/source/Range.d.ts +68 -0
- package/lib/source/Range.js +155 -0
- package/lib/source/Source.d.ts +110 -0
- package/lib/source/Source.js +222 -0
- package/lib/source/index.d.ts +9 -0
- package/lib/source/index.js +21 -0
- package/lib/symbol/Symbol.d.ts +219 -0
- package/lib/symbol/Symbol.js +324 -0
- package/lib/symbol/SymbolUtil.d.ts +407 -0
- package/lib/symbol/SymbolUtil.js +880 -0
- package/lib/symbol/UriBinder.d.ts +3 -0
- package/lib/symbol/UriBinder.js +3 -0
- package/lib/symbol/index.d.ts +4 -0
- package/lib/symbol/index.js +16 -0
- package/package.json +41 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
var _SymbolPathCollector_set;
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SymbolTable = exports.SymbolLocation = exports.Symbol = exports.SymbolUsageType = exports.SymbolUsageTypes = exports.SymbolPathCollector = exports.SymbolPath = exports.ResourceLocationCategory = exports.ResourceLocationCategories = exports.AllCategories = exports.DatapackCategories = exports.MiscCategories = exports.FileCategories = exports.TagFileCategories = exports.TaggableResourceLocationCategories = exports.WorldgenFileCategories = exports.RegistryCategories = exports.NbtdocCategories = void 0;
|
|
13
|
+
const rfdc_1 = __importDefault(require("rfdc"));
|
|
14
|
+
const common_1 = require("../common");
|
|
15
|
+
const source_1 = require("../source");
|
|
16
|
+
//#region NBTDoc Categories
|
|
17
|
+
exports.NbtdocCategories = Object.freeze([
|
|
18
|
+
'nbtdoc',
|
|
19
|
+
'nbtdoc/description',
|
|
20
|
+
]);
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region Registry Categories
|
|
23
|
+
// Data in `java-edition/src/binder/index.ts` may need to be updated when this section is changed.
|
|
24
|
+
exports.RegistryCategories = Object.freeze([
|
|
25
|
+
'activity',
|
|
26
|
+
'attribute',
|
|
27
|
+
'block',
|
|
28
|
+
'block_entity_type',
|
|
29
|
+
'block_predicate_type',
|
|
30
|
+
'chunk_status',
|
|
31
|
+
'custom_stat',
|
|
32
|
+
'enchantment',
|
|
33
|
+
'entity_type',
|
|
34
|
+
'float_provider_type',
|
|
35
|
+
'fluid',
|
|
36
|
+
'game_event',
|
|
37
|
+
'height_provider_type',
|
|
38
|
+
'int_provider_type',
|
|
39
|
+
'item',
|
|
40
|
+
'loot_condition_type',
|
|
41
|
+
'loot_function_type',
|
|
42
|
+
'loot_nbt_provider_type',
|
|
43
|
+
'loot_number_provider_type',
|
|
44
|
+
'loot_pool_entry_type',
|
|
45
|
+
'loot_score_provider_type',
|
|
46
|
+
'memory_module_type',
|
|
47
|
+
'menu',
|
|
48
|
+
'mob_effect',
|
|
49
|
+
'motive',
|
|
50
|
+
'particle_type',
|
|
51
|
+
'point_of_interest_type',
|
|
52
|
+
'pos_rule_test',
|
|
53
|
+
'position_source_type',
|
|
54
|
+
'potion',
|
|
55
|
+
'recipe_serializer',
|
|
56
|
+
'recipe_type',
|
|
57
|
+
'rule_test',
|
|
58
|
+
'schedule',
|
|
59
|
+
'sensor_type',
|
|
60
|
+
'sound_event',
|
|
61
|
+
'stat_type',
|
|
62
|
+
'villager_profession',
|
|
63
|
+
'villager_type',
|
|
64
|
+
'worldgen/biome_source',
|
|
65
|
+
'worldgen/block_placer_type',
|
|
66
|
+
'worldgen/block_state_provider_type',
|
|
67
|
+
'worldgen/carver',
|
|
68
|
+
'worldgen/chunk_generator',
|
|
69
|
+
'worldgen/decorator',
|
|
70
|
+
'worldgen/feature',
|
|
71
|
+
'worldgen/feature_size_type',
|
|
72
|
+
'worldgen/foliage_placer_type',
|
|
73
|
+
'worldgen/material_condition',
|
|
74
|
+
'worldgen/material_rule',
|
|
75
|
+
'worldgen/placement_modifier_type',
|
|
76
|
+
'worldgen/structure_feature',
|
|
77
|
+
'worldgen/structure_piece',
|
|
78
|
+
'worldgen/structure_pool_element',
|
|
79
|
+
'worldgen/structure_processor',
|
|
80
|
+
'worldgen/surface_builder',
|
|
81
|
+
'worldgen/tree_decorator_type',
|
|
82
|
+
'worldgen/trunk_placer_type',
|
|
83
|
+
]);
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region Data Pack Categories
|
|
86
|
+
exports.WorldgenFileCategories = Object.freeze([
|
|
87
|
+
'worldgen/biome',
|
|
88
|
+
'worldgen/configured_carver',
|
|
89
|
+
'worldgen/configured_feature',
|
|
90
|
+
'worldgen/configured_structure_feature',
|
|
91
|
+
'worldgen/configured_surface_builder',
|
|
92
|
+
'worldgen/noise',
|
|
93
|
+
'worldgen/noise_settings',
|
|
94
|
+
'worldgen/placed_feature',
|
|
95
|
+
'worldgen/processor_list',
|
|
96
|
+
'worldgen/template_pool',
|
|
97
|
+
]);
|
|
98
|
+
exports.TaggableResourceLocationCategories = Object.freeze([
|
|
99
|
+
'function',
|
|
100
|
+
...exports.RegistryCategories,
|
|
101
|
+
...exports.WorldgenFileCategories,
|
|
102
|
+
]);
|
|
103
|
+
exports.TagFileCategories = Object.freeze(exports.TaggableResourceLocationCategories.map(key => `tag/${key}`));
|
|
104
|
+
exports.FileCategories = Object.freeze([
|
|
105
|
+
'advancement',
|
|
106
|
+
'dimension',
|
|
107
|
+
'dimension_type',
|
|
108
|
+
'function',
|
|
109
|
+
'item_modifier',
|
|
110
|
+
'loot_table',
|
|
111
|
+
'predicate',
|
|
112
|
+
'recipe',
|
|
113
|
+
'structure',
|
|
114
|
+
...exports.TagFileCategories,
|
|
115
|
+
...exports.WorldgenFileCategories,
|
|
116
|
+
]);
|
|
117
|
+
exports.MiscCategories = Object.freeze([
|
|
118
|
+
'attribute_modifier_uuid',
|
|
119
|
+
'bossbar',
|
|
120
|
+
'objective',
|
|
121
|
+
'score_holder',
|
|
122
|
+
'storage',
|
|
123
|
+
'tag',
|
|
124
|
+
'team',
|
|
125
|
+
]);
|
|
126
|
+
exports.DatapackCategories = Object.freeze([
|
|
127
|
+
...exports.FileCategories,
|
|
128
|
+
...exports.MiscCategories,
|
|
129
|
+
]);
|
|
130
|
+
//#endregion
|
|
131
|
+
exports.AllCategories = Object.freeze([
|
|
132
|
+
...exports.DatapackCategories,
|
|
133
|
+
...exports.NbtdocCategories,
|
|
134
|
+
...exports.RegistryCategories,
|
|
135
|
+
]);
|
|
136
|
+
exports.ResourceLocationCategories = Object.freeze([
|
|
137
|
+
'bossbar',
|
|
138
|
+
'storage',
|
|
139
|
+
...exports.FileCategories,
|
|
140
|
+
...exports.RegistryCategories,
|
|
141
|
+
]);
|
|
142
|
+
var ResourceLocationCategory;
|
|
143
|
+
(function (ResourceLocationCategory) {
|
|
144
|
+
function is(category) {
|
|
145
|
+
return exports.ResourceLocationCategories.includes(category);
|
|
146
|
+
}
|
|
147
|
+
ResourceLocationCategory.is = is;
|
|
148
|
+
})(ResourceLocationCategory = exports.ResourceLocationCategory || (exports.ResourceLocationCategory = {}));
|
|
149
|
+
var SymbolPath;
|
|
150
|
+
(function (SymbolPath) {
|
|
151
|
+
function fromSymbol(symbol) {
|
|
152
|
+
return symbol
|
|
153
|
+
? { category: symbol.category, path: symbol.path }
|
|
154
|
+
: undefined;
|
|
155
|
+
}
|
|
156
|
+
SymbolPath.fromSymbol = fromSymbol;
|
|
157
|
+
/**
|
|
158
|
+
* Equivalent {@link SymbolPath}s will always be serialized into the same string value.
|
|
159
|
+
*/
|
|
160
|
+
function toString(path) {
|
|
161
|
+
return JSON.stringify({ category: path.category, path: path.path });
|
|
162
|
+
}
|
|
163
|
+
SymbolPath.toString = toString;
|
|
164
|
+
function fromString(value) {
|
|
165
|
+
return JSON.parse(value);
|
|
166
|
+
}
|
|
167
|
+
SymbolPath.fromString = fromString;
|
|
168
|
+
})(SymbolPath = exports.SymbolPath || (exports.SymbolPath = {}));
|
|
169
|
+
class SymbolPathCollector {
|
|
170
|
+
constructor() {
|
|
171
|
+
_SymbolPathCollector_set.set(this, new Set());
|
|
172
|
+
}
|
|
173
|
+
add(path) {
|
|
174
|
+
if (!path) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
__classPrivateFieldGet(this, _SymbolPathCollector_set, "f").add(SymbolPath.toString(path));
|
|
178
|
+
}
|
|
179
|
+
has(path) {
|
|
180
|
+
return __classPrivateFieldGet(this, _SymbolPathCollector_set, "f").has(SymbolPath.toString(path));
|
|
181
|
+
}
|
|
182
|
+
collect() {
|
|
183
|
+
return [...__classPrivateFieldGet(this, _SymbolPathCollector_set, "f")].map(SymbolPath.fromString);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.SymbolPathCollector = SymbolPathCollector;
|
|
187
|
+
_SymbolPathCollector_set = new WeakMap();
|
|
188
|
+
exports.SymbolUsageTypes = Object.freeze(['definition', 'declaration', 'implementation', 'reference', 'typeDefinition']);
|
|
189
|
+
var SymbolUsageType;
|
|
190
|
+
(function (SymbolUsageType) {
|
|
191
|
+
function is(value) {
|
|
192
|
+
return exports.SymbolUsageTypes.includes(value);
|
|
193
|
+
}
|
|
194
|
+
SymbolUsageType.is = is;
|
|
195
|
+
})(SymbolUsageType = exports.SymbolUsageType || (exports.SymbolUsageType = {}));
|
|
196
|
+
var Symbol;
|
|
197
|
+
(function (Symbol) {
|
|
198
|
+
function get(table, category, ...path) {
|
|
199
|
+
if ((0, common_1.isIterable)(table)) {
|
|
200
|
+
for (const t of table) {
|
|
201
|
+
const result = get(t, category, ...path);
|
|
202
|
+
if (result) {
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
const map = table[category];
|
|
209
|
+
for (const p of path) {
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
Symbol.get = get;
|
|
214
|
+
})(Symbol = exports.Symbol || (exports.Symbol = {}));
|
|
215
|
+
var SymbolLocation;
|
|
216
|
+
(function (SymbolLocation) {
|
|
217
|
+
/* istanbul ignore next */
|
|
218
|
+
function create(doc, range, fullRange, contributor, additional) {
|
|
219
|
+
return {
|
|
220
|
+
...source_1.Location.create(doc, range),
|
|
221
|
+
...fullRange ? { fullRange: source_1.Range.get(fullRange), fullPosRange: source_1.PositionRange.from(fullRange, doc) } : {},
|
|
222
|
+
...contributor ? { contributor } : {},
|
|
223
|
+
...additional ? additional : {},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
SymbolLocation.create = create;
|
|
227
|
+
})(SymbolLocation = exports.SymbolLocation || (exports.SymbolLocation = {}));
|
|
228
|
+
var SymbolTable;
|
|
229
|
+
(function (SymbolTable) {
|
|
230
|
+
/**
|
|
231
|
+
* The passed-in parameter `table` won't be mutated.
|
|
232
|
+
*
|
|
233
|
+
* @returns An identical symbol table where each Symbol's `parentMap` and `parentSymbol` properties
|
|
234
|
+
* are set properly.
|
|
235
|
+
*/
|
|
236
|
+
function link(table) {
|
|
237
|
+
const linkSymbol = (symbol, parentMap, parentSymbol, category, path) => {
|
|
238
|
+
symbol.category = category;
|
|
239
|
+
symbol.identifier = path[path.length - 1];
|
|
240
|
+
symbol.path = path;
|
|
241
|
+
symbol.parentMap = parentMap;
|
|
242
|
+
if (parentSymbol) {
|
|
243
|
+
symbol.parentSymbol = parentSymbol;
|
|
244
|
+
}
|
|
245
|
+
if (symbol.members) {
|
|
246
|
+
linkSymbolMap(symbol.members, symbol, category, path);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const linkSymbolMap = (map, parentSymbol, category, path) => {
|
|
250
|
+
for (const [identifier, childSymbol] of Object.entries(map)) {
|
|
251
|
+
linkSymbol(childSymbol, map, parentSymbol, category, [...path, identifier]);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const ans = (0, rfdc_1.default)()(table);
|
|
255
|
+
for (const [category, map] of Object.entries(ans)) {
|
|
256
|
+
linkSymbolMap(map, undefined, category, []);
|
|
257
|
+
}
|
|
258
|
+
return ans;
|
|
259
|
+
}
|
|
260
|
+
SymbolTable.link = link;
|
|
261
|
+
/**
|
|
262
|
+
* The passed-in parameter `table` won't be mutated.
|
|
263
|
+
*
|
|
264
|
+
* @returns An identical symbol table where each Symbol's `parentMap` and `parentSymbol` properties
|
|
265
|
+
* are deleted.
|
|
266
|
+
*/
|
|
267
|
+
function unlink(table) {
|
|
268
|
+
const unlinkSymbol = (symbol) => {
|
|
269
|
+
delete symbol.category;
|
|
270
|
+
delete symbol.identifier;
|
|
271
|
+
delete symbol.parentMap;
|
|
272
|
+
delete symbol.parentSymbol;
|
|
273
|
+
delete symbol.path;
|
|
274
|
+
if (symbol.members) {
|
|
275
|
+
unlinkSymbolMap(symbol.members);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const unlinkSymbolMap = (map) => {
|
|
279
|
+
for (const childSymbol of Object.values(map)) {
|
|
280
|
+
unlinkSymbol(childSymbol);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const ans = (0, rfdc_1.default)({ circles: true })(table);
|
|
284
|
+
for (const map of Object.values(ans)) {
|
|
285
|
+
unlinkSymbolMap(map);
|
|
286
|
+
}
|
|
287
|
+
return ans;
|
|
288
|
+
}
|
|
289
|
+
SymbolTable.unlink = unlink;
|
|
290
|
+
/**
|
|
291
|
+
* @returns A serialized string representation of this symbol table. It can be turned back into
|
|
292
|
+
* a symbol table through the {@link deserialize} method.
|
|
293
|
+
*/
|
|
294
|
+
function serialize(table) {
|
|
295
|
+
return JSON.stringify(unlink(table));
|
|
296
|
+
}
|
|
297
|
+
SymbolTable.serialize = serialize;
|
|
298
|
+
/**
|
|
299
|
+
* @returns The symbol table represented by the string returned by the {@link serialize} method.
|
|
300
|
+
*/
|
|
301
|
+
function deserialize(json) {
|
|
302
|
+
return link(JSON.parse(json));
|
|
303
|
+
}
|
|
304
|
+
SymbolTable.deserialize = deserialize;
|
|
305
|
+
})(SymbolTable = exports.SymbolTable || (exports.SymbolTable = {}));
|
|
306
|
+
// interface SymbolEvent {
|
|
307
|
+
// symbol: Symbol,
|
|
308
|
+
// }
|
|
309
|
+
// interface SymbolLocationEvent extends SymbolEvent {
|
|
310
|
+
// type: SymbolUsageType,
|
|
311
|
+
// location: SymbolLocation,
|
|
312
|
+
// }
|
|
313
|
+
// export class CachedSymbolTable extends TypedEmitter<{
|
|
314
|
+
// symbolCreated: (e: SymbolEvent) => unknown,
|
|
315
|
+
// symbolAmended: (e: SymbolEvent) => unknown,
|
|
316
|
+
// symbolRemoved: (e: SymbolEvent) => unknown,
|
|
317
|
+
// symbolLocationCreated: (e: SymbolLocationEvent) => unknown,
|
|
318
|
+
// symbolLocationRemoved: (e: SymbolLocationEvent) => unknown,
|
|
319
|
+
// }> {
|
|
320
|
+
// constructor(public readonly table: SymbolTable) {
|
|
321
|
+
// super()
|
|
322
|
+
// }
|
|
323
|
+
// }
|
|
324
|
+
//# sourceMappingURL=Symbol.js.map
|