@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.
Files changed (186) hide show
  1. package/README.md +10 -0
  2. package/lib/common/Heap.d.ts +1 -0
  3. package/lib/common/Heap.js +2 -0
  4. package/lib/common/index.d.ts +2 -0
  5. package/lib/common/index.js +14 -0
  6. package/lib/common/util.d.ts +120 -0
  7. package/lib/common/util.js +292 -0
  8. package/lib/index.d.ts +8 -0
  9. package/lib/index.js +20 -0
  10. package/lib/node/AstNode.d.ts +64 -0
  11. package/lib/node/AstNode.js +108 -0
  12. package/lib/node/BooleanNode.d.ts +13 -0
  13. package/lib/node/BooleanNode.js +20 -0
  14. package/lib/node/CommentNode.d.ts +12 -0
  15. package/lib/node/CommentNode.js +11 -0
  16. package/lib/node/ErrorNode.d.ts +8 -0
  17. package/lib/node/ErrorNode.js +12 -0
  18. package/lib/node/FileNode.d.ts +21 -0
  19. package/lib/node/FileNode.js +11 -0
  20. package/lib/node/FloatNode.d.ts +13 -0
  21. package/lib/node/FloatNode.js +21 -0
  22. package/lib/node/IntegerNode.d.ts +13 -0
  23. package/lib/node/IntegerNode.js +20 -0
  24. package/lib/node/ListNode.d.ts +15 -0
  25. package/lib/node/ListNode.js +11 -0
  26. package/lib/node/LiteralNode.d.ts +19 -0
  27. package/lib/node/LiteralNode.js +22 -0
  28. package/lib/node/LongNode.d.ts +13 -0
  29. package/lib/node/LongNode.js +20 -0
  30. package/lib/node/RecordNode.d.ts +20 -0
  31. package/lib/node/RecordNode.js +11 -0
  32. package/lib/node/ResourceLocationNode.d.ts +41 -0
  33. package/lib/node/ResourceLocationNode.js +65 -0
  34. package/lib/node/Sequence.d.ts +22 -0
  35. package/lib/node/Sequence.js +11 -0
  36. package/lib/node/StringNode.d.ts +63 -0
  37. package/lib/node/StringNode.js +43 -0
  38. package/lib/node/SymbolNode.d.ts +21 -0
  39. package/lib/node/SymbolNode.js +22 -0
  40. package/lib/node/TableNode.d.ts +17 -0
  41. package/lib/node/TableNode.js +11 -0
  42. package/lib/node/index.d.ts +16 -0
  43. package/lib/node/index.js +28 -0
  44. package/lib/parser/Parser.d.ts +16 -0
  45. package/lib/parser/Parser.js +5 -0
  46. package/lib/parser/boolean.d.ts +4 -0
  47. package/lib/parser/boolean.js +11 -0
  48. package/lib/parser/comment.d.ts +12 -0
  49. package/lib/parser/comment.js +34 -0
  50. package/lib/parser/empty.d.ts +3 -0
  51. package/lib/parser/empty.js +7 -0
  52. package/lib/parser/error.d.ts +8 -0
  53. package/lib/parser/error.js +22 -0
  54. package/lib/parser/file.d.ts +9 -0
  55. package/lib/parser/file.js +37 -0
  56. package/lib/parser/float.d.ts +33 -0
  57. package/lib/parser/float.js +57 -0
  58. package/lib/parser/index.d.ts +17 -0
  59. package/lib/parser/index.js +36 -0
  60. package/lib/parser/integer.d.ts +33 -0
  61. package/lib/parser/integer.js +46 -0
  62. package/lib/parser/list.d.ts +12 -0
  63. package/lib/parser/list.js +70 -0
  64. package/lib/parser/literal.d.ts +5 -0
  65. package/lib/parser/literal.js +41 -0
  66. package/lib/parser/long.d.ts +33 -0
  67. package/lib/parser/long.js +50 -0
  68. package/lib/parser/record.d.ts +22 -0
  69. package/lib/parser/record.js +97 -0
  70. package/lib/parser/resourceLocation.d.ts +4 -0
  71. package/lib/parser/resourceLocation.js +67 -0
  72. package/lib/parser/string.d.ts +18 -0
  73. package/lib/parser/string.js +129 -0
  74. package/lib/parser/symbol.d.ts +12 -0
  75. package/lib/parser/symbol.js +33 -0
  76. package/lib/parser/table.d.ts +22 -0
  77. package/lib/parser/table.js +97 -0
  78. package/lib/parser/util.d.ts +134 -0
  79. package/lib/parser/util.js +224 -0
  80. package/lib/processor/ColorInfoProvider.d.ts +87 -0
  81. package/lib/processor/ColorInfoProvider.js +141 -0
  82. package/lib/processor/InlayHintProvider.d.ts +8 -0
  83. package/lib/processor/InlayHintProvider.js +3 -0
  84. package/lib/processor/SignatureHelpProvider.d.ts +18 -0
  85. package/lib/processor/SignatureHelpProvider.js +3 -0
  86. package/lib/processor/checker/Checker.d.ts +7 -0
  87. package/lib/processor/checker/Checker.js +7 -0
  88. package/lib/processor/checker/builtin.d.ts +23 -0
  89. package/lib/processor/checker/builtin.js +83 -0
  90. package/lib/processor/checker/index.d.ts +3 -0
  91. package/lib/processor/checker/index.js +28 -0
  92. package/lib/processor/colorizer/Colorizer.d.ts +23 -0
  93. package/lib/processor/colorizer/Colorizer.js +70 -0
  94. package/lib/processor/colorizer/builtin.d.ts +17 -0
  95. package/lib/processor/colorizer/builtin.js +84 -0
  96. package/lib/processor/colorizer/index.d.ts +3 -0
  97. package/lib/processor/colorizer/index.js +28 -0
  98. package/lib/processor/completer/Completer.d.ts +75 -0
  99. package/lib/processor/completer/Completer.js +92 -0
  100. package/lib/processor/completer/builtin.d.ts +30 -0
  101. package/lib/processor/completer/builtin.js +172 -0
  102. package/lib/processor/completer/index.d.ts +3 -0
  103. package/lib/processor/completer/index.js +28 -0
  104. package/lib/processor/formatter/Formatter.d.ts +6 -0
  105. package/lib/processor/formatter/Formatter.js +19 -0
  106. package/lib/processor/formatter/builtin.d.ts +15 -0
  107. package/lib/processor/formatter/builtin.js +60 -0
  108. package/lib/processor/formatter/index.d.ts +3 -0
  109. package/lib/processor/formatter/index.js +28 -0
  110. package/lib/processor/index.d.ts +10 -0
  111. package/lib/processor/index.js +22 -0
  112. package/lib/processor/linter/Linter.d.ts +4 -0
  113. package/lib/processor/linter/Linter.js +3 -0
  114. package/lib/processor/linter/builtin/undeclaredSymbol.d.ts +4 -0
  115. package/lib/processor/linter/builtin/undeclaredSymbol.js +73 -0
  116. package/lib/processor/linter/builtin.d.ts +15 -0
  117. package/lib/processor/linter/builtin.js +120 -0
  118. package/lib/processor/linter/index.d.ts +3 -0
  119. package/lib/processor/linter/index.js +28 -0
  120. package/lib/processor/util.d.ts +17 -0
  121. package/lib/processor/util.js +32 -0
  122. package/lib/service/CacheService.d.ts +54 -0
  123. package/lib/service/CacheService.js +195 -0
  124. package/lib/service/CommandExecutor.d.ts +3 -0
  125. package/lib/service/CommandExecutor.js +7 -0
  126. package/lib/service/Config.d.ts +218 -0
  127. package/lib/service/Config.js +264 -0
  128. package/lib/service/Context.d.ts +143 -0
  129. package/lib/service/Context.js +143 -0
  130. package/lib/service/Dependency.d.ts +10 -0
  131. package/lib/service/Dependency.js +11 -0
  132. package/lib/service/Downloader.d.ts +67 -0
  133. package/lib/service/Downloader.js +185 -0
  134. package/lib/service/ErrorReporter.d.ts +27 -0
  135. package/lib/service/ErrorReporter.js +49 -0
  136. package/lib/service/FileService.d.ts +96 -0
  137. package/lib/service/FileService.js +224 -0
  138. package/lib/service/Hover.d.ts +10 -0
  139. package/lib/service/Hover.js +16 -0
  140. package/lib/service/Logger.d.ts +31 -0
  141. package/lib/service/Logger.js +30 -0
  142. package/lib/service/MetaRegistry.d.ts +106 -0
  143. package/lib/service/MetaRegistry.js +192 -0
  144. package/lib/service/Operations.d.ts +8 -0
  145. package/lib/service/Operations.js +26 -0
  146. package/lib/service/Profiler.d.ts +33 -0
  147. package/lib/service/Profiler.js +76 -0
  148. package/lib/service/Project.d.ts +173 -0
  149. package/lib/service/Project.js +593 -0
  150. package/lib/service/Service.d.ts +55 -0
  151. package/lib/service/Service.js +207 -0
  152. package/lib/service/SymbolLocations.d.ts +17 -0
  153. package/lib/service/SymbolLocations.js +16 -0
  154. package/lib/service/SymbolRegistrar.d.ts +5 -0
  155. package/lib/service/SymbolRegistrar.js +3 -0
  156. package/lib/service/fileUtil.d.ts +121 -0
  157. package/lib/service/fileUtil.js +268 -0
  158. package/lib/service/index.d.ts +18 -0
  159. package/lib/service/index.js +33 -0
  160. package/lib/source/IndexMap.d.ts +16 -0
  161. package/lib/source/IndexMap.js +46 -0
  162. package/lib/source/LanguageError.d.ts +27 -0
  163. package/lib/source/LanguageError.js +15 -0
  164. package/lib/source/Location.d.ts +19 -0
  165. package/lib/source/Location.js +25 -0
  166. package/lib/source/Offset.d.ts +13 -0
  167. package/lib/source/Offset.js +25 -0
  168. package/lib/source/Position.d.ts +23 -0
  169. package/lib/source/Position.js +43 -0
  170. package/lib/source/PositionRange.d.ts +38 -0
  171. package/lib/source/PositionRange.js +83 -0
  172. package/lib/source/Range.d.ts +68 -0
  173. package/lib/source/Range.js +155 -0
  174. package/lib/source/Source.d.ts +110 -0
  175. package/lib/source/Source.js +222 -0
  176. package/lib/source/index.d.ts +9 -0
  177. package/lib/source/index.js +21 -0
  178. package/lib/symbol/Symbol.d.ts +219 -0
  179. package/lib/symbol/Symbol.js +324 -0
  180. package/lib/symbol/SymbolUtil.d.ts +407 -0
  181. package/lib/symbol/SymbolUtil.js +880 -0
  182. package/lib/symbol/UriBinder.d.ts +3 -0
  183. package/lib/symbol/UriBinder.js +3 -0
  184. package/lib/symbol/index.d.ts +4 -0
  185. package/lib/symbol/index.js +16 -0
  186. package/package.json +41 -0
