@spyglassmc/core 0.1.1 → 0.3.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.
Files changed (206) hide show
  1. package/README.md +7 -0
  2. package/lib/browser.d.ts +2 -0
  3. package/lib/browser.js +2 -0
  4. package/lib/common/Dev.d.ts +11 -0
  5. package/lib/common/Dev.js +90 -0
  6. package/lib/{service → common}/Logger.d.ts +0 -0
  7. package/lib/{service → common}/Logger.js +2 -5
  8. package/lib/common/Operations.d.ts +12 -0
  9. package/lib/common/Operations.js +33 -0
  10. package/lib/common/ReadonlyProxy.d.ts +9 -0
  11. package/lib/common/ReadonlyProxy.js +23 -0
  12. package/lib/common/StateProxy.d.ts +35 -0
  13. package/lib/common/StateProxy.js +69 -0
  14. package/lib/common/TwoWayMap.d.ts +21 -0
  15. package/lib/common/TwoWayMap.js +69 -0
  16. package/lib/common/externals/BrowserExternals.d.ts +3 -0
  17. package/lib/common/externals/BrowserExternals.js +191 -0
  18. package/lib/common/externals/NodeJsExternals.d.ts +3 -0
  19. package/lib/common/externals/NodeJsExternals.js +152 -0
  20. package/lib/common/externals/downloader.d.ts +31 -0
  21. package/lib/common/externals/downloader.js +32 -0
  22. package/lib/common/externals/index.d.ts +96 -0
  23. package/lib/common/externals/index.js +2 -0
  24. package/lib/common/index.d.ts +8 -1
  25. package/lib/common/index.js +8 -13
  26. package/lib/common/util.d.ts +50 -39
  27. package/lib/common/util.js +73 -122
  28. package/lib/index.d.ts +7 -7
  29. package/lib/index.js +7 -19
  30. package/lib/node/AstNode.d.ts +12 -11
  31. package/lib/node/AstNode.js +10 -16
  32. package/lib/node/BooleanNode.d.ts +2 -2
  33. package/lib/node/BooleanNode.js +4 -7
  34. package/lib/node/CommentNode.d.ts +6 -5
  35. package/lib/node/CommentNode.js +4 -9
  36. package/lib/node/ErrorNode.d.ts +1 -1
  37. package/lib/node/ErrorNode.js +2 -5
  38. package/lib/node/FileNode.d.ts +8 -4
  39. package/lib/node/FileNode.js +3 -6
  40. package/lib/node/FloatNode.d.ts +3 -3
  41. package/lib/node/FloatNode.js +4 -7
  42. package/lib/node/IntegerNode.d.ts +3 -3
  43. package/lib/node/IntegerNode.js +4 -7
  44. package/lib/node/ListNode.d.ts +2 -2
  45. package/lib/node/ListNode.js +2 -5
  46. package/lib/node/LiteralNode.d.ts +5 -5
  47. package/lib/node/LiteralNode.js +5 -8
  48. package/lib/node/LongNode.d.ts +3 -3
  49. package/lib/node/LongNode.js +4 -7
  50. package/lib/node/RecordNode.d.ts +2 -2
  51. package/lib/node/RecordNode.js +2 -5
  52. package/lib/node/ResourceLocationNode.d.ts +8 -10
  53. package/lib/node/ResourceLocationNode.js +9 -12
  54. package/lib/node/Sequence.d.ts +4 -3
  55. package/lib/node/Sequence.js +4 -6
  56. package/lib/node/StringNode.d.ts +5 -5
  57. package/lib/node/StringNode.js +9 -12
  58. package/lib/node/SymbolNode.d.ts +5 -5
  59. package/lib/node/SymbolNode.js +5 -8
  60. package/lib/node/index.d.ts +15 -15
  61. package/lib/node/index.js +15 -27
  62. package/lib/nodejs.d.ts +2 -0
  63. package/lib/nodejs.js +2 -0
  64. package/lib/parser/Parser.d.ts +3 -3
  65. package/lib/parser/Parser.js +1 -4
  66. package/lib/parser/boolean.d.ts +2 -2
  67. package/lib/parser/boolean.js +3 -6
  68. package/lib/parser/comment.d.ts +2 -2
  69. package/lib/parser/comment.js +5 -9
  70. package/lib/parser/empty.d.ts +1 -1
  71. package/lib/parser/empty.js +1 -5
  72. package/lib/parser/error.d.ts +2 -2
  73. package/lib/parser/error.js +5 -9
  74. package/lib/parser/file.d.ts +3 -3
  75. package/lib/parser/file.js +9 -13
  76. package/lib/parser/float.d.ts +4 -4
  77. package/lib/parser/float.js +12 -16
  78. package/lib/parser/index.d.ts +16 -16
  79. package/lib/parser/index.js +16 -34
  80. package/lib/parser/integer.d.ts +4 -4
  81. package/lib/parser/integer.js +10 -14
  82. package/lib/parser/list.d.ts +2 -2
  83. package/lib/parser/list.js +15 -19
  84. package/lib/parser/literal.d.ts +2 -2
  85. package/lib/parser/literal.js +5 -9
  86. package/lib/parser/long.d.ts +4 -4
  87. package/lib/parser/long.js +10 -14
  88. package/lib/parser/record.d.ts +3 -3
  89. package/lib/parser/record.js +20 -24
  90. package/lib/parser/resourceLocation.d.ts +2 -2
  91. package/lib/parser/resourceLocation.js +12 -24
  92. package/lib/parser/string.d.ts +7 -7
  93. package/lib/parser/string.js +40 -44
  94. package/lib/parser/symbol.d.ts +3 -3
  95. package/lib/parser/symbol.js +4 -14
  96. package/lib/parser/util.d.ts +30 -12
  97. package/lib/parser/util.js +78 -65
  98. package/lib/processor/ColorInfoProvider.d.ts +1 -1
  99. package/lib/processor/ColorInfoProvider.js +6 -9
  100. package/lib/processor/InlayHintProvider.d.ts +4 -3
  101. package/lib/processor/InlayHintProvider.js +1 -2
  102. package/lib/processor/SignatureHelpProvider.d.ts +4 -3
  103. package/lib/processor/SignatureHelpProvider.js +1 -2
  104. package/lib/processor/binder/Binder.d.ts +26 -0
  105. package/lib/processor/binder/Binder.js +18 -0
  106. package/lib/processor/binder/builtin.d.ts +27 -0
  107. package/lib/processor/binder/builtin.js +116 -0
  108. package/lib/processor/binder/index.d.ts +3 -0
  109. package/lib/processor/binder/index.js +3 -0
  110. package/lib/processor/checker/Checker.d.ts +2 -2
  111. package/lib/processor/checker/Checker.js +1 -5
  112. package/lib/processor/checker/builtin.d.ts +4 -4
  113. package/lib/processor/checker/builtin.js +22 -33
  114. package/lib/processor/checker/index.d.ts +2 -2
  115. package/lib/processor/checker/index.js +2 -27
  116. package/lib/processor/colorizer/Colorizer.d.ts +6 -5
  117. package/lib/processor/colorizer/Colorizer.js +8 -11
  118. package/lib/processor/colorizer/builtin.d.ts +3 -3
  119. package/lib/processor/colorizer/builtin.js +33 -46
  120. package/lib/processor/colorizer/index.d.ts +2 -2
  121. package/lib/processor/colorizer/index.js +2 -27
  122. package/lib/processor/completer/Completer.d.ts +6 -5
  123. package/lib/processor/completer/Completer.js +14 -33
  124. package/lib/processor/completer/builtin.d.ts +10 -9
  125. package/lib/processor/completer/builtin.js +59 -75
  126. package/lib/processor/completer/index.d.ts +2 -2
  127. package/lib/processor/completer/index.js +2 -27
  128. package/lib/processor/formatter/Formatter.d.ts +4 -3
  129. package/lib/processor/formatter/Formatter.js +2 -7
  130. package/lib/processor/formatter/builtin.d.ts +3 -3
  131. package/lib/processor/formatter/builtin.js +22 -36
  132. package/lib/processor/formatter/index.d.ts +2 -2
  133. package/lib/processor/formatter/index.js +2 -27
  134. package/lib/processor/index.d.ts +10 -9
  135. package/lib/processor/index.js +10 -21
  136. package/lib/processor/linter/Linter.d.ts +4 -3
  137. package/lib/processor/linter/Linter.js +1 -2
  138. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
  139. package/lib/processor/linter/builtin/undeclaredSymbol.js +23 -27
  140. package/lib/processor/linter/builtin.d.ts +4 -3
  141. package/lib/processor/linter/builtin.js +19 -26
  142. package/lib/processor/linter/index.d.ts +2 -2
  143. package/lib/processor/linter/index.js +2 -27
  144. package/lib/processor/util.d.ts +4 -14
  145. package/lib/processor/util.js +1 -16
  146. package/lib/service/CacheService.d.ts +8 -6
  147. package/lib/service/CacheService.js +35 -56
  148. package/lib/service/Config.d.ts +17 -16
  149. package/lib/service/Config.js +56 -51
  150. package/lib/service/Context.d.ts +24 -21
  151. package/lib/service/Context.js +40 -36
  152. package/lib/service/Dependency.js +2 -5
  153. package/lib/service/Downloader.d.ts +9 -39
  154. package/lib/service/Downloader.js +37 -106
  155. package/lib/service/ErrorReporter.d.ts +2 -2
  156. package/lib/service/ErrorReporter.js +11 -15
  157. package/lib/service/FileService.d.ts +40 -14
  158. package/lib/service/FileService.js +107 -81
  159. package/lib/service/Hover.d.ts +2 -2
  160. package/lib/service/Hover.js +4 -7
  161. package/lib/service/MetaRegistry.d.ts +17 -12
  162. package/lib/service/MetaRegistry.js +81 -73
  163. package/lib/service/Profiler.d.ts +3 -2
  164. package/lib/service/Profiler.js +81 -45
  165. package/lib/service/Project.d.ts +101 -73
  166. package/lib/service/Project.js +438 -367
  167. package/lib/service/Service.d.ts +19 -29
  168. package/lib/service/Service.js +57 -53
  169. package/lib/service/SymbolLocations.d.ts +3 -3
  170. package/lib/service/SymbolLocations.js +4 -7
  171. package/lib/service/SymbolRegistrar.d.ts +1 -1
  172. package/lib/service/SymbolRegistrar.js +1 -2
  173. package/lib/service/UriProcessor.d.ts +5 -0
  174. package/lib/service/UriProcessor.js +2 -0
  175. package/lib/service/fileUtil.d.ts +21 -41
  176. package/lib/service/fileUtil.js +59 -129
  177. package/lib/service/index.d.ts +16 -17
  178. package/lib/service/index.js +16 -31
  179. package/lib/source/IndexMap.d.ts +1 -1
  180. package/lib/source/IndexMap.js +7 -10
  181. package/lib/source/LanguageError.d.ts +2 -2
  182. package/lib/source/LanguageError.js +3 -6
  183. package/lib/source/Location.d.ts +3 -3
  184. package/lib/source/Location.js +6 -9
  185. package/lib/source/Offset.d.ts +1 -1
  186. package/lib/source/Offset.js +4 -7
  187. package/lib/source/Position.js +2 -5
  188. package/lib/source/PositionRange.d.ts +2 -2
  189. package/lib/source/PositionRange.js +14 -17
  190. package/lib/source/Range.d.ts +1 -1
  191. package/lib/source/Range.js +7 -10
  192. package/lib/source/Source.d.ts +9 -4
  193. package/lib/source/Source.js +58 -31
  194. package/lib/source/index.d.ts +8 -8
  195. package/lib/source/index.js +8 -20
  196. package/lib/symbol/Symbol.d.ts +15 -14
  197. package/lib/symbol/Symbol.js +53 -68
  198. package/lib/symbol/SymbolUtil.d.ts +30 -39
  199. package/lib/symbol/SymbolUtil.js +189 -168
  200. package/lib/symbol/index.d.ts +2 -3
  201. package/lib/symbol/index.js +2 -15
  202. package/package.json +7 -4
  203. package/lib/service/Operations.d.ts +0 -8
  204. package/lib/service/Operations.js +0 -26
  205. package/lib/symbol/UriBinder.d.ts +0 -3
  206. package/lib/symbol/UriBinder.js +0 -3
