@spyglassmc/core 0.1.2 → 0.4.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 (205) 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.js +4 -10
  15. package/lib/common/externals/BrowserExternals.d.ts +3 -0
  16. package/lib/common/externals/BrowserExternals.js +191 -0
  17. package/lib/common/externals/NodeJsExternals.d.ts +3 -0
  18. package/lib/common/externals/NodeJsExternals.js +152 -0
  19. package/lib/common/externals/downloader.d.ts +31 -0
  20. package/lib/common/externals/downloader.js +32 -0
  21. package/lib/common/externals/index.d.ts +96 -0
  22. package/lib/common/externals/index.js +2 -0
  23. package/lib/common/index.d.ts +8 -1
  24. package/lib/common/index.js +8 -17
  25. package/lib/common/util.d.ts +48 -20
  26. package/lib/common/util.js +71 -86
  27. package/lib/index.d.ts +7 -7
  28. package/lib/index.js +7 -23
  29. package/lib/node/AstNode.d.ts +12 -11
  30. package/lib/node/AstNode.js +10 -16
  31. package/lib/node/BooleanNode.d.ts +2 -2
  32. package/lib/node/BooleanNode.js +4 -7
  33. package/lib/node/CommentNode.d.ts +6 -5
  34. package/lib/node/CommentNode.js +4 -9
  35. package/lib/node/ErrorNode.d.ts +1 -1
  36. package/lib/node/ErrorNode.js +2 -5
  37. package/lib/node/FileNode.d.ts +8 -4
  38. package/lib/node/FileNode.js +3 -6
  39. package/lib/node/FloatNode.d.ts +3 -3
  40. package/lib/node/FloatNode.js +4 -7
  41. package/lib/node/IntegerNode.d.ts +3 -3
  42. package/lib/node/IntegerNode.js +4 -7
  43. package/lib/node/ListNode.d.ts +2 -2
  44. package/lib/node/ListNode.js +2 -5
  45. package/lib/node/LiteralNode.d.ts +4 -4
  46. package/lib/node/LiteralNode.js +4 -7
  47. package/lib/node/LongNode.d.ts +3 -3
  48. package/lib/node/LongNode.js +4 -7
  49. package/lib/node/RecordNode.d.ts +2 -2
  50. package/lib/node/RecordNode.js +2 -5
  51. package/lib/node/ResourceLocationNode.d.ts +7 -7
  52. package/lib/node/ResourceLocationNode.js +9 -12
  53. package/lib/node/Sequence.d.ts +2 -2
  54. package/lib/node/Sequence.js +4 -7
  55. package/lib/node/StringNode.d.ts +5 -5
  56. package/lib/node/StringNode.js +9 -12
  57. package/lib/node/SymbolNode.d.ts +4 -4
  58. package/lib/node/SymbolNode.js +4 -7
  59. package/lib/node/index.d.ts +15 -15
  60. package/lib/node/index.js +15 -31
  61. package/lib/nodejs.d.ts +2 -0
  62. package/lib/nodejs.js +2 -0
  63. package/lib/parser/Parser.d.ts +3 -3
  64. package/lib/parser/Parser.js +1 -4
  65. package/lib/parser/boolean.d.ts +2 -2
  66. package/lib/parser/boolean.js +3 -6
  67. package/lib/parser/comment.d.ts +2 -2
  68. package/lib/parser/comment.js +5 -9
  69. package/lib/parser/empty.d.ts +1 -1
  70. package/lib/parser/empty.js +1 -5
  71. package/lib/parser/error.d.ts +2 -2
  72. package/lib/parser/error.js +5 -9
  73. package/lib/parser/file.d.ts +3 -3
  74. package/lib/parser/file.js +9 -13
  75. package/lib/parser/float.d.ts +4 -4
  76. package/lib/parser/float.js +12 -16
  77. package/lib/parser/index.d.ts +16 -16
  78. package/lib/parser/index.js +16 -38
  79. package/lib/parser/integer.d.ts +4 -4
  80. package/lib/parser/integer.js +10 -14
  81. package/lib/parser/list.d.ts +2 -2
  82. package/lib/parser/list.js +15 -19
  83. package/lib/parser/literal.d.ts +2 -2
  84. package/lib/parser/literal.js +5 -9
  85. package/lib/parser/long.d.ts +4 -4
  86. package/lib/parser/long.js +10 -14
  87. package/lib/parser/record.d.ts +3 -3
  88. package/lib/parser/record.js +20 -24
  89. package/lib/parser/resourceLocation.d.ts +2 -2
  90. package/lib/parser/resourceLocation.js +12 -24
  91. package/lib/parser/string.d.ts +7 -7
  92. package/lib/parser/string.js +36 -42
  93. package/lib/parser/symbol.d.ts +3 -3
  94. package/lib/parser/symbol.js +4 -14
  95. package/lib/parser/util.d.ts +6 -5
  96. package/lib/parser/util.js +40 -60
  97. package/lib/processor/ColorInfoProvider.d.ts +1 -1
  98. package/lib/processor/ColorInfoProvider.js +6 -9
  99. package/lib/processor/InlayHintProvider.d.ts +4 -3
  100. package/lib/processor/InlayHintProvider.js +1 -2
  101. package/lib/processor/SignatureHelpProvider.d.ts +4 -3
  102. package/lib/processor/SignatureHelpProvider.js +1 -2
  103. package/lib/processor/binder/Binder.d.ts +26 -0
  104. package/lib/processor/binder/Binder.js +18 -0
  105. package/lib/processor/binder/builtin.d.ts +27 -0
  106. package/lib/processor/binder/builtin.js +116 -0
  107. package/lib/processor/binder/index.d.ts +3 -0
  108. package/lib/processor/binder/index.js +3 -0
  109. package/lib/processor/checker/Checker.d.ts +2 -2
  110. package/lib/processor/checker/Checker.js +1 -5
  111. package/lib/processor/checker/builtin.d.ts +4 -4
  112. package/lib/processor/checker/builtin.js +22 -33
  113. package/lib/processor/checker/index.d.ts +2 -2
  114. package/lib/processor/checker/index.js +2 -31
  115. package/lib/processor/colorizer/Colorizer.d.ts +6 -5
  116. package/lib/processor/colorizer/Colorizer.js +8 -11
  117. package/lib/processor/colorizer/builtin.d.ts +3 -3
  118. package/lib/processor/colorizer/builtin.js +34 -46
  119. package/lib/processor/colorizer/index.d.ts +2 -2
  120. package/lib/processor/colorizer/index.js +2 -31
  121. package/lib/processor/completer/Completer.d.ts +6 -5
  122. package/lib/processor/completer/Completer.js +14 -33
  123. package/lib/processor/completer/builtin.d.ts +10 -9
  124. package/lib/processor/completer/builtin.js +47 -63
  125. package/lib/processor/completer/index.d.ts +2 -2
  126. package/lib/processor/completer/index.js +2 -31
  127. package/lib/processor/formatter/Formatter.d.ts +4 -3
  128. package/lib/processor/formatter/Formatter.js +2 -7
  129. package/lib/processor/formatter/builtin.d.ts +3 -3
  130. package/lib/processor/formatter/builtin.js +22 -36
  131. package/lib/processor/formatter/index.d.ts +2 -2
  132. package/lib/processor/formatter/index.js +2 -31
  133. package/lib/processor/index.d.ts +10 -9
  134. package/lib/processor/index.js +10 -25
  135. package/lib/processor/linter/Linter.d.ts +4 -3
  136. package/lib/processor/linter/Linter.js +1 -2
  137. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +2 -2
  138. package/lib/processor/linter/builtin/undeclaredSymbol.js +20 -24
  139. package/lib/processor/linter/builtin.d.ts +4 -3
  140. package/lib/processor/linter/builtin.js +19 -26
  141. package/lib/processor/linter/index.d.ts +2 -2
  142. package/lib/processor/linter/index.js +2 -31
  143. package/lib/processor/util.d.ts +4 -14
  144. package/lib/processor/util.js +1 -16
  145. package/lib/service/CacheService.d.ts +13 -8
  146. package/lib/service/CacheService.js +45 -57
  147. package/lib/service/Config.d.ts +11 -12
  148. package/lib/service/Config.js +50 -45
  149. package/lib/service/Context.d.ts +23 -20
  150. package/lib/service/Context.js +39 -36
  151. package/lib/service/Dependency.js +2 -5
  152. package/lib/service/Downloader.d.ts +9 -40
  153. package/lib/service/Downloader.js +37 -110
  154. package/lib/service/ErrorReporter.d.ts +2 -2
  155. package/lib/service/ErrorReporter.js +10 -14
  156. package/lib/service/FileService.d.ts +15 -14
  157. package/lib/service/FileService.js +55 -92
  158. package/lib/service/Hover.d.ts +2 -2
  159. package/lib/service/Hover.js +4 -7
  160. package/lib/service/MetaRegistry.d.ts +22 -12
  161. package/lib/service/MetaRegistry.js +81 -73
  162. package/lib/service/Profiler.d.ts +3 -2
  163. package/lib/service/Profiler.js +81 -45
  164. package/lib/service/Project.d.ts +105 -76
  165. package/lib/service/Project.js +449 -370
  166. package/lib/service/Service.d.ts +17 -27
  167. package/lib/service/Service.js +37 -43
  168. package/lib/service/SymbolLocations.d.ts +3 -3
  169. package/lib/service/SymbolLocations.js +4 -7
  170. package/lib/service/SymbolRegistrar.d.ts +1 -1
  171. package/lib/service/SymbolRegistrar.js +1 -2
  172. package/lib/service/UriProcessor.d.ts +5 -0
  173. package/lib/service/UriProcessor.js +2 -0
  174. package/lib/service/fileUtil.d.ts +15 -45
  175. package/lib/service/fileUtil.js +38 -143
  176. package/lib/service/index.d.ts +16 -17
  177. package/lib/service/index.js +16 -35
  178. package/lib/source/IndexMap.d.ts +1 -1
  179. package/lib/source/IndexMap.js +7 -10
  180. package/lib/source/LanguageError.d.ts +20 -6
  181. package/lib/source/LanguageError.js +16 -9
  182. package/lib/source/Location.d.ts +3 -3
  183. package/lib/source/Location.js +6 -9
  184. package/lib/source/Offset.d.ts +1 -1
  185. package/lib/source/Offset.js +4 -7
  186. package/lib/source/Position.js +2 -5
  187. package/lib/source/PositionRange.d.ts +3 -3
  188. package/lib/source/PositionRange.js +17 -20
  189. package/lib/source/Range.d.ts +1 -1
  190. package/lib/source/Range.js +7 -10
  191. package/lib/source/Source.d.ts +5 -3
  192. package/lib/source/Source.js +34 -29
  193. package/lib/source/index.d.ts +8 -8
  194. package/lib/source/index.js +8 -24
  195. package/lib/symbol/Symbol.d.ts +5 -4
  196. package/lib/symbol/Symbol.js +49 -65
  197. package/lib/symbol/SymbolUtil.d.ts +29 -31
  198. package/lib/symbol/SymbolUtil.js +178 -157
  199. package/lib/symbol/index.d.ts +2 -3
  200. package/lib/symbol/index.js +2 -19
  201. package/package.json +7 -4
  202. package/lib/service/Operations.d.ts +0 -8
  203. package/lib/service/Operations.js +0 -26
  204. package/lib/symbol/UriBinder.d.ts +0 -3
  205. package/lib/symbol/UriBinder.js +0 -3