@@ -0,0 +1,96 @@
1
+ /// <reference types="node" />
2
+ import type { Dependency } from './Dependency';
3
+ import type { RootUriString } from './fileUtil';
4
+ import type { Logger } from './Logger';
5
+ export interface UriProtocolSupporter {
6
+ /**
7
+ * @throws
8
+ *
9
+ * @returns A hash created from the content of the item at `uri`. This hash is used by the cache invalidation
10
+ * mechanism to check if an item has been modified, therefore it doesn't need to use a super duper secure hash
11
+ * algorithm. Algorithms like SHA-1 or MD5 should be good enough.
12
+ */
13
+ hash(uri: string): Promise<string>;
14
+ /**
15
+ * @param uri A file URI.
16
+ * @returns The content of the file at `uri`.
17
+ * @throws If the URI doesn't exist in the file system.
18
+ */
19
+ readFile(uri: string): Promise<Buffer>;
20
+ listFiles(): Iterable<string>;
21
+ /**
22
+ * Each URI in this array must end with a slash (`/`).
23
+ */
24
+ listRoots(): Iterable<RootUriString>;
25
+ }
26
+ declare type Protocol = `${string}:`;
27
+ export interface FileService extends UriProtocolSupporter {
28
+ /**
29
+ * @param protocol A protocol of URI, including the colon. e.g. `file:`.
30
+ * @param supporter The supporter for that `protocol`.
31
+ * @param force If the protocol is already supported, whether to override it or not.
32
+ *
33
+ * @throws If `protocol` is already registered, unless `force` is set to `true`.
34
+ */
35
+ register(protocol: Protocol, supporter: UriProtocolSupporter, force?: boolean): void;
36
+ /**
37
+ * Unregister the supported associated with `protocol`. Nothing happens if the `protocol` isn't supported.
38
+ */
39
+ unregister(protocol: Protocol): void;
40
+ }
41
+ export declare namespace FileService {
42
+ function create(): FileService;
43
+ }
44
+ export declare class FileServiceImpl implements FileService {
45
+ private readonly supporters;
46
+ register(protocol: Protocol, supporter: UriProtocolSupporter, force?: boolean): void;
47
+ unregister(protocol: Protocol): void;
48
+ /**
49
+ * @throws If the protocol of `uri` isn't supported.
50
+ *
51
+ * @returns The protocol if it's supported.
52
+ */
53
+ private getSupportedProtocol;
54
+ /**
55
+ * @throws
56
+ */
57
+ hash(uri: string): Promise<string>;
58
+ /**
59
+ * @throws
60
+ */
61
+ readFile(uri: string): Promise<Buffer>;
62
+ listFiles(): Generator<string, void, undefined>;
63
+ listRoots(): Generator<`${string}/`, void, undefined>;
64
+ }
65
+ export declare class FileUriSupporter implements UriProtocolSupporter {
66
+ private readonly roots;
67
+ private readonly files;
68
+ readonly protocol = "file:";
69
+ private constructor();
70
+ hash(uri: string): Promise<string>;
71
+ readFile(uri: string): Promise<Buffer>;
72
+ listFiles(): Generator<string, void, undefined>;
73
+ listRoots(): `${string}/`[];
74
+ private static rootUriToGlob;
75
+ static create(dependencies: readonly Dependency[], logger: Logger): Promise<FileUriSupporter>;
76
+ }
77
+ export declare class SpyglassUriSupporter implements UriProtocolSupporter {
78
+ private readonly entries;
79
+ readonly protocol = "spyglassmc:";
80
+ private static readonly SupportedArchiveExtnames;
81
+ /**
82
+ * @param entries A map from archive URIs to unzipped entries.
83
+ */
84
+ private constructor();
85
+ hash(uri: string): Promise<string>;
86
+ readFile(uri: string): Promise<Buffer>;
87
+ /**
88
+ * @throws
89
+ */
90
+ private getDataInArchive;
91
+ listFiles(): Generator<string, void, unknown>;
92
+ listRoots(): Generator<`${string}/`, void, unknown>;
93
+ static create(dependencies: readonly Dependency[], logger: Logger, checksums: Record<RootUriString, string>): Promise<SpyglassUriSupporter>;
94
+ }
95
+ export {};
96
+ //# sourceMappingURL=FileService.d.ts.map
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ /* istanbul ignore file */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6
+ }) : (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ o[k2] = m[k];
9
+ }));
10
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
11
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
12
+ }) : function(o, v) {
13
+ o["default"] = v;
14
+ });
15
+ var __importStar = (this && this.__importStar) || function (mod) {
16
+ if (mod && mod.__esModule) return mod;
17
+ var result = {};
18
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
19
+ __setModuleDefault(result, mod);
20
+ return result;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SpyglassUriSupporter = exports.FileUriSupporter = exports.FileServiceImpl = exports.FileService = void 0;
27
+ const crypto_1 = __importDefault(require("crypto"));
28
+ const decompress_1 = __importDefault(require("decompress"));
29
+ const fs_1 = __importStar(require("fs"));
30
+ const globby_1 = __importDefault(require("globby"));
31
+ const common_1 = require("../common");
32
+ const fileUtil_1 = require("./fileUtil");
33
+ const HashAlgorithm = 'sha1';
34
+ var FileService;
35
+ (function (FileService) {
36
+ let instance;
37
+ function create() {
38
+ return instance ?? (instance = new FileServiceImpl());
39
+ }
40
+ FileService.create = create;
41
+ })(FileService = exports.FileService || (exports.FileService = {}));
42
+ class FileServiceImpl {
43
+ constructor() {
44
+ this.supporters = new Map();
45
+ }
46
+ register(protocol, supporter, force = false) {
47
+ if (!force && this.supporters.has(protocol)) {
48
+ throw new Error(`The protocol “${protocol}” is already associated with another supporter.`);
49
+ }
50
+ this.supporters.set(protocol, supporter);
51
+ }
52
+ unregister(protocol) {
53
+ this.supporters.delete(protocol);
54
+ }
55
+ /**
56
+ * @throws If the protocol of `uri` isn't supported.
57
+ *
58
+ * @returns The protocol if it's supported.
59
+ */
60
+ getSupportedProtocol(uri) {
61
+ const protocol = new common_1.Uri(uri).protocol;
62
+ if (!this.supporters.has(protocol)) {
63
+ throw new Error(`The protocol “${protocol}” is unsupported.`);
64
+ }
65
+ return protocol;
66
+ }
67
+ /**
68
+ * @throws
69
+ */
70
+ async hash(uri) {
71
+ const protocol = this.getSupportedProtocol(uri);
72
+ return this.supporters.get(protocol).hash(uri);
73
+ }
74
+ /**
75
+ * @throws
76
+ */
77
+ readFile(uri) {
78
+ const protocol = this.getSupportedProtocol(uri);
79
+ return this.supporters.get(protocol).readFile(uri);
80
+ }
81
+ *listFiles() {
82
+ for (const supporter of this.supporters.values()) {
83
+ yield* supporter.listFiles();
84
+ }
85
+ }
86
+ *listRoots() {
87
+ for (const supporter of this.supporters.values()) {
88
+ yield* supporter.listRoots();
89
+ }
90
+ }
91
+ }
92
+ exports.FileServiceImpl = FileServiceImpl;
93
+ class FileUriSupporter {
94
+ constructor(roots, files) {
95
+ this.roots = roots;
96
+ this.files = files;
97
+ this.protocol = 'file:';
98
+ }
99
+ async hash(uri) {
100
+ return hashFile(uri);
101
+ }
102
+ readFile(uri) {
103
+ return fs_1.promises.readFile(new common_1.Uri(uri));
104
+ }
105
+ *listFiles() {
106
+ for (const files of this.files.values()) {
107
+ yield* files;
108
+ }
109
+ }
110
+ listRoots() {
111
+ return this.roots;
112
+ }
113
+ static rootUriToGlob(root) {
114
+ return fileUtil_1.fileUtil.fileUriToPath(root) + '**/*';
115
+ }
116
+ static async create(dependencies, logger) {
117
+ const roots = [];
118
+ const files = new Map();
119
+ for (let { uri } of dependencies) {
120
+ try {
121
+ if (fileUtil_1.fileUtil.isFileUri(uri) && (await fs_1.promises.stat(new common_1.Uri(uri))).isDirectory()) {
122
+ uri = fileUtil_1.fileUtil.ensureEndingSlash(uri);
123
+ roots.push(uri);
124
+ files.set(uri, (await (0, globby_1.default)(this.rootUriToGlob(uri), { absolute: true, dot: true })).map(fileUtil_1.fileUtil.pathToFileUri));
125
+ }
126
+ }
127
+ catch (e) {
128
+ logger.error(`[FileUriSupporter#create] Bad dependency “${uri}”`, e);
129
+ }
130
+ }
131
+ return new FileUriSupporter(roots, files);
132
+ }
133
+ }
134
+ exports.FileUriSupporter = FileUriSupporter;
135
+ class SpyglassUriSupporter {
136
+ /**
137
+ * @param entries A map from archive URIs to unzipped entries.
138
+ */
139
+ constructor(entries) {
140
+ this.entries = entries;
141
+ this.protocol = common_1.SpyglassUri.Protocol;
142
+ }
143
+ async hash(uri) {
144
+ const { archiveUri, pathInArchive } = common_1.SpyglassUri.Archive.decode(new common_1.Uri(uri));
145
+ if (!pathInArchive) {
146
+ // Hash the archive itself.
147
+ return hashFile(archiveUri);
148
+ }
149
+ else {
150
+ // Hash the corresponding file.
151
+ return (0, common_1.getSha1)(await this.getDataInArchive(archiveUri, pathInArchive));
152
+ }
153
+ }
154
+ async readFile(uri) {
155
+ const { archiveUri, pathInArchive } = common_1.SpyglassUri.Archive.decode(new common_1.Uri(uri));
156
+ return this.getDataInArchive(archiveUri, pathInArchive);
157
+ }
158
+ /**
159
+ * @throws
160
+ */
161
+ async getDataInArchive(archiveUri, pathInArchive) {
162
+ const entries = this.entries.get(archiveUri);
163
+ if (!entries) {
164
+ throw new Error(`Archive “${archiveUri}” has not been loaded into the memory`);
165
+ }
166
+ const entry = entries.get(pathInArchive);
167
+ if (!entry) {
168
+ throw new Error(`Path “${pathInArchive}” does not exist in archive “${archiveUri}”`);
169
+ }
170
+ if (entry.type !== 'file') {
171
+ throw new Error(`Path “${pathInArchive}” in archive “${archiveUri}” is not a file`);
172
+ }
173
+ return entry.data;
174
+ }
175
+ *listFiles() {
176
+ for (const [archiveUri, files] of this.entries.entries()) {
177
+ for (const file of files.values()) {
178
+ yield common_1.SpyglassUri.Archive.get(archiveUri, file.path);
179
+ }
180
+ }
181
+ }
182
+ *listRoots() {
183
+ for (const archiveUri of this.entries.keys()) {
184
+ yield common_1.SpyglassUri.Archive.get(archiveUri);
185
+ }
186
+ }
187
+ static async create(dependencies, logger, checksums) {
188
+ const entries = new Map();
189
+ for (const { uri, info } of dependencies) {
190
+ try {
191
+ if (uri.startsWith('file:') && SpyglassUriSupporter.SupportedArchiveExtnames.some(ext => uri.endsWith(ext)) && (await fs_1.promises.stat(new common_1.Uri(uri))).isFile()) {
192
+ const rootUri = common_1.SpyglassUri.Archive.get(uri);
193
+ const cachedChecksum = checksums[rootUri];
194
+ if (cachedChecksum !== undefined) {
195
+ const checksum = await hashFile(uri);
196
+ if (cachedChecksum === checksum) {
197
+ // The dependency has not changed since last cache.
198
+ logger.info(`[SpyglassUriSupporter#create] Skipped decompressing “${uri}” thanks to cache ${checksum}`);
199
+ continue;
200
+ }
201
+ }
202
+ const files = await (0, decompress_1.default)(fileUtil_1.fileUtil.fileUriToPath(uri), { strip: typeof info?.startDepth === 'number' ? info.startDepth : 0 });
203
+ entries.set(uri, new Map(files.map(f => [f.path.replace(/\\/g, '/'), f])));
204
+ }
205
+ }
206
+ catch (e) {
207
+ logger.error(`[SpyglassUriSupporter#create] Bad dependency “${uri}”`, e);
208
+ }
209
+ }
210
+ return new SpyglassUriSupporter(entries);
211
+ }
212
+ }
213
+ exports.SpyglassUriSupporter = SpyglassUriSupporter;
214
+ SpyglassUriSupporter.SupportedArchiveExtnames = ['.tar', '.tar.bz2', '.tar.gz', '.zip'];
215
+ async function hashFile(uri) {
216
+ return new Promise((resolve, reject) => {
217
+ const hash = crypto_1.default.createHash(HashAlgorithm);
218
+ fs_1.default.createReadStream(new common_1.Uri(uri))
219
+ .on('data', chunk => hash.update(chunk))
220
+ .on('end', () => resolve(hash.digest('hex')))
221
+ .on('error', reject);
222
+ });
223
+ }
224
+ //# sourceMappingURL=FileService.js.map
@@ -0,0 +1,10 @@
1
+ import type { RangeLike } from '../source';
2
+ import { Range } from '../source';
3
+ export interface Hover {
4
+ range: Range;
5
+ markdown: string;
6
+ }
7
+ export declare namespace Hover {
8
+ function create(range: RangeLike, markdown: string): Hover;
9
+ }
10
+ //# sourceMappingURL=Hover.d.ts.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Hover = void 0;
4
+ const source_1 = require("../source");
5
+ var Hover;
6
+ (function (Hover) {
7
+ /* istanbul ignore next */
8
+ function create(range, markdown) {
9
+ return {
10
+ range: source_1.Range.get(range),
11
+ markdown,
12
+ };
13
+ }
14
+ Hover.create = create;
15
+ })(Hover = exports.Hover || (exports.Hover = {}));
16
+ //# sourceMappingURL=Hover.js.map
@@ -0,0 +1,31 @@
1
+ export interface Logger {
2
+ /**
3
+ * Output an error message.
4
+ */
5
+ error(data: any, ...args: any[]): void;
6
+ /**
7
+ * Log an information.
8
+ */
9
+ info(data: any, ...args: any[]): void;
10
+ /**
11
+ * Log a message.
12
+ */
13
+ log(data: any, ...args: any[]): void;
14
+ /**
15
+ * Output a warning message.
16
+ */
17
+ warn(data: any, ...args: any[]): void;
18
+ }
19
+ export declare namespace Logger {
20
+ /**
21
+ * @returns The built-in `console`.
22
+ * Do **not** use this implementation in language servers, as some clients cannot handle
23
+ * non-LSP stdout. (https://github.com/SpyglassMC/Spyglass/issues/845)
24
+ */
25
+ function create(): Logger;
26
+ /**
27
+ * @returns A logger that does nothing.
28
+ */
29
+ function noop(): Logger;
30
+ }
31
+ //# sourceMappingURL=Logger.d.ts.map
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ var Logger;
5
+ (function (Logger) {
6
+ /* istanbul ignore next */
7
+ /**
8
+ * @returns The built-in `console`.
9
+ * Do **not** use this implementation in language servers, as some clients cannot handle
10
+ * non-LSP stdout. (https://github.com/SpyglassMC/Spyglass/issues/845)
11
+ */
12
+ function create() {
13
+ return console;
14
+ }
15
+ Logger.create = create;
16
+ /**
17
+ * @returns A logger that does nothing.
18
+ */
19
+ function noop() {
20
+ return new NoopLogger();
21
+ }
22
+ Logger.noop = noop;
23
+ })(Logger = exports.Logger || (exports.Logger = {}));
24
+ class NoopLogger {
25
+ error() { }
26
+ info() { }
27
+ log() { }
28
+ warn() { }
29
+ }
30
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1,106 @@
1
+ import { Lazy } from '../common';
2
+ import type { AstNode } from '../node';
3
+ import type { Parser } from '../parser';
4
+ import type { Checker, Colorizer, Completer, InlayHintProvider } from '../processor';
5
+ import type { Formatter } from '../processor/formatter';
6
+ import type { Linter } from '../processor/linter/Linter';
7
+ import type { SignatureHelpProvider } from '../processor/SignatureHelpProvider';
8
+ import type { UriBinder } from '../symbol';
9
+ import type { DependencyKey, DependencyProvider } from './Dependency';
10
+ import type { FileExtension } from './fileUtil';
11
+ import type { Logger } from './Logger';
12
+ import type { SymbolRegistrar } from './SymbolRegistrar';
13
+ export interface LanguageOptions {
14
+ /**
15
+ * An array of extensions of files corresponding to the language. Each extension should include the leading dot (`.`).
16
+ */
17
+ extensions: FileExtension[];
18
+ triggerCharacters?: string[];
19
+ parser: Parser<AstNode>;
20
+ completer?: Completer<any>;
21
+ }
22
+ interface LinterRegistration {
23
+ configValidator: (ruleName: string, ruleValue: unknown, logger: Logger) => unknown;
24
+ linter: Linter<AstNode>;
25
+ nodePredicate: (node: AstNode) => unknown;
26
+ }
27
+ interface SymbolRegistrarRegistration {
28
+ registrar: SymbolRegistrar;
29
+ checksum: string | undefined;
30
+ }
31
+ /**
32
+ * The meta registry of Spyglass. You can register new parsers, processors, and languages here.
33
+ */
34
+ export declare class MetaRegistry {
35
+ #private;
36
+ constructor();
37
+ /**
38
+ * Registers a new language.
39
+ * @param languageID The language ID. e.g. `"mcfunction"`
40
+ * @param options The language options for this language.
41
+ */
42
+ registerLanguage(languageID: string, options: LanguageOptions): void;
43
+ /**
44
+ * An array of all registered language IDs.
45
+ */
46
+ getLanguages(): string[];
47
+ isSupportedLanguage(language: string): boolean;
48
+ /**
49
+ * An array of file extensions (including the leading dot (`.`)) that are supported.
50
+ */
51
+ getSupportedFileExtensions(): FileExtension[];
52
+ /**
53
+ * An array of characters that trigger a completion request.
54
+ */
55
+ getTriggerCharacters(): string[];
56
+ /**
57
+ * @param fileExtension The file extension including the leading dot. e.g. `".mcfunction"`.
58
+ * @returns The language ID registered for the file extension, or `undefined`.
59
+ */
60
+ getLanguageID(fileExtension: FileExtension): string | undefined;
61
+ hasChecker<N extends AstNode>(type: N['type']): boolean;
62
+ getChecker<N extends AstNode>(type: N['type']): Checker<N>;
63
+ registerChecker<N extends AstNode>(type: N['type'], checker: Checker<N>): void;
64
+ hasColorizer<N extends AstNode>(type: N['type']): boolean;
65
+ getColorizer<N extends AstNode>(type: N['type']): Colorizer<N>;
66
+ registerColorizer<N extends AstNode>(type: N['type'], colorizer: Colorizer<N>): void;
67
+ hasCompleter<N extends AstNode>(type: N['type']): boolean;
68
+ getCompleter<N extends AstNode>(type: N['type']): Completer<N>;
69
+ registerCompleter<N extends AstNode>(type: N['type'], completer: Completer<N>): void;
70
+ registerCompleter(type: string, completer: Completer<any>): void;
71
+ shouldComplete(languageID: string, triggerCharacter?: string): boolean;
72
+ getCompleterForLanguageID(languageID: string): Completer<any>;
73
+ getDependencyProvider(key: DependencyKey): DependencyProvider | undefined;
74
+ registerDependencyProvider(key: DependencyKey, provider: DependencyProvider): void;
75
+ hasFormatter<N extends AstNode>(type: N['type']): boolean;
76
+ getFormatter<N extends AstNode>(type: N['type']): Formatter<N>;
77
+ registerFormatter<N extends AstNode>(type: N['type'], formatter: Formatter<N>): void;
78
+ registerInlayHintProvider(provider: InlayHintProvider<any>): void;
79
+ get inlayHintProviders(): Set<InlayHintProvider<any>>;
80
+ getLinter(ruleName: string): LinterRegistration;
81
+ registerLinter(ruleName: string, options: LinterRegistration): void;
82
+ hasParser<N extends AstNode>(id: N['type']): boolean;
83
+ hasParser(id: string): boolean;
84
+ /**
85
+ * @throws When no parser is registered for the node type.
86
+ */
87
+ getParser<N extends AstNode>(id: N['type']): Parser<N>;
88
+ getParser<N extends AstNode>(id: string): Parser<N>;
89
+ getParserLazily<N extends AstNode>(id: N['type']): Lazy.UnresolvedLazy<Parser<N>>;
90
+ getParserLazily<N extends AstNode>(id: string): Lazy.UnresolvedLazy<Parser<N>>;
91
+ registerParser<N extends AstNode>(id: N['type'], parser: Parser<N>): void;
92
+ registerParser(id: string, parser: Parser): void;
93
+ /**
94
+ * @returns The corresponding `Parser` for the language ID.
95
+ * @throws If there's no such language in the registry.
96
+ */
97
+ getParserForLanguageId<N extends AstNode>(languageID: string): Parser<N>;
98
+ registerSignatureHelpProvider(provider: SignatureHelpProvider<any>): void;
99
+ get signatureHelpProviders(): Set<SignatureHelpProvider<any>>;
100
+ registerSymbolRegistrar(id: string, registrar: SymbolRegistrarRegistration): void;
101
+ get symbolRegistrars(): Map<string, SymbolRegistrarRegistration>;
102
+ registerUriBinder(uriBinder: UriBinder): void;
103
+ get uriBinders(): Set<UriBinder>;
104
+ }
105
+ export {};
106
+ //# sourceMappingURL=MetaRegistry.d.ts.map