@@ -1,72 +1,69 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
8
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9
- if (kind === "m") throw new TypeError("Private method is not writable");
10
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
12
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13
- };
14
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
16
- 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");
17
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
18
- };
19
- var __importDefault = (this && this.__importDefault) || function (mod) {
20
- return (mod && mod.__esModule) ? mod : { "default": mod };
21
- };
22
- var _SymbolUtil_global, _SymbolUtil_trimmableSymbols, _SymbolUtil_cache, _SymbolUtil_currentContributor, _SymbolQuery_doc, _SymbolQuery_node, _SymbolQuery_createdWithUri, _SymbolQuery_currentContributor, _SymbolQuery_hasTriggeredIf, _SymbolQuery_map, _SymbolQuery_parentSymbol, _SymbolQuery_symbol;
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.SymbolFormatter = exports.SymbolQuery = exports.SymbolUtil = void 0;
25
- const assert_1 = require("assert");
26
- const events_1 = __importDefault(require("events"));
27
- const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
28
- const source_1 = require("../source");
29
- const Symbol_1 = require("./Symbol");
30
- class SymbolUtil extends events_1.default {
31
- constructor(global,
7
+ import { TextDocument } from 'vscode-languageserver-textdocument';
8
+ import { Range } from '../source/index.js';
9
+ import { SymbolLocation, SymbolPath, SymbolUsageTypes } from './Symbol.js';
10
+ export class SymbolUtil {
11
+ #global;
12
+ #eventEmitter;
13
+ #eventEmitterConstructor;
14
+ #trimmableSymbols = new Set();
15
+ #cache = Object.create(null);
16
+ #currentContributor;
17
+ /**
18
+ * @internal
19
+ */
20
+ _delayedOps = [];
21
+ /**
22
+ * @internal
23
+ */
24
+ _inDelayMode;
25
+ get global() {
26
+ return this.#global;
27
+ }
28
+ constructor(global, eventEmitterConstructor,
32
29
  /** @internal */
33
30
  _currentContributor,
34
31
  /** @internal */
35
32
  _inDelayMode = false) {
36
- super();
37
- _SymbolUtil_global.set(this, void 0);
38
- _SymbolUtil_trimmableSymbols.set(this, new Set());
39
- _SymbolUtil_cache.set(this, Object.create(null));
40
- _SymbolUtil_currentContributor.set(this, void 0);
41
- /**
42
- * @internal
43
- */
44
- this._delayedOps = [];
45
- __classPrivateFieldSet(this, _SymbolUtil_global, global, "f");
46
- __classPrivateFieldSet(this, _SymbolUtil_currentContributor, _currentContributor, "f");
33
+ this.#eventEmitter = new eventEmitterConstructor();
34
+ this.#eventEmitterConstructor = eventEmitterConstructor;
35
+ this.#global = global;
36
+ this.#currentContributor = _currentContributor;
47
37
  this._inDelayMode = _inDelayMode;
48
38
  this
49
39
  .on('symbolCreated', ({ symbol }) => {
50
- __classPrivateFieldGet(this, _SymbolUtil_trimmableSymbols, "f").add(Symbol_1.SymbolPath.toString(symbol));
40
+ this.#trimmableSymbols.add(SymbolPath.toString(symbol));
51
41
  })
52
42
  .on('symbolRemoved', ({ symbol }) => {
53
- __classPrivateFieldGet(this, _SymbolUtil_trimmableSymbols, "f").delete(Symbol_1.SymbolPath.toString(symbol));
43
+ this.#trimmableSymbols.delete(SymbolPath.toString(symbol));
54
44
  })
55
45
  .on('symbolLocationCreated', ({ symbol, location }) => {
56
- var _a, _b, _c;
57
- const cache = (_a = __classPrivateFieldGet(this, _SymbolUtil_cache, "f"))[_b = location.contributor ?? 'undefined'] ?? (_a[_b] = Object.create(null));
58
- const fileSymbols = cache[_c = location.uri] ?? (cache[_c] = new Set());
59
- const path = Symbol_1.SymbolPath.toString(symbol);
46
+ const cache = this.#cache[location.contributor ?? 'undefined'] ??= Object.create(null);
47
+ const fileSymbols = cache[location.uri] ??= new Set();
48
+ const path = SymbolPath.toString(symbol);
60
49
  fileSymbols.add(path);
61
- __classPrivateFieldGet(this, _SymbolUtil_trimmableSymbols, "f").delete(path);
50
+ this.#trimmableSymbols.delete(path);
62
51
  })
63
52
  .on('symbolLocationRemoved', ({ symbol }) => {
64
- const path = Symbol_1.SymbolPath.toString(symbol);
65
- __classPrivateFieldGet(this, _SymbolUtil_trimmableSymbols, "f").add(path);
53
+ const path = SymbolPath.toString(symbol);
54
+ this.#trimmableSymbols.add(path);
66
55
  });
67
56
  }
68
- get global() {
69
- return __classPrivateFieldGet(this, _SymbolUtil_global, "f");
57
+ on(event, callbackFn) {
58
+ this.#eventEmitter.on(event, callbackFn);
59
+ return this;
60
+ }
61
+ once(event, callbackFn) {
62
+ this.#eventEmitter.once(event, callbackFn);
63
+ return this;
64
+ }
65
+ emit(event, ...args) {
66
+ return this.#eventEmitter.emit(event, ...args);
70
67
  }
71
68
  /**
72
69
  * Build the internal cache of the SymbolUtil according to the current global symbol table.
@@ -87,7 +84,7 @@ class SymbolUtil extends events_1.default {
87
84
  * `applyDelayedEdits` is called, the original SymbolUtil will also be modified.
88
85
  */
89
86
  clone() {
90
- return new SymbolUtil(__classPrivateFieldGet(this, _SymbolUtil_global, "f"), __classPrivateFieldGet(this, _SymbolUtil_currentContributor, "f"), true);
87
+ return new SymbolUtil(this.#global, this.#eventEmitterConstructor, this.#currentContributor, true);
91
88
  }
92
89
  /**
93
90
  * Apply edits done during the delay mode.
@@ -98,24 +95,24 @@ class SymbolUtil extends events_1.default {
98
95
  this._inDelayMode = false;
99
96
  }
100
97
  contributeAs(contributor, fn) {
101
- const originalValue = __classPrivateFieldGet(this, _SymbolUtil_currentContributor, "f");
102
- __classPrivateFieldSet(this, _SymbolUtil_currentContributor, contributor, "f");
98
+ const originalValue = this.#currentContributor;
99
+ this.#currentContributor = contributor;
103
100
  try {
104
101
  fn();
105
102
  }
106
103
  finally {
107
- __classPrivateFieldSet(this, _SymbolUtil_currentContributor, originalValue, "f");
104
+ this.#currentContributor = originalValue;
108
105
  }
109
106
  return this;
110
107
  }
111
108
  async contributeAsAsync(contributor, fn) {
112
- const originalValue = __classPrivateFieldGet(this, _SymbolUtil_currentContributor, "f");
113
- __classPrivateFieldSet(this, _SymbolUtil_currentContributor, contributor, "f");
109
+ const originalValue = this.#currentContributor;
110
+ this.#currentContributor = contributor;
114
111
  try {
115
112
  await fn();
116
113
  }
117
114
  finally {
118
- __classPrivateFieldSet(this, _SymbolUtil_currentContributor, originalValue, "f");
115
+ this.#currentContributor = originalValue;
119
116
  }
120
117
  return this;
121
118
  }
@@ -129,10 +126,10 @@ class SymbolUtil extends events_1.default {
129
126
  clear({ uri, contributor, predicate = () => true }) {
130
127
  const getCaches = () => {
131
128
  if (contributor) {
132
- return __classPrivateFieldGet(this, _SymbolUtil_cache, "f")[contributor] ? [__classPrivateFieldGet(this, _SymbolUtil_cache, "f")[contributor]] : [];
129
+ return this.#cache[contributor] ? [this.#cache[contributor]] : [];
133
130
  }
134
131
  else {
135
- return Object.values(__classPrivateFieldGet(this, _SymbolUtil_cache, "f"));
132
+ return Object.values(this.#cache);
136
133
  }
137
134
  };
138
135
  const getPaths = () => {
@@ -140,12 +137,12 @@ class SymbolUtil extends events_1.default {
140
137
  const sets = uri
141
138
  ? caches.map(cache => cache[uri] ?? new Set())
142
139
  : caches.map(cache => Object.values(cache)).flat();
143
- return sets.map(s => [...s]).flat().map(Symbol_1.SymbolPath.fromString);
140
+ return sets.map(s => [...s]).flat().map(SymbolPath.fromString);
144
141
  };
145
142
  const getTables = () => {
146
143
  return uri
147
- ? [__classPrivateFieldGet(this, _SymbolUtil_global, "f")]
148
- : [__classPrivateFieldGet(this, _SymbolUtil_global, "f")];
144
+ ? [this.#global]
145
+ : [this.#global];
149
146
  };
150
147
  const paths = getPaths();
151
148
  const tables = getTables();
@@ -163,6 +160,15 @@ class SymbolUtil extends events_1.default {
163
160
  }
164
161
  }
165
162
  lookup(category, path, node) {
163
+ while (node) {
164
+ if (node.locals) {
165
+ const result = SymbolUtil.lookupTable(node.locals, category, path);
166
+ if (result.symbol) {
167
+ return result;
168
+ }
169
+ }
170
+ node = node.parent;
171
+ }
166
172
  return SymbolUtil.lookupTable(this.global, category, path);
167
173
  }
168
174
  query(doc, category, ...path) {
@@ -172,7 +178,7 @@ class SymbolUtil extends events_1.default {
172
178
  return new SymbolQuery({
173
179
  category,
174
180
  doc,
175
- contributor: __classPrivateFieldGet(this, _SymbolUtil_currentContributor, "f"),
181
+ contributor: this.#currentContributor,
176
182
  map: visible ? parentMap : undefined,
177
183
  parentSymbol: parentSymbol,
178
184
  path,
@@ -207,14 +213,14 @@ class SymbolUtil extends events_1.default {
207
213
  trimSymbol(symbol.parentSymbol);
208
214
  }
209
215
  };
210
- for (const pathString of __classPrivateFieldGet(this, _SymbolUtil_trimmableSymbols, "f")) {
211
- const path = Symbol_1.SymbolPath.fromString(pathString);
216
+ for (const pathString of this.#trimmableSymbols) {
217
+ const path = SymbolPath.fromString(pathString);
212
218
  const { symbol } = SymbolUtil.lookupTable(table, path.category, path.path);
213
219
  trimSymbol(symbol);
214
220
  }
215
221
  }
216
222
  removeLocationsFromSymbol(symbol, predicate) {
217
- for (const type of Symbol_1.SymbolUsageTypes) {
223
+ for (const type of SymbolUsageTypes) {
218
224
  if (!symbol[type]) {
219
225
  continue;
220
226
  }
@@ -304,7 +310,7 @@ class SymbolUtil extends events_1.default {
304
310
  symbol.desc = addition.desc;
305
311
  }
306
312
  if (addition.relations && Object.keys(addition.relations).length) {
307
- symbol.relations ?? (symbol.relations = {});
313
+ symbol.relations ??= {};
308
314
  for (const relationship of Object.keys(addition.relations)) {
309
315
  symbol.relations[relationship] = addition.relations[relationship];
310
316
  }
@@ -315,12 +321,12 @@ class SymbolUtil extends events_1.default {
315
321
  if ('visibility' in addition) {
316
322
  // Visibility changes are only accepted if the change wouldn't result in the
317
323
  // symbol being stored in a different symbol table.
318
- const inGlobalTable = (v) => v === undefined || v === 2 /* Public */ || v === 3 /* Restricted */;
324
+ const inGlobalTable = (v) => v === undefined || v === 2 /* SymbolVisibility.Public */ || v === 3 /* SymbolVisibility.Restricted */;
319
325
  if (symbol.visibility === addition.visibility || (inGlobalTable(symbol.visibility) && inGlobalTable(addition.visibility))) {
320
326
  symbol.visibility = addition.visibility;
321
327
  }
322
328
  else {
323
- throw new Error(`Cannot change visibility from ${symbol.visibility} to ${addition.visibility}: ${JSON.stringify(Symbol_1.SymbolPath.fromSymbol(symbol))}`);
329
+ throw new Error(`Cannot change visibility from ${symbol.visibility} to ${addition.visibility}: ${JSON.stringify(SymbolPath.fromSymbol(symbol))}`);
324
330
  }
325
331
  }
326
332
  if (addition.visibilityRestriction?.length) {
@@ -331,9 +337,9 @@ class SymbolUtil extends events_1.default {
331
337
  amendSymbolUsage(symbol, addition, doc, contributor) {
332
338
  if (addition) {
333
339
  const type = addition.type ?? 'reference';
334
- const arr = symbol[type] ?? (symbol[type] = []);
335
- const range = source_1.Range.get((SymbolAdditionUsageWithNode.is(addition) ? addition.node : addition.range) ?? 0);
336
- const location = Symbol_1.SymbolLocation.create(doc, range, addition.fullRange, contributor, {
340
+ const arr = symbol[type] ??= [];
341
+ const range = Range.get((SymbolAdditionUsageWithNode.is(addition) ? addition.node : addition.range) ?? 0);
342
+ const location = SymbolLocation.create(doc, range, addition.fullRange, contributor, {
337
343
  accessType: addition.accessType,
338
344
  skipRenaming: addition.skipRenaming,
339
345
  });
@@ -369,11 +375,11 @@ class SymbolUtil extends events_1.default {
369
375
  }
370
376
  static isVisible(symbol, _uri) {
371
377
  switch (symbol.visibility) {
372
- case 3 /* Restricted */:
378
+ case 3 /* SymbolVisibility.Restricted */:
373
379
  return false; // FIXME: check with workspace root URIs.
374
- case 0 /* Block */:
375
- case 1 /* File */:
376
- case 2 /* Public */:
380
+ case 0 /* SymbolVisibility.Block */:
381
+ case 1 /* SymbolVisibility.File */:
382
+ case 2 /* SymbolVisibility.Public */:
377
383
  default:
378
384
  return true;
379
385
  }
@@ -412,7 +418,7 @@ class SymbolUtil extends events_1.default {
412
418
  * @throws If the symbol does not have any declarations or definitions.
413
419
  */
414
420
  static getDeclaredLocation(symbol) {
415
- return symbol.declaration?.[0] ?? symbol.definition?.[0] ?? (() => { throw new Error(`Cannot get declared location of ${JSON.stringify(Symbol_1.SymbolPath.fromSymbol(symbol))}`); })();
421
+ return symbol.declaration?.[0] ?? symbol.definition?.[0] ?? (() => { throw new Error(`Cannot get declared location of ${JSON.stringify(SymbolPath.fromSymbol(symbol))}`); })();
416
422
  }
417
423
  static forEachSymbolInMap(map, fn) {
418
424
  for (const symbol of Object.values(map)) {
@@ -428,20 +434,19 @@ class SymbolUtil extends events_1.default {
428
434
  }
429
435
  }
430
436
  static forEachLocationOfSymbol(symbol, fn) {
431
- for (const type of Symbol_1.SymbolUsageTypes) {
437
+ for (const type of SymbolUsageTypes) {
432
438
  symbol[type]?.forEach(location => fn({ type, location }));
433
439
  }
434
440
  }
435
441
  static isVisibilityInGlobal(v) {
436
- return v === undefined || v === 2 /* Public */ || v === 3 /* Restricted */;
442
+ return v === undefined || v === 2 /* SymbolVisibility.Public */ || v === 3 /* SymbolVisibility.Restricted */;
437
443
  }
438
444
  static areVisibilitiesCompatible(v1, v2) {
439
445
  return ((this.isVisibilityInGlobal(v1) && this.isVisibilityInGlobal(v2)) ||
440
- (v1 === 0 /* Block */ && v2 === 0 /* Block */) ||
441
- (v1 === 1 /* File */ && v2 === 1 /* File */));
446
+ (v1 === 0 /* SymbolVisibility.Block */ && v2 === 0 /* SymbolVisibility.Block */) ||
447
+ (v1 === 1 /* SymbolVisibility.File */ && v2 === 1 /* SymbolVisibility.File */));
442
448
  }
443
449
  }
444
- _SymbolUtil_global = new WeakMap(), _SymbolUtil_trimmableSymbols = new WeakMap(), _SymbolUtil_cache = new WeakMap(), _SymbolUtil_currentContributor = new WeakMap();
445
450
  __decorate([
446
451
  DelayModeSupport()
447
452
  ], SymbolUtil.prototype, "clear", null);
@@ -451,7 +456,6 @@ __decorate([
451
456
  __decorate([
452
457
  DelayModeSupport()
453
458
  ], SymbolUtil.prototype, "removeLocationsFromSymbol", null);
454
- exports.SymbolUtil = SymbolUtil;
455
459
  var SymbolAdditionUsageWithRange;
456
460
  (function (SymbolAdditionUsageWithRange) {
457
461
  /* istanbul ignore next */
@@ -469,65 +473,71 @@ var SymbolAdditionUsageWithNode;
469
473
  SymbolAdditionUsageWithNode.is = is;
470
474
  })(SymbolAdditionUsageWithNode || (SymbolAdditionUsageWithNode = {}));
471
475
  /* istanbul ignore next */
472
- class SymbolQuery {
476
+ export class SymbolQuery {
477
+ category;
478
+ path;
479
+ #doc;
480
+ #node;
481
+ /**
482
+ * If only a string URI (instead of a {@link TextDocument}) is provided when constructing this class.
483
+ *
484
+ * If this is `true`, {@link SymbolAdditionUsageWithRange.range} is ignored and treated as `[0, 0)` when entering symbols through this class.
485
+ */
486
+ #createdWithUri;
487
+ #currentContributor;
488
+ #hasTriggeredIf = false;
489
+ /**
490
+ * The map where the queried symbol is stored. `undefined` if the map hasn't been created yet.
491
+ */
492
+ #map;
493
+ #parentSymbol;
494
+ /**
495
+ * The queried symbol. `undefined` if the symbol hasn't been created yet.
496
+ */
497
+ #symbol;
498
+ /**
499
+ * The {@link SymbolUtil} where this query was created.
500
+ */
501
+ util;
502
+ get symbol() {
503
+ return this.#symbol;
504
+ }
505
+ get visibleMembers() {
506
+ return SymbolUtil.filterVisibleSymbols(this.#doc.uri, this.path.length === 0 ? this.#map : this.#symbol?.members);
507
+ }
473
508
  constructor({ category, contributor, doc, map, parentSymbol, path, symbol, util }) {
474
- _SymbolQuery_doc.set(this, void 0);
475
- _SymbolQuery_node.set(this, void 0);
476
- /**
477
- * If only a string URI (instead of a {@link TextDocument}) is provided when constructing this class.
478
- *
479
- * If this is `true`, {@link SymbolAdditionUsageWithRange.range} is ignored and treated as `[0, 0)` when entering symbols through this class.
480
- */
481
- _SymbolQuery_createdWithUri.set(this, void 0);
482
- _SymbolQuery_currentContributor.set(this, void 0);
483
- _SymbolQuery_hasTriggeredIf.set(this, false
484
- /**
485
- * The map where the queried symbol is stored. `undefined` if the map hasn't been created yet.
486
- */
487
- );
488
- /**
489
- * The map where the queried symbol is stored. `undefined` if the map hasn't been created yet.
490
- */
491
- _SymbolQuery_map.set(this, void 0);
492
- _SymbolQuery_parentSymbol.set(this, void 0);
493
- /**
494
- * The queried symbol. `undefined` if the symbol hasn't been created yet.
495
- */
496
- _SymbolQuery_symbol.set(this, void 0);
497
509
  this.category = category;
498
510
  this.path = path;
499
511
  if (typeof doc === 'string') {
500
- doc = vscode_languageserver_textdocument_1.TextDocument.create(doc, '', 0, '');
501
- __classPrivateFieldSet(this, _SymbolQuery_createdWithUri, true, "f");
512
+ doc = TextDocument.create(doc, '', 0, '');
513
+ this.#createdWithUri = true;
502
514
  }
503
515
  else if (isDocAndNode(doc)) {
504
- __classPrivateFieldSet(this, _SymbolQuery_node, doc.node, "f");
516
+ this.#node = doc.node;
505
517
  doc = doc.doc;
506
518
  }
507
- __classPrivateFieldSet(this, _SymbolQuery_doc, doc, "f");
508
- __classPrivateFieldSet(this, _SymbolQuery_currentContributor, contributor, "f");
509
- __classPrivateFieldSet(this, _SymbolQuery_map, map, "f");
510
- __classPrivateFieldSet(this, _SymbolQuery_parentSymbol, parentSymbol, "f");
511
- __classPrivateFieldSet(this, _SymbolQuery_symbol, symbol, "f");
519
+ this.#doc = doc;
520
+ this.#currentContributor = contributor;
521
+ this.#map = map;
522
+ this.#parentSymbol = parentSymbol;
523
+ this.#symbol = symbol;
512
524
  this.util = util;
513
525
  }
514
- get symbol() {
515
- return __classPrivateFieldGet(this, _SymbolQuery_symbol, "f");
516
- }
517
- get visibleMembers() {
518
- return SymbolUtil.filterVisibleSymbols(__classPrivateFieldGet(this, _SymbolQuery_doc, "f").uri, this.path.length === 0 ? __classPrivateFieldGet(this, _SymbolQuery_map, "f") : __classPrivateFieldGet(this, _SymbolQuery_symbol, "f")?.members);
519
- }
520
526
  heyGimmeDaSymbol() {
521
- return __classPrivateFieldGet(this, _SymbolQuery_symbol, "f");
527
+ return this.#symbol;
528
+ }
529
+ getData(predicate) {
530
+ const data = this.#symbol?.data;
531
+ return predicate(data) ? data : undefined;
522
532
  }
523
533
  with(fn) {
524
534
  fn(this);
525
535
  return this;
526
536
  }
527
537
  if(predicate, fn) {
528
- if (predicate.call(this, __classPrivateFieldGet(this, _SymbolQuery_symbol, "f"), this)) {
529
- fn.call(this, __classPrivateFieldGet(this, _SymbolQuery_symbol, "f"), this);
530
- __classPrivateFieldSet(this, _SymbolQuery_hasTriggeredIf, true, "f");
538
+ if (predicate.call(this, this.#symbol, this)) {
539
+ fn.call(this, this.#symbol, this);
540
+ this.#hasTriggeredIf = true;
531
541
  }
532
542
  return this;
533
543
  }
@@ -577,8 +587,8 @@ class SymbolQuery {
577
587
  * Calls `fn` if none of the former `if` conditions are met.
578
588
  */
579
589
  else(fn) {
580
- if (!__classPrivateFieldGet(this, _SymbolQuery_hasTriggeredIf, "f")) {
581
- fn.call(this, __classPrivateFieldGet(this, _SymbolQuery_symbol, "f"), this);
590
+ if (!this.#hasTriggeredIf) {
591
+ fn.call(this, this.#symbol, this);
582
592
  }
583
593
  return this;
584
594
  }
@@ -597,29 +607,37 @@ class SymbolQuery {
597
607
  return this.else(() => this.resolveAlias());
598
608
  }
599
609
  _enter(addition) {
610
+ /**
611
+ * Get a proper visibility from the addition:
612
+ * * If the visibility is specified, use it.
613
+ * * If the visibility is `undefined`, use the visibility of the symbol, or `Public` if unapplicable.
614
+ */
615
+ const getAdditionVisibility = (addition) => {
616
+ return addition.data?.visibility ?? this.symbol?.visibility ?? 2 /* SymbolVisibility.Public */;
617
+ };
600
618
  const getMap = (addition) => {
601
- var _a, _b;
602
- if (__classPrivateFieldGet(this, _SymbolQuery_map, "f") && SymbolUtil.areVisibilitiesCompatible(addition.data?.visibility, __classPrivateFieldGet(this, _SymbolQuery_symbol, "f")?.visibility)) {
603
- return __classPrivateFieldGet(this, _SymbolQuery_map, "f");
619
+ const additionVisibility = getAdditionVisibility(addition);
620
+ if (this.#map && SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#symbol?.visibility)) {
621
+ return this.#map;
604
622
  }
605
623
  if (this.path.length > 1) {
606
- if (__classPrivateFieldGet(this, _SymbolQuery_parentSymbol, "f")) {
607
- if (!SymbolUtil.areVisibilitiesCompatible(addition.data?.visibility, __classPrivateFieldGet(this, _SymbolQuery_parentSymbol, "f").visibility)) {
608
- throw new Error(`Cannot enter member “${this.getPath()}” of ${SymbolFormatter.stringifyVisibility(addition.data?.visibility)} visibility to parent of ${SymbolFormatter.stringifyVisibility(__classPrivateFieldGet(this, _SymbolQuery_parentSymbol, "f").visibility)} visibility`);
624
+ if (this.#parentSymbol) {
625
+ if (!SymbolUtil.areVisibilitiesCompatible(additionVisibility, this.#parentSymbol.visibility)) {
626
+ throw new Error(`Cannot enter member “${this.getPath()}” of ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility to parent of ${SymbolFormatter.stringifyVisibility(this.#parentSymbol.visibility)} visibility`);
609
627
  }
610
- return (_a = __classPrivateFieldGet(this, _SymbolQuery_parentSymbol, "f")).members ?? (_a.members = {});
628
+ return this.#parentSymbol.members ??= {};
611
629
  }
612
630
  }
613
631
  else {
614
632
  let table;
615
- if (SymbolUtil.isVisibilityInGlobal(addition.data?.visibility)) {
633
+ if (SymbolUtil.isVisibilityInGlobal(additionVisibility)) {
616
634
  table = this.util.global;
617
635
  }
618
- else if (addition.data?.visibility === 1 /* File */) {
619
- if (!__classPrivateFieldGet(this, _SymbolQuery_node, "f")) {
620
- throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(addition.data?.visibility)} visibility as no node is supplied`);
636
+ else if (additionVisibility === 1 /* SymbolVisibility.File */) {
637
+ if (!this.#node) {
638
+ throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility as no node is supplied`);
621
639
  }
622
- let node = __classPrivateFieldGet(this, _SymbolQuery_node, "f");
640
+ let node = this.#node;
623
641
  while (node) {
624
642
  if (node.type === 'file') {
625
643
  table = node.locals;
@@ -628,14 +646,14 @@ class SymbolQuery {
628
646
  node = node.parent;
629
647
  }
630
648
  if (!table) {
631
- throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(addition.data?.visibility)} visibility as no file node is supplied`);
649
+ throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility as no file node is supplied`);
632
650
  }
633
651
  }
634
652
  else {
635
- if (!__classPrivateFieldGet(this, _SymbolQuery_node, "f")) {
636
- throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(addition.data?.visibility)} visibility as no node is supplied`);
653
+ if (!this.#node) {
654
+ throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility as no node is supplied`);
637
655
  }
638
- let node = __classPrivateFieldGet(this, _SymbolQuery_node, "f");
656
+ let node = this.#node;
639
657
  while (node) {
640
658
  if (node.locals) {
641
659
  table = node.locals;
@@ -644,22 +662,22 @@ class SymbolQuery {
644
662
  node = node.parent;
645
663
  }
646
664
  if (!table) {
647
- throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(addition.data?.visibility)} visibility as no node with locals is supplied`);
665
+ throw new Error(`Cannot enter “${this.getPath()}” with ${SymbolFormatter.stringifyVisibility(additionVisibility)} visibility as no node with locals is supplied`);
648
666
  }
649
667
  }
650
668
  // TODO: Move part of symbol from global to table.
651
- return table[_b = this.category] ?? (table[_b] = {});
669
+ return table[this.category] ??= {};
652
670
  }
653
671
  throw new Error(`Cannot create the symbol map for “${this.getPath()}”`);
654
672
  };
655
673
  // Treat `usage.range` as `[0, 0)` if this class was constructed with a string URI (instead of a `TextDocument`).
656
- if (__classPrivateFieldGet(this, _SymbolQuery_createdWithUri, "f") && SymbolAdditionUsageWithRange.is(addition.usage)) {
657
- addition.usage.range = source_1.Range.create(0, 0);
674
+ if (this.#createdWithUri && SymbolAdditionUsageWithRange.is(addition.usage)) {
675
+ addition.usage.range = Range.create(0, 0);
658
676
  }
659
- __classPrivateFieldSet(this, _SymbolQuery_map, getMap(addition), "f");
660
- __classPrivateFieldSet(this, _SymbolQuery_symbol, this.util.enterMap(__classPrivateFieldGet(this, _SymbolQuery_parentSymbol, "f"), __classPrivateFieldGet(this, _SymbolQuery_map, "f"), this.category, this.path, this.path[this.path.length - 1], addition, __classPrivateFieldGet(this, _SymbolQuery_doc, "f"), __classPrivateFieldGet(this, _SymbolQuery_currentContributor, "f")), "f");
677
+ this.#map = getMap(addition);
678
+ this.#symbol = this.util.enterMap(this.#parentSymbol, this.#map, this.category, this.path, this.path[this.path.length - 1], addition, this.#doc, this.#currentContributor);
661
679
  if (addition.usage?.node) {
662
- addition.usage.node.symbol = __classPrivateFieldGet(this, _SymbolQuery_symbol, "f");
680
+ addition.usage.node.symbol = this.#symbol;
663
681
  }
664
682
  }
665
683
  /**
@@ -693,13 +711,13 @@ class SymbolQuery {
693
711
  * after the error is thrown.
694
712
  */
695
713
  resolveAlias() {
696
- if (__classPrivateFieldGet(this, _SymbolQuery_symbol, "f")) {
697
- const result = this.util.resolveAlias(__classPrivateFieldGet(this, _SymbolQuery_symbol, "f"));
714
+ if (this.#symbol) {
715
+ const result = this.util.resolveAlias(this.#symbol);
698
716
  if (!result) {
699
717
  throw new Error('The current symbol points to an non-existent symbol.');
700
718
  }
701
- __classPrivateFieldSet(this, _SymbolQuery_symbol, result, "f");
702
- __classPrivateFieldSet(this, _SymbolQuery_map, result.parentMap, "f");
719
+ this.#symbol = result;
720
+ this.#map = result.parentMap;
703
721
  }
704
722
  return this;
705
723
  }
@@ -708,7 +726,7 @@ class SymbolQuery {
708
726
  let doc, identifier, fn;
709
727
  if (arguments.length === 2) {
710
728
  // Ensure the member query result will not unknowingly have a dummy TextDocument passed down from this class.
711
- doc = __classPrivateFieldGet(this, _SymbolQuery_createdWithUri, "f") ? __classPrivateFieldGet(this, _SymbolQuery_doc, "f").uri : __classPrivateFieldGet(this, _SymbolQuery_doc, "f");
729
+ doc = this.#createdWithUri ? this.#doc.uri : this.#doc;
712
730
  identifier = arguments[0];
713
731
  fn = arguments[1];
714
732
  }
@@ -717,20 +735,20 @@ class SymbolQuery {
717
735
  identifier = arguments[1];
718
736
  fn = arguments[2];
719
737
  }
720
- if (__classPrivateFieldGet(this, _SymbolQuery_symbol, "f") === undefined) {
738
+ if (this.#symbol === undefined) {
721
739
  throw new Error(`Tried to query member symbol “${identifier}” from an undefined symbol (path “${this.path.join('.')}”)`);
722
740
  }
723
- const memberDoc = typeof doc === 'string' && doc === __classPrivateFieldGet(this, _SymbolQuery_doc, "f").uri && !__classPrivateFieldGet(this, _SymbolQuery_createdWithUri, "f")
724
- ? __classPrivateFieldGet(this, _SymbolQuery_doc, "f")
741
+ const memberDoc = typeof doc === 'string' && doc === this.#doc.uri && !this.#createdWithUri
742
+ ? this.#doc
725
743
  : doc;
726
- const memberMap = __classPrivateFieldGet(this, _SymbolQuery_symbol, "f").members;
744
+ const memberMap = this.#symbol.members;
727
745
  const memberSymbol = memberMap?.[identifier];
728
746
  const memberQueryResult = new SymbolQuery({
729
747
  category: this.category,
730
748
  doc: memberDoc,
731
- contributor: __classPrivateFieldGet(this, _SymbolQuery_currentContributor, "f"),
749
+ contributor: this.#currentContributor,
732
750
  map: memberMap,
733
- parentSymbol: __classPrivateFieldGet(this, _SymbolQuery_symbol, "f"),
751
+ parentSymbol: this.#symbol,
734
752
  path: [...this.path, identifier],
735
753
  symbol: memberSymbol,
736
754
  util: this.util,
@@ -755,18 +773,21 @@ class SymbolQuery {
755
773
  return `${this.category}.${this.path.join('/')}`;
756
774
  }
757
775
  }
758
- _SymbolQuery_doc = new WeakMap(), _SymbolQuery_node = new WeakMap(), _SymbolQuery_createdWithUri = new WeakMap(), _SymbolQuery_currentContributor = new WeakMap(), _SymbolQuery_hasTriggeredIf = new WeakMap(), _SymbolQuery_map = new WeakMap(), _SymbolQuery_parentSymbol = new WeakMap(), _SymbolQuery_symbol = new WeakMap();
759
776
  __decorate([
760
777
  DelayModeSupport((self) => self.util)
761
778
  ], SymbolQuery.prototype, "_enter", null);
762
- exports.SymbolQuery = SymbolQuery;
763
779
  /* istanbul ignore next */
764
780
  /**
765
781
  * A series of methods for converting symbol structures to human-readable outputs. Mostly for debug purposes.
766
782
  */
767
- var SymbolFormatter;
783
+ export var SymbolFormatter;
768
784
  (function (SymbolFormatter) {
769
785
  const IndentChar = '+ ';
786
+ function assertEqual(a, b) {
787
+ if (a !== b) {
788
+ throw new Error(`Assertion error: ${a} !== ${b}`);
789
+ }
790
+ }
770
791
  function stringifySymbolStack(stack) {
771
792
  return stack.map(table => stringifySymbolTable(table)).join('\n------------\n');
772
793
  }
@@ -787,7 +808,7 @@ var SymbolFormatter;
787
808
  const ans = [];
788
809
  for (const identifier of Object.keys(map)) {
789
810
  const symbol = map[identifier];
790
- assert_1.strict.equal(identifier, symbol.identifier);
811
+ assertEqual(identifier, symbol.identifier);
791
812
  ans.push(stringifySymbol(symbol, indent));
792
813
  }
793
814
  return ans.join(`\n${indent}------------\n`);
@@ -798,7 +819,7 @@ var SymbolFormatter;
798
819
  return 'undefined';
799
820
  }
800
821
  const ans = [];
801
- assert_1.strict.equal(symbol.path[symbol.path.length - 1], symbol.identifier);
822
+ assertEqual(symbol.path[symbol.path.length - 1], symbol.identifier);
802
823
  ans.push(`SYMBOL ${symbol.path.join('.')}` +
803
824
  ` {${symbol.category}${symbol.subcategory ? ` (${symbol.subcategory})` : ''}}` +
804
825
  ` [${stringifyVisibility(symbol.visibility, symbol.visibilityRestriction)}]`);
@@ -808,7 +829,7 @@ var SymbolFormatter;
808
829
  if (symbol.desc) {
809
830
  ans.push(`${IndentChar}description: ${symbol.desc}`);
810
831
  }
811
- for (const type of Symbol_1.SymbolUsageTypes) {
832
+ for (const type of SymbolUsageTypes) {
812
833
  if (symbol[type]) {
813
834
  ans.push(`${IndentChar}${type}:\n${symbol[type].map(v => `${indent}${IndentChar.repeat(2)}${JSON.stringify(v)}`).join(`\n${indent}${IndentChar.repeat(2)}------------\n`)}`);
814
835
  }
@@ -826,13 +847,13 @@ var SymbolFormatter;
826
847
  let stringVisibility;
827
848
  // Const enums cannot be indexed even if `--preserveConstEnums` is on: https://github.com/microsoft/TypeScript/issues/31353
828
849
  switch (visibility) {
829
- case 0 /* Block */:
850
+ case 0 /* SymbolVisibility.Block */:
830
851
  stringVisibility = 'Block';
831
852
  break;
832
- case 1 /* File */:
853
+ case 1 /* SymbolVisibility.File */:
833
854
  stringVisibility = 'File';
834
855
  break;
835
- case 3 /* Restricted */:
856
+ case 3 /* SymbolVisibility.Restricted */:
836
857
  stringVisibility = 'Restricted';
837
858
  break;
838
859
  default:
@@ -851,7 +872,7 @@ symbol:
851
872
  ${stringifySymbol(result.symbol, IndentChar)}`;
852
873
  }
853
874
  SymbolFormatter.stringifyLookupResult = stringifyLookupResult;
854
- })(SymbolFormatter = exports.SymbolFormatter || (exports.SymbolFormatter = {}));
875
+ })(SymbolFormatter || (SymbolFormatter = {}));
855
876
  /**
856
877
  * Make a method support delay mode: if the {@link SymbolUtil} is in delay mode, the actual invocation of the method will be
857
878
  * stored to the {@link SymbolUtil._delayedOps} array.