@@ -1,41 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.fileUtil = void 0;
30
- const child_process_1 = __importDefault(require("child_process"));
31
- const fs_1 = require("fs");
32
- const path_1 = require("path");
33
- const process_1 = __importDefault(require("process"));
34
- const url_1 = __importStar(require("url"));
35
- const util_1 = require("util");
36
- const zlib_1 = __importDefault(require("zlib"));
37
- const common_1 = require("../common");
38
- var fileUtil;
1
+ import { bufferToString, Uri } from '../common/index.js';
2
+ export var fileUtil;
39
3
  (function (fileUtil) {
40
4
  /**
41
5
  * @param rootUris The root URIs. Each URI in this array must end with a slash (`/`).
@@ -106,53 +70,8 @@ var fileUtil;
106
70
  }
107
71
  fileUtil.basename = basename;
108
72
  /* istanbul ignore next */
109
- /**
110
- * @param fileUri A file URI.
111
- * @returns The corresponding file path of the `fileUri` in platform-specific format.
112
- * @throws If the URI is not a file schema URI.
113
- */
114
- function fileUriToPath(fileUri) {
115
- return url_1.default.fileURLToPath(new url_1.URL(fileUri));
116
- }
117
- fileUtil.fileUriToPath = fileUriToPath;
118
- /* istanbul ignore next */
119
- /**
120
- * @param path A file path.
121
- * @returns The corresponding file URI of the `path`.
122
- */
123
- function pathToFileUri(path) {
124
- return url_1.default.pathToFileURL(path).toString();
125
- }
126
- fileUtil.pathToFileUri = pathToFileUri;
127
- /* istanbul ignore next */
128
- function normalize(uri) {
129
- try {
130
- return isFileUri(uri) ? pathToFileUri(fileUriToPath(uri)) : new url_1.URL(uri).toString();
131
- }
132
- catch {
133
- return uri;
134
- }
135
- }
136
- fileUtil.normalize = normalize;
137
- /**
138
- * @param path A string file path, string file URI, or a file URI object.
139
- *
140
- * @returns A {@link fs.PathLike}.
141
- */
142
- function toFsPathLike(path) {
143
- if (typeof path === 'string' && isFileUri(path)) {
144
- return new url_1.URL(path);
145
- }
146
- return path;
147
- }
148
- /* istanbul ignore next */
149
- function getParentOfFile(path) {
150
- if (path instanceof url_1.URL || isFileUri(path)) {
151
- return new url_1.URL('.', path);
152
- }
153
- else {
154
- return (0, path_1.resolve)(path, '..');
155
- }
73
+ function getParentOfFile(externals, path) {
74
+ return new Uri('.', path);
156
75
  }
157
76
  fileUtil.getParentOfFile = getParentOfFile;
158
77
  /* istanbul ignore next */
@@ -161,12 +80,12 @@ var fileUtil;
161
80
  *
162
81
  * @param mode Default to `0o777` (`rwxrwxrwx`)
163
82
  */
164
- async function ensureDir(path, mode = 0o777) {
83
+ async function ensureDir(externals, path, mode = 0o777) {
165
84
  try {
166
- await fs_1.promises.mkdir(toFsPathLike(path), { mode, recursive: true });
85
+ await externals.fs.mkdir(path, { mode, recursive: true });
167
86
  }
168
87
  catch (e) {
169
- if (!(0, common_1.isErrorCode)(e, 'EEXIST')) {
88
+ if (!externals.error.isKind(e, 'EEXIST')) {
170
89
  throw e;
171
90
  }
172
91
  }
@@ -180,31 +99,31 @@ var fileUtil;
180
99
  *
181
100
  * @param mode Default to `0o777` (`rwxrwxrwx`)
182
101
  */
183
- async function ensureParentOfFile(path, mode = 0o777) {
184
- return ensureDir(getParentOfFile(path), mode);
102
+ async function ensureParentOfFile(externals, path, mode = 0o777) {
103
+ return ensureDir(externals, getParentOfFile(externals, path), mode);
185
104
  }
186
105
  fileUtil.ensureParentOfFile = ensureParentOfFile;
187
- async function chmod(path, mode) {
188
- return fs_1.promises.chmod(toFsPathLike(path), mode);
106
+ async function chmod(externals, path, mode) {
107
+ return externals.fs.chmod(path, mode);
189
108
  }
190
109
  fileUtil.chmod = chmod;
191
- async function ensureWritable(path) {
110
+ async function ensureWritable(externals, path) {
192
111
  try {
193
- await chmod(path, 0o666);
112
+ await chmod(externals, path, 0o666);
194
113
  }
195
114
  catch (e) {
196
- if (!(0, common_1.isEnoent)(e)) {
115
+ if (!externals.error.isKind(e, 'ENOENT')) {
197
116
  throw e;
198
117
  }
199
118
  }
200
119
  }
201
120
  fileUtil.ensureWritable = ensureWritable;
202
- async function markReadOnly(path) {
203
- return chmod(path, 0o444);
121
+ async function markReadOnly(externals, path) {
122
+ return chmod(externals, path, 0o444);
204
123
  }
205
124
  fileUtil.markReadOnly = markReadOnly;
206
- async function readFile(path) {
207
- return fs_1.promises.readFile(toFsPathLike(path));
125
+ async function readFile(externals, path) {
126
+ return externals.fs.readFile(path);
208
127
  }
209
128
  fileUtil.readFile = readFile;
210
129
  /* istanbul ignore next */
@@ -220,18 +139,18 @@ var fileUtil;
220
139
  * * Mode: `0o666` (`rw-rw-rw-`)
221
140
  * * Flag: `w`
222
141
  */
223
- async function writeFile(path, data, mode = 0o666) {
224
- await ensureParentOfFile(path);
225
- await ensureWritable(path);
226
- return fs_1.promises.writeFile(toFsPathLike(path), data, { mode });
142
+ async function writeFile(externals, path, data, mode = 0o666) {
143
+ await ensureParentOfFile(externals, path);
144
+ await ensureWritable(externals, path);
145
+ return externals.fs.writeFile(path, data, { mode });
227
146
  }
228
147
  fileUtil.writeFile = writeFile;
229
148
  /* istanbul ignore next */
230
149
  /**
231
150
  * @throws
232
151
  */
233
- async function readJson(path) {
234
- return JSON.parse((0, common_1.bufferToString)(await readFile(path)));
152
+ async function readJson(externals, path) {
153
+ return JSON.parse(bufferToString(await readFile(externals, path)));
235
154
  }
236
155
  fileUtil.readJson = readJson;
237
156
  /* istanbul ignore next */
@@ -240,64 +159,40 @@ var fileUtil;
240
159
  *
241
160
  * @see {@link writeFile}
242
161
  */
243
- async function writeJson(path, data) {
244
- return writeFile(path, JSON.stringify(data));
162
+ async function writeJson(externals, path, data) {
163
+ return writeFile(externals, path, JSON.stringify(data));
245
164
  }
246
165
  fileUtil.writeJson = writeJson;
247
166
  /**
248
167
  * @throws
249
168
  */
250
- async function readGzippedFile(path) {
251
- const unzip = (0, util_1.promisify)(zlib_1.default.gunzip);
252
- return unzip(await readFile(path));
169
+ async function readGzippedFile(externals, path) {
170
+ return externals.archive.gunzip(await readFile(externals, path));
253
171
  }
254
172
  fileUtil.readGzippedFile = readGzippedFile;
255
173
  /**
256
174
  * @throws
257
175
  */
258
- async function writeGzippedFile(path, buffer) {
259
- const zip = (0, util_1.promisify)(zlib_1.default.gzip);
260
- return writeFile(path, await zip(buffer));
176
+ async function writeGzippedFile(externals, path, buffer) {
177
+ if (typeof buffer === 'string') {
178
+ buffer = new TextEncoder().encode(buffer);
179
+ }
180
+ return writeFile(externals, path, await externals.archive.gzip(buffer));
261
181
  }
262
182
  fileUtil.writeGzippedFile = writeGzippedFile;
263
183
  /**
264
184
  * @throws
265
185
  */
266
- async function readGzippedJson(path) {
267
- return JSON.parse((0, common_1.bufferToString)(await readGzippedFile(path)));
186
+ async function readGzippedJson(externals, path) {
187
+ return JSON.parse(bufferToString(await readGzippedFile(externals, path)));
268
188
  }
269
189
  fileUtil.readGzippedJson = readGzippedJson;
270
190
  /**
271
191
  * @throws
272
192
  */
273
- async function writeGzippedJson(path, data) {
274
- return writeGzippedFile(path, JSON.stringify(data));
193
+ async function writeGzippedJson(externals, path, data) {
194
+ return writeGzippedFile(externals, path, JSON.stringify(data));
275
195
  }
276
196
  fileUtil.writeGzippedJson = writeGzippedJson;
277
- /**
278
- * Show the file/directory in the platform-specific explorer program.
279
- *
280
- * Should not be called with unsanitized user-input path due to the possibility of
281
- * arbitrary code execution.
282
- *
283
- * @returns The `stdout` from the spawned child process.
284
- */
285
- async function showFile(path) {
286
- const execFile = (0, util_1.promisify)(child_process_1.default.execFile);
287
- let command;
288
- switch (process_1.default.platform) {
289
- case 'darwin':
290
- command = 'open';
291
- break;
292
- case 'win32':
293
- command = 'explorer';
294
- break;
295
- default:
296
- command = 'xdg-open';
297
- break;
298
- }
299
- return execFile(command, [path]);
300
- }
301
- fileUtil.showFile = showFile;
302
- })(fileUtil = exports.fileUtil || (exports.fileUtil = {}));
197
+ })(fileUtil || (fileUtil = {}));
303
198
  //# sourceMappingURL=fileUtil.js.map
@@ -1,18 +1,17 @@
1
- export * from './CacheService';
2
- export * from './Config';
3
- export * from './Context';
4
- export * from './Dependency';
5
- export * from './Downloader';
6
- export * from './ErrorReporter';
7
- export { FileService, UriProtocolSupporter } from './FileService';
8
- export * from './fileUtil';
9
- export * from './Hover';
10
- export * from './Logger';
11
- export * from './MetaRegistry';
12
- export * from './Operations';
13
- export * from './Profiler';
14
- export * from './Project';
15
- export * from './Service';
16
- export * from './SymbolLocations';
17
- export * from './SymbolRegistrar';
1
+ export * from './CacheService.js';
2
+ export * from './Config.js';
3
+ export * from './Context.js';
4
+ export * from './Dependency.js';
5
+ export * from './Downloader.js';
6
+ export * from './ErrorReporter.js';
7
+ export { FileService, UriProtocolSupporter } from './FileService.js';
8
+ export * from './fileUtil.js';
9
+ export * from './Hover.js';
10
+ export * from './MetaRegistry.js';
11
+ export * from './Profiler.js';
12
+ export * from './Project.js';
13
+ export * from './Service.js';
14
+ export * from './SymbolLocations.js';
15
+ export * from './SymbolRegistrar.js';
16
+ export * from './UriProcessor.js';
18
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,37 +1,18 @@
1
- "use strict";
2
1
  /* istanbul ignore file */
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.FileService = void 0;
19
- __exportStar(require("./CacheService"), exports);
20
- __exportStar(require("./Config"), exports);
21
- __exportStar(require("./Context"), exports);
22
- __exportStar(require("./Dependency"), exports);
23
- __exportStar(require("./Downloader"), exports);
24
- __exportStar(require("./ErrorReporter"), exports);
25
- var FileService_1 = require("./FileService");
26
- Object.defineProperty(exports, "FileService", { enumerable: true, get: function () { return FileService_1.FileService; } });
27
- __exportStar(require("./fileUtil"), exports);
28
- __exportStar(require("./Hover"), exports);
29
- __exportStar(require("./Logger"), exports);
30
- __exportStar(require("./MetaRegistry"), exports);
31
- __exportStar(require("./Operations"), exports);
32
- __exportStar(require("./Profiler"), exports);
33
- __exportStar(require("./Project"), exports);
34
- __exportStar(require("./Service"), exports);
35
- __exportStar(require("./SymbolLocations"), exports);
36
- __exportStar(require("./SymbolRegistrar"), exports);
2
+ export * from './CacheService.js';
3
+ export * from './Config.js';
4
+ export * from './Context.js';
5
+ export * from './Dependency.js';
6
+ export * from './Downloader.js';
7
+ export * from './ErrorReporter.js';
8
+ export { FileService } from './FileService.js';
9
+ export * from './fileUtil.js';
10
+ export * from './Hover.js';
11
+ export * from './MetaRegistry.js';
12
+ export * from './Profiler.js';
13
+ export * from './Project.js';
14
+ export * from './Service.js';
15
+ export * from './SymbolLocations.js';
16
+ export * from './SymbolRegistrar.js';
17
+ export * from './UriProcessor.js';
37
18
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { Range } from './Range';
1
+ import { Range } from './Range.js';
2
2
  /**
3
3
  * The pairs should be in ascending order.
4
4
  */
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IndexMap = void 0;
4
- const Range_1 = require("./Range");
5
- var IndexMap;
1
+ import { Range } from './Range.js';
2
+ export var IndexMap;
6
3
  (function (IndexMap) {
7
4
  function convertOffset(map, offset, from, to, isEndOffset) {
8
5
  let ans = offset;
9
6
  for (const pair of map) {
10
- if (Range_1.Range.contains(pair[from], offset, isEndOffset)) {
7
+ if (Range.contains(pair[from], offset, isEndOffset)) {
11
8
  return isEndOffset ? pair[to].end : pair[to].start;
12
9
  }
13
- else if (Range_1.Range.endsBefore(pair[from], offset)) {
10
+ else if (Range.endsBefore(pair[from], offset)) {
14
11
  ans = offset - pair[from].end + pair[to].end;
15
12
  }
16
13
  else {
@@ -24,7 +21,7 @@ var IndexMap;
24
21
  }
25
22
  IndexMap.toInnerOffset = toInnerOffset;
26
23
  function toInnerRange(map, outer) {
27
- return Range_1.Range.create(toInnerOffset(map, outer.start), convertOffset(map, outer.end, 'outer', 'inner', true));
24
+ return Range.create(toInnerOffset(map, outer.start), convertOffset(map, outer.end, 'outer', 'inner', true));
28
25
  }
29
26
  IndexMap.toInnerRange = toInnerRange;
30
27
  function toOuterOffset(map, offset) {
@@ -32,7 +29,7 @@ var IndexMap;
32
29
  }
33
30
  IndexMap.toOuterOffset = toOuterOffset;
34
31
  function toOuterRange(map, inner) {
35
- return Range_1.Range.create(toOuterOffset(map, inner.start), convertOffset(map, inner.end, 'inner', 'outer', true));
32
+ return Range.create(toOuterOffset(map, inner.start), convertOffset(map, inner.end, 'inner', 'outer', true));
36
33
  }
37
34
  IndexMap.toOuterRange = toOuterRange;
38
35
  function merge(outerMap, innerMap) {
@@ -42,5 +39,5 @@ var IndexMap;
42
39
  }));
43
40
  }
44
41
  IndexMap.merge = merge;
45
- })(IndexMap = exports.IndexMap || (exports.IndexMap = {}));
42
+ })(IndexMap || (IndexMap = {}));
46
43
  //# sourceMappingURL=IndexMap.js.map
@@ -1,14 +1,28 @@
1
- import type { Location } from './Location';
2
- import type { Range } from './Range';
3
- export interface LanguageError {
1
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
2
+ import type { Location } from './Location.js';
3
+ import { PositionRange } from './PositionRange.js';
4
+ import type { Range } from './Range.js';
5
+ export interface LanguageErrorData {
4
6
  message: string;
5
- range: Range;
6
7
  severity: ErrorSeverity;
7
8
  info?: LanguageErrorInfo;
8
9
  }
9
- export declare namespace LanguageError {
10
- function create(message: string, range: Range, severity?: ErrorSeverity, info?: LanguageErrorInfo): LanguageError;
10
+ export interface LanguageError extends LanguageErrorData {
11
+ range: Range;
12
+ }
13
+ /**
14
+ * A language error that uses {@link PositionRange} instead of {@link Range} to represent the span of the error.
15
+ */
16
+ export interface PosRangeLanguageError extends LanguageErrorData {
17
+ posRange: PositionRange;
11
18
  }
19
+ export declare const LanguageError: Readonly<{
20
+ create(message: string, range: Range, severity?: ErrorSeverity, info?: LanguageErrorInfo): LanguageError;
21
+ /**
22
+ * @returns A {@link PosRangeLanguageError}.
23
+ */
24
+ withPosRange(error: LanguageError, doc: TextDocument): PosRangeLanguageError;
25
+ }>;
12
26
  export declare const enum ErrorSeverity {
13
27
  Hint = 0,
14
28
  Information = 1,
@@ -1,15 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LanguageError = void 0;
4
- var LanguageError;
5
- (function (LanguageError) {
6
- function create(message, range, severity = 3 /* ErrorSeverity.Error */, info) {
1
+ import { PositionRange } from './PositionRange.js';
2
+ export const LanguageError = Object.freeze({
3
+ create(message, range, severity = 3 /* ErrorSeverity.Error */, info) {
7
4
  const ans = { range, message, severity };
8
5
  if (info) {
9
6
  ans.info = info;
10
7
  }
11
8
  return ans;
12
- }
13
- LanguageError.create = create;
14
- })(LanguageError = exports.LanguageError || (exports.LanguageError = {}));
9
+ },
10
+ /**
11
+ * @returns A {@link PosRangeLanguageError}.
12
+ */
13
+ withPosRange(error, doc) {
14
+ return {
15
+ posRange: PositionRange.from(error.range, doc),
16
+ message: error.message,
17
+ severity: error.severity,
18
+ ...error.info && { info: error.info },
19
+ };
20
+ },
21
+ });
15
22
  //# sourceMappingURL=LanguageError.js.map
@@ -1,7 +1,7 @@
1
1
  import type { TextDocument } from 'vscode-languageserver-textdocument';
2
- import { PositionRange } from './PositionRange';
3
- import type { RangeLike } from './Range';
4
- import { Range } from './Range';
2
+ import { PositionRange } from './PositionRange.js';
3
+ import type { RangeLike } from './Range.js';
4
+ import { Range } from './Range.js';
5
5
  export interface Location {
6
6
  uri: string;
7
7
  range: Range;
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Location = void 0;
4
- const PositionRange_1 = require("./PositionRange");
5
- const Range_1 = require("./Range");
6
- var Location;
1
+ import { PositionRange } from './PositionRange.js';
2
+ import { Range } from './Range.js';
3
+ export var Location;
7
4
  (function (Location) {
8
5
  function get(partial) {
9
6
  return {
10
7
  uri: partial.uri ?? '',
11
- range: Range_1.Range.get(partial.range ?? { start: 0, end: 0 }),
8
+ range: Range.get(partial.range ?? { start: 0, end: 0 }),
12
9
  posRange: partial.posRange ?? { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
13
10
  };
14
11
  }
@@ -17,9 +14,9 @@ var Location;
17
14
  return Location.get({
18
15
  uri: doc.uri,
19
16
  range,
20
- posRange: PositionRange_1.PositionRange.from(range, doc),
17
+ posRange: PositionRange.from(range, doc),
21
18
  });
22
19
  }
23
20
  Location.create = create;
24
- })(Location = exports.Location || (exports.Location = {}));
21
+ })(Location || (Location = {}));
25
22
  //# sourceMappingURL=Location.js.map
@@ -1,4 +1,4 @@
1
- import { ReadonlySource } from './Source';
1
+ import { ReadonlySource } from './Source.js';
2
2
  export declare type OffsetLike = number | ReadonlySource | ((this: void) => number | ReadonlySource);
3
3
  export declare namespace Offset {
4
4
  /**
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Offset = void 0;
4
- const Source_1 = require("./Source");
5
- var Offset;
1
+ import { ReadonlySource } from './Source.js';
2
+ export var Offset;
6
3
  (function (Offset) {
7
4
  /**
8
5
  * Get an offset from a `OffsetLike`.
@@ -15,11 +12,11 @@ var Offset;
15
12
  if (typeof offset === 'function') {
16
13
  offset = offset();
17
14
  }
18
- if (offset instanceof Source_1.ReadonlySource) {
15
+ if (offset instanceof ReadonlySource) {
19
16
  offset = offset.cursor;
20
17
  }
21
18
  return offset;
22
19
  }
23
20
  Offset.get = get;
24
- })(Offset = exports.Offset || (exports.Offset = {}));
21
+ })(Offset || (Offset = {}));
25
22
  //# sourceMappingURL=Offset.js.map
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Position = void 0;
4
- var Position;
1
+ export var Position;
5
2
  (function (Position) {
6
3
  function create(param1, param2) {
7
4
  if (typeof param1 === 'object') {
@@ -39,5 +36,5 @@ var Position;
39
36
  (pos1.line === pos2.line && pos1.character < pos2.character));
40
37
  }
41
38
  Position.isBefore = isBefore;
42
- })(Position = exports.Position || (exports.Position = {}));
39
+ })(Position || (Position = {}));
43
40
  //# sourceMappingURL=Position.js.map
@@ -1,6 +1,6 @@
1
1
  import type { TextDocument } from 'vscode-languageserver-textdocument';
2
- import { Position } from './Position';
3
- import type { RangeLike } from './Range';
2
+ import { Position } from './Position.js';
3
+ import type { RangeLike } from './Range.js';
4
4
  export interface PositionRange {
5
5
  start: Position;
6
6
  end: Position;
@@ -12,7 +12,7 @@ export declare namespace PositionRange {
12
12
  /**
13
13
  * @returns A `PositionRange` converted from a `RangeLike`.
14
14
  */
15
- function from(range: RangeLike, doc: TextDocument): PositionRange;
15
+ function from(rangeLike: RangeLike, doc: TextDocument): PositionRange;
16
16
  /**
17
17
  * ```typescript
18
18
  * {
@@ -1,28 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PositionRange = void 0;
4
- const Position_1 = require("./Position");
5
- const Range_1 = require("./Range");
6
- var PositionRange;
1
+ import { Position } from './Position.js';
2
+ import { Range } from './Range.js';
3
+ export var PositionRange;
7
4
  (function (PositionRange) {
8
5
  function create(param1, param2, param3, param4) {
9
6
  if (typeof param1 === 'number') {
10
7
  return {
11
- start: Position_1.Position.create(param1, param2),
12
- end: Position_1.Position.create(param3, param4),
8
+ start: Position.create(param1, param2),
9
+ end: Position.create(param3, param4),
13
10
  };
14
11
  }
15
12
  else if (param2 !== undefined) {
16
13
  return {
17
- start: Position_1.Position.create(param1),
18
- end: Position_1.Position.create(param2),
14
+ start: Position.create(param1),
15
+ end: Position.create(param2),
19
16
  };
20
17
  }
21
18
  else {
22
19
  const partial = param1;
23
20
  return {
24
- start: Position_1.Position.create(partial.start ?? {}),
25
- end: Position_1.Position.create(partial.end ?? {}),
21
+ start: Position.create(partial.start ?? {}),
22
+ end: Position.create(partial.end ?? {}),
26
23
  };
27
24
  }
28
25
  }
@@ -30,11 +27,11 @@ var PositionRange;
30
27
  /**
31
28
  * @returns A `PositionRange` converted from a `RangeLike`.
32
29
  */
33
- function from(range, doc) {
34
- const _range = Range_1.Range.get(range);
30
+ function from(rangeLike, doc) {
31
+ const range = Range.get(rangeLike);
35
32
  const ans = {
36
- start: doc.positionAt(_range.start),
37
- end: doc.positionAt(_range.end),
33
+ start: doc.positionAt(range.start),
34
+ end: doc.positionAt(range.end),
38
35
  };
39
36
  return ans;
40
37
  }
@@ -56,9 +53,9 @@ var PositionRange;
56
53
  * }
57
54
  * ```
58
55
  */
59
- PositionRange.Full = Object.freeze(PositionRange.create(Position_1.Position.Beginning, Position_1.Position.Infinity));
56
+ PositionRange.Full = Object.freeze(PositionRange.create(Position.Beginning, Position.Infinity));
60
57
  function toString(range) {
61
- return `[${Position_1.Position.toString(range.start)}, ${Position_1.Position.toString(range.end)})`;
58
+ return `[${Position.toString(range.start)}, ${Position.toString(range.end)})`;
62
59
  }
63
60
  PositionRange.toString = toString;
64
61
  function contains(range, pos) {
@@ -76,8 +73,8 @@ var PositionRange;
76
73
  }
77
74
  PositionRange.contains = contains;
78
75
  function endsBefore(range, pos) {
79
- return Position_1.Position.isBefore(Position_1.Position.create(range.end.line, range.end.character - 1), pos);
76
+ return Position.isBefore(Position.create(range.end.line, range.end.character - 1), pos);
80
77
  }
81
78
  PositionRange.endsBefore = endsBefore;
82
- })(PositionRange = exports.PositionRange || (exports.PositionRange = {}));
79
+ })(PositionRange || (PositionRange = {}));
83
80
  //# sourceMappingURL=PositionRange.js.map