@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,16 +1,16 @@
1
- import type { StringNode, StringOptions } from '../node';
2
- import type { InfallibleParser } from '../parser';
3
- import type { ParserContext } from '../service';
4
- import type { IndexMap } from '../source';
5
- import type { Parser, Result, Returnable } from './Parser';
1
+ import type { StringNode, StringOptions } from '../node/index.js';
2
+ import type { InfallibleParser } from '../parser/index.js';
3
+ import type { ParserContext } from '../service/index.js';
4
+ import type { IndexMap } from '../source/index.js';
5
+ import type { Parser, Result, Returnable } from './Parser.js';
6
6
  export declare function string(options: StringOptions): InfallibleParser<StringNode>;
7
7
  export declare function parseStringValue<T extends Returnable>(parser: Parser<T>, value: string, map: IndexMap, ctx: ParserContext): Result<T>;
8
8
  export declare const BrigadierUnquotableCharacters: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "_", ".", "+", "-"];
9
- export declare const BrigadierUnquotableCharacterSet: Set<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "i" | "p" | "-" | "+" | "e" | "a" | "b" | "c" | "d" | "f" | "g" | "h" | "j" | "k" | "l" | "m" | "n" | "o" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "_" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z">;
9
+ export declare const BrigadierUnquotableCharacterSet: Set<"0" | "k" | "v" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "i" | "p" | "-" | "+" | "e" | "a" | "b" | "c" | "d" | "f" | "g" | "h" | "j" | "l" | "m" | "n" | "o" | "q" | "r" | "s" | "t" | "u" | "w" | "x" | "y" | "z" | "_" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z">;
10
10
  export declare const BrigadierUnquotablePattern: RegExp;
11
11
  export declare const BrigadierUnquotableOption: {
12
12
  allowEmpty: boolean;
13
- allowList: Set<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "i" | "p" | "-" | "+" | "e" | "a" | "b" | "c" | "d" | "f" | "g" | "h" | "j" | "k" | "l" | "m" | "n" | "o" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "_" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z">;
13
+ allowList: Set<"0" | "k" | "v" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "." | "i" | "p" | "-" | "+" | "e" | "a" | "b" | "c" | "d" | "f" | "g" | "h" | "j" | "l" | "m" | "n" | "o" | "q" | "r" | "s" | "t" | "u" | "w" | "x" | "y" | "z" | "_" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z">;
14
14
  };
15
15
  export declare const BrigadierStringOptions: StringOptions;
16
16
  export declare const brigadierString: InfallibleParser<StringNode>;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAllowedCharacter = exports.brigadierString = exports.BrigadierStringOptions = exports.BrigadierUnquotableOption = exports.BrigadierUnquotablePattern = exports.BrigadierUnquotableCharacterSet = exports.BrigadierUnquotableCharacters = exports.parseStringValue = exports.string = void 0;
4
- const locales_1 = require("@spyglassmc/locales");
5
- const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
6
- const node_1 = require("../node");
7
- const source_1 = require("../source");
8
- const Parser_1 = require("./Parser");
9
- function string(options) {
1
+ import { localeQuote, localize } from '@spyglassmc/locales';
2
+ import { TextDocument } from 'vscode-languageserver-textdocument';
3
+ import { EscapeChar, EscapeTable } from '../node/index.js';
4
+ import { Range, Source } from '../source/index.js';
5
+ import { Failure } from './Parser.js';
6
+ export function string(options) {
10
7
  return (src, ctx) => {
11
8
  const ans = {
12
9
  type: 'string',
13
- range: source_1.Range.create(src),
10
+ range: Range.create(src),
14
11
  options,
15
12
  value: '',
16
13
  valueMap: [],
@@ -25,39 +22,39 @@ function string(options) {
25
22
  const cStart = src.cursor;
26
23
  src.skip();
27
24
  const c2 = src.read();
28
- if (c2 === '\\' || c2 === currentQuote || node_1.EscapeChar.is(options.escapable.characters, c2)) {
25
+ if (c2 === '\\' || c2 === currentQuote || EscapeChar.is(options.escapable.characters, c2)) {
29
26
  ans.valueMap.push({
30
- inner: source_1.Range.create(ans.value.length, ans.value.length + 1),
31
- outer: source_1.Range.create(cStart, src),
27
+ inner: Range.create(ans.value.length, ans.value.length + 1),
28
+ outer: Range.create(cStart, src),
32
29
  });
33
- ans.value += node_1.EscapeTable.get(c2);
30
+ ans.value += EscapeTable.get(c2);
34
31
  }
35
32
  else if (options.escapable.unicode && c2 === 'u') {
36
33
  const hex = src.peek(4);
37
34
  if (/^[0-9a-f]{4}$/i.test(hex)) {
38
35
  src.skip(4);
39
36
  ans.valueMap.push({
40
- inner: source_1.Range.create(ans.value.length, ans.value.length + 1),
41
- outer: source_1.Range.create(cStart, src),
37
+ inner: Range.create(ans.value.length, ans.value.length + 1),
38
+ outer: Range.create(cStart, src),
42
39
  });
43
40
  ans.value += String.fromCharCode(parseInt(hex, 16));
44
41
  }
45
42
  else {
46
- ctx.err.report((0, locales_1.localize)('parser.string.illegal-unicode-escape'), source_1.Range.create(src, src.getCharRange(3).end));
43
+ ctx.err.report(localize('parser.string.illegal-unicode-escape'), Range.create(src, src.getCharRange(3).end));
47
44
  ans.valueMap.push({
48
- inner: source_1.Range.create(ans.value.length, ans.value.length + 1),
49
- outer: source_1.Range.create(cStart, src),
45
+ inner: Range.create(ans.value.length, ans.value.length + 1),
46
+ outer: Range.create(cStart, src),
50
47
  });
51
48
  ans.value += c2;
52
49
  }
53
50
  }
54
51
  else {
55
52
  if (!options.escapable.allowUnknown) {
56
- ctx.err.report((0, locales_1.localize)('parser.string.illegal-escape', (0, locales_1.localeQuote)(c2)), src.getCharRange(-1));
53
+ ctx.err.report(localize('parser.string.illegal-escape', localeQuote(c2)), src.getCharRange(-1));
57
54
  }
58
55
  ans.valueMap.push({
59
- inner: source_1.Range.create(ans.value.length, ans.value.length + 1),
60
- outer: source_1.Range.create(cStart, src),
56
+ inner: Range.create(ans.value.length, ans.value.length + 1),
57
+ outer: Range.create(cStart, src),
61
58
  });
62
59
  ans.value += c2;
63
60
  }
@@ -68,10 +65,10 @@ function string(options) {
68
65
  }
69
66
  }
70
67
  if (!src.trySkip(currentQuote)) {
71
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localeQuote)(currentQuote)), src);
68
+ ctx.err.report(localize('expected', localeQuote(currentQuote)), src);
72
69
  }
73
70
  if (!options.quotes.includes(currentQuote)) {
74
- ctx.err.report((0, locales_1.localize)('parser.string.illegal-quote', options.quotes), ans);
71
+ ctx.err.report(localize('parser.string.illegal-quote', options.quotes), ans);
75
72
  }
76
73
  start = contentStart;
77
74
  }
@@ -80,17 +77,17 @@ function string(options) {
80
77
  ans.value += src.read();
81
78
  }
82
79
  if (!ans.value && !options.unquotable.allowEmpty) {
83
- ctx.err.report((0, locales_1.localize)('expected', (0, locales_1.localize)('string')), src);
80
+ ctx.err.report(localize('expected', localize('string')), src);
84
81
  }
85
82
  }
86
83
  else {
87
- ctx.err.report((0, locales_1.localize)('expected', options.quotes), src);
84
+ ctx.err.report(localize('expected', options.quotes), src);
88
85
  }
89
- ans.valueMap.unshift({ inner: source_1.Range.create(0), outer: source_1.Range.create(start) });
86
+ ans.valueMap.unshift({ inner: Range.create(0), outer: Range.create(start) });
90
87
  if (options.value?.parser) {
91
88
  const valueResult = parseStringValue(options.value.parser, ans.value, ans.valueMap, ctx);
92
89
  /* istanbul ignore else */
93
- if (valueResult !== Parser_1.Failure) {
90
+ if (valueResult !== Failure) {
94
91
  ans.children = [valueResult];
95
92
  }
96
93
  }
@@ -98,34 +95,31 @@ function string(options) {
98
95
  return ans;
99
96
  };
100
97
  }
101
- exports.string = string;
102
- function parseStringValue(parser, value, map, ctx) {
103
- const valueSrc = new source_1.Source(value, map);
98
+ export function parseStringValue(parser, value, map, ctx) {
99
+ const valueSrc = new Source(value, map);
104
100
  const valueCtx = {
105
101
  ...ctx,
106
- doc: vscode_languageserver_textdocument_1.TextDocument.create(ctx.doc.uri, ctx.doc.languageId, ctx.doc.version, value),
102
+ doc: TextDocument.create(ctx.doc.uri, ctx.doc.languageId, ctx.doc.version, value),
107
103
  };
108
104
  // TODO: Mark trailing string as errors.
109
105
  return parser(valueSrc, valueCtx);
110
106
  }
111
- exports.parseStringValue = parseStringValue;
112
- exports.BrigadierUnquotableCharacters = Object.freeze([
107
+ export const BrigadierUnquotableCharacters = Object.freeze([
113
108
  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
114
109
  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
115
110
  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
116
111
  '_', '.', '+', '-',
117
112
  ]);
118
- exports.BrigadierUnquotableCharacterSet = new Set(exports.BrigadierUnquotableCharacters);
119
- exports.BrigadierUnquotablePattern = /^[0-9A-Za-z_\.\+\-]*$/;
120
- exports.BrigadierUnquotableOption = { allowEmpty: true, allowList: exports.BrigadierUnquotableCharacterSet };
121
- exports.BrigadierStringOptions = {
113
+ export const BrigadierUnquotableCharacterSet = new Set(BrigadierUnquotableCharacters);
114
+ export const BrigadierUnquotablePattern = /^[0-9A-Za-z_\.\+\-]*$/;
115
+ export const BrigadierUnquotableOption = { allowEmpty: true, allowList: BrigadierUnquotableCharacterSet };
116
+ export const BrigadierStringOptions = {
122
117
  escapable: {},
123
118
  quotes: ['"', "'"],
124
- unquotable: exports.BrigadierUnquotableOption,
119
+ unquotable: BrigadierUnquotableOption,
125
120
  };
126
- exports.brigadierString = string(exports.BrigadierStringOptions);
127
- function isAllowedCharacter(c, options) {
121
+ export const brigadierString = string(BrigadierStringOptions);
122
+ export function isAllowedCharacter(c, options) {
128
123
  return options.allowList?.has(c) ?? !options.blockList?.has(c);
129
124
  }
130
- exports.isAllowedCharacter = isAllowedCharacter;
131
125
  //# sourceMappingURL=string.js.map
@@ -1,6 +1,6 @@
1
- import type { SymbolNode, SymbolOptions } from '../node/SymbolNode';
2
- import type { AllCategory } from '../symbol';
3
- import type { InfallibleParser } from './Parser';
1
+ import type { SymbolNode, SymbolOptions } from '../node/SymbolNode.js';
2
+ import type { AllCategory } from '../symbol/index.js';
3
+ import type { InfallibleParser } from './Parser.js';
4
4
  /**
5
5
  * This parser reads _everything_ until the end of the {@link Source}.
6
6
  *
@@ -1,27 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.symbol = void 0;
4
- const source_1 = require("../source");
5
- function symbol(param) {
1
+ import { Range } from '../source/index.js';
2
+ export function symbol(param) {
6
3
  const options = getOptions(param);
7
- return (src, ctx) => {
4
+ return (src, _ctx) => {
8
5
  const ans = {
9
6
  type: 'symbol',
10
- range: source_1.Range.create(src),
7
+ range: Range.create(src),
11
8
  options,
12
9
  value: src.readRemaining(),
13
10
  };
14
- if (ans.value) {
15
- const path = options.parentPath ? [...options.parentPath, ans.value] : [ans.value];
16
- ctx.symbols
17
- .query(ctx.doc, options.category, ...path)
18
- .enter({ usage: { type: options.usageType, node: ans, accessType: options.accessType } });
19
- }
20
11
  ans.range.end = src.cursor;
21
12
  return ans;
22
13
  };
23
14
  }
24
- exports.symbol = symbol;
25
15
  function getOptions(param) {
26
16
  if (typeof param === 'string') {
27
17
  return { category: param };
@@ -1,8 +1,8 @@
1
- import type { AstNode } from '../node';
2
- import { SequenceUtil } from '../node';
3
- import type { ParserContext } from '../service';
4
- import type { ErrorSeverity, ReadonlySource, Source } from '../source';
5
- import type { InfallibleParser, Parser, Result, Returnable } from './Parser';
1
+ import type { AstNode } from '../node/index.js';
2
+ import { SequenceUtil } from '../node/index.js';
3
+ import type { ParserContext } from '../service/index.js';
4
+ import type { ErrorSeverity, ReadonlySource, Source } from '../source/index.js';
5
+ import type { InfallibleParser, Parser, Result, Returnable } from './Parser.js';
6
6
  declare type ExtractNodeType<P extends Parser<Returnable>> = P extends Parser<infer V> ? V : never;
7
7
  /**
8
8
  * @template PA Parser array.
@@ -111,6 +111,7 @@ declare type ExtractFromGettableParser<T extends GettableParser> = T extends {
111
111
  declare type Case = {
112
112
  predicate?: (this: void, src: ReadonlySource) => boolean;
113
113
  prefix?: string;
114
+ regex?: RegExp;
114
115
  parser: GettableParser;
115
116
  };
116
117
  /**
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.acceptIf = exports.acceptOnly = exports.stopBefore = exports.validate = exports.setType = exports.map = exports.select = exports.recover = exports.optional = exports.failOnError = exports.failOnEmpty = exports.any = exports.repeat = exports.sequence = exports.attempt = void 0;
4
- const node_1 = require("../node");
5
- const service_1 = require("../service");
6
- const source_1 = require("../source");
7
- const Parser_1 = require("./Parser");
8
- function attempt(parser, src, ctx) {
1
+ import { SequenceUtil, SequenceUtilDiscriminator } from '../node/index.js';
2
+ import { ErrorReporter } from '../service/index.js';
3
+ import { Range } from '../source/index.js';
4
+ import { Failure } from './Parser.js';
5
+ export function attempt(parser, src, ctx) {
9
6
  const tmpSrc = src.clone();
10
7
  const tmpCtx = {
11
8
  ...ctx,
12
- err: new service_1.ErrorReporter(),
13
- symbols: ctx.symbols.clone(),
9
+ err: new ErrorReporter(),
14
10
  };
15
11
  const result = parser(tmpSrc, tmpCtx);
16
12
  return {
@@ -20,17 +16,15 @@ function attempt(parser, src, ctx) {
20
16
  updateSrcAndCtx: () => {
21
17
  src.innerCursor = tmpSrc.innerCursor;
22
18
  ctx.err.absorb(tmpCtx.err);
23
- tmpCtx.symbols.applyDelayedEdits();
24
19
  },
25
20
  };
26
21
  }
27
- exports.attempt = attempt;
28
- function sequence(parsers, parseGap) {
22
+ export function sequence(parsers, parseGap) {
29
23
  return (src, ctx) => {
30
24
  const ans = {
31
- [node_1.SequenceUtilDiscriminator]: true,
25
+ [SequenceUtilDiscriminator]: true,
32
26
  children: [],
33
- range: source_1.Range.create(src),
27
+ range: Range.create(src),
34
28
  };
35
29
  for (const [i, p] of parsers.entries()) {
36
30
  const parser = typeof p === 'function' ? p : p.get(ans);
@@ -41,13 +35,13 @@ function sequence(parsers, parseGap) {
41
35
  ans.children.push(...parseGap(src, ctx));
42
36
  }
43
37
  const result = parser(src, ctx);
44
- if (result === Parser_1.Failure) {
45
- return Parser_1.Failure;
38
+ if (result === Failure) {
39
+ return Failure;
46
40
  }
47
41
  else if (result === undefined) {
48
42
  continue;
49
43
  }
50
- else if (node_1.SequenceUtil.is(result)) {
44
+ else if (SequenceUtil.is(result)) {
51
45
  ans.children.push(...result.children);
52
46
  }
53
47
  else {
@@ -58,24 +52,23 @@ function sequence(parsers, parseGap) {
58
52
  return ans;
59
53
  };
60
54
  }
61
- exports.sequence = sequence;
62
- function repeat(parser, parseGap) {
55
+ export function repeat(parser, parseGap) {
63
56
  return (src, ctx) => {
64
57
  const ans = {
65
- [node_1.SequenceUtilDiscriminator]: true,
58
+ [SequenceUtilDiscriminator]: true,
66
59
  children: [],
67
- range: source_1.Range.create(src),
60
+ range: Range.create(src),
68
61
  };
69
62
  while (src.canRead()) {
70
63
  if (parseGap) {
71
64
  ans.children.push(...parseGap(src, ctx));
72
65
  }
73
66
  const { result, updateSrcAndCtx } = attempt(parser, src, ctx);
74
- if (result === Parser_1.Failure) {
67
+ if (result === Failure) {
75
68
  break;
76
69
  }
77
70
  updateSrcAndCtx();
78
- if (node_1.SequenceUtil.is(result)) {
71
+ if (SequenceUtil.is(result)) {
79
72
  ans.children.push(...result.children);
80
73
  }
81
74
  else {
@@ -86,18 +79,17 @@ function repeat(parser, parseGap) {
86
79
  return ans;
87
80
  };
88
81
  }
89
- exports.repeat = repeat;
90
- function any(parsers, out) {
82
+ export function any(parsers, out) {
91
83
  return (src, ctx) => {
92
84
  const results = parsers
93
85
  .map((parser, i) => ({ attempt: attempt(parser, src, ctx), index: i }))
94
- .filter(({ attempt }) => attempt.result !== Parser_1.Failure)
86
+ .filter(({ attempt }) => attempt.result !== Failure)
95
87
  .sort((a, b) => (b.attempt.endCursor - a.attempt.endCursor) || (a.attempt.errorAmount - b.attempt.errorAmount));
96
88
  if (results.length === 0) {
97
89
  if (out) {
98
90
  out.index = -1;
99
91
  }
100
- return Parser_1.Failure;
92
+ return Failure;
101
93
  }
102
94
  results[0].attempt.updateSrcAndCtx();
103
95
  if (out) {
@@ -106,11 +98,10 @@ function any(parsers, out) {
106
98
  return results[0].attempt.result;
107
99
  };
108
100
  }
109
- exports.any = any;
110
101
  /**
111
102
  * @returns A parser that fails when the passed-in parser didn't move the cursor at all.
112
103
  */
113
- function failOnEmpty(parser) {
104
+ export function failOnEmpty(parser) {
114
105
  return (src, ctx) => {
115
106
  const start = src.cursor;
116
107
  const { endCursor, updateSrcAndCtx, result } = attempt(parser, src, ctx);
@@ -118,14 +109,13 @@ function failOnEmpty(parser) {
118
109
  updateSrcAndCtx();
119
110
  return result;
120
111
  }
121
- return Parser_1.Failure;
112
+ return Failure;
122
113
  };
123
114
  }
124
- exports.failOnEmpty = failOnEmpty;
125
115
  /**
126
116
  * @returns A parser that fails when the passed-in parser produced any errors.
127
117
  */
128
- function failOnError(parser) {
118
+ export function failOnError(parser) {
129
119
  return (src, ctx) => {
130
120
  const start = src.cursor;
131
121
  const { errorAmount, updateSrcAndCtx, result } = attempt(parser, src, ctx);
@@ -133,14 +123,13 @@ function failOnError(parser) {
133
123
  updateSrcAndCtx();
134
124
  return result;
135
125
  }
136
- return Parser_1.Failure;
126
+ return Failure;
137
127
  };
138
128
  }
139
- exports.failOnError = failOnError;
140
- function optional(parser) {
129
+ export function optional(parser) {
141
130
  return ((src, ctx) => {
142
131
  const { result, updateSrcAndCtx } = attempt(parser, src, ctx);
143
- if (result === Parser_1.Failure) {
132
+ if (result === Failure) {
144
133
  return undefined;
145
134
  }
146
135
  else {
@@ -149,22 +138,20 @@ function optional(parser) {
149
138
  }
150
139
  });
151
140
  }
152
- exports.optional = optional;
153
- function recover(parser, defaultValue) {
141
+ export function recover(parser, defaultValue) {
154
142
  return (src, ctx) => {
155
143
  const result = parser(src, ctx);
156
- if (result === Parser_1.Failure) {
144
+ if (result === Failure) {
157
145
  const ans = defaultValue(src, ctx);
158
146
  return ans;
159
147
  }
160
148
  return result;
161
149
  };
162
150
  }
163
- exports.recover = recover;
164
- function select(cases) {
151
+ export function select(cases) {
165
152
  return (src, ctx) => {
166
- for (const { predicate, prefix, parser } of cases) {
167
- if (predicate?.(src) ?? (prefix !== undefined ? src.tryPeek(prefix) : undefined) ?? true) {
153
+ for (const { predicate, prefix, parser, regex } of cases) {
154
+ if (predicate?.(src) ?? (prefix !== undefined ? src.tryPeek(prefix) : undefined) ?? (regex && src.matchPattern(regex)) ?? true) {
168
155
  const callableParser = typeof parser === 'object' ? parser.get() : parser;
169
156
  return callableParser(src, ctx);
170
157
  }
@@ -172,31 +159,28 @@ function select(cases) {
172
159
  throw new Error('The select parser util was called with non-exhaustive cases');
173
160
  };
174
161
  }
175
- exports.select = select;
176
- function map(parser, fn) {
162
+ export function map(parser, fn) {
177
163
  return (src, ctx) => {
178
164
  const result = parser(src, ctx);
179
- if (result === Parser_1.Failure) {
180
- return Parser_1.Failure;
165
+ if (result === Failure) {
166
+ return Failure;
181
167
  }
182
168
  const ans = fn(result, src, ctx);
183
169
  return ans;
184
170
  };
185
171
  }
186
- exports.map = map;
187
- function setType(type, parser) {
172
+ export function setType(type, parser) {
188
173
  return map(parser, res => {
189
174
  const { type: _type, ...restResult } = res;
190
175
  const ans = {
191
176
  type,
192
177
  ...restResult,
193
178
  };
194
- delete ans[node_1.SequenceUtilDiscriminator];
179
+ delete ans[SequenceUtilDiscriminator];
195
180
  return ans;
196
181
  });
197
182
  }
198
- exports.setType = setType;
199
- function validate(parser, validator, message, severity) {
183
+ export function validate(parser, validator, message, severity) {
200
184
  return map(parser, (res, src, ctx) => {
201
185
  const isLegal = validator(res, src, ctx);
202
186
  if (!isLegal) {
@@ -205,8 +189,7 @@ function validate(parser, validator, message, severity) {
205
189
  return res;
206
190
  });
207
191
  }
208
- exports.validate = validate;
209
- function stopBefore(parser, ...teminators) {
192
+ export function stopBefore(parser, ...teminators) {
210
193
  const flatTerminators = teminators.flat();
211
194
  return (src, ctx) => {
212
195
  const tmpSrc = src.clone();
@@ -220,8 +203,7 @@ function stopBefore(parser, ...teminators) {
220
203
  return ans;
221
204
  };
222
205
  }
223
- exports.stopBefore = stopBefore;
224
- function acceptOnly(parser, ...characters) {
206
+ export function acceptOnly(parser, ...characters) {
225
207
  const set = new Set(characters.flat());
226
208
  return (src, ctx) => {
227
209
  const tmpSrc = src.clone();
@@ -237,8 +219,7 @@ function acceptOnly(parser, ...characters) {
237
219
  return ans;
238
220
  };
239
221
  }
240
- exports.acceptOnly = acceptOnly;
241
- function acceptIf(parser, predicate) {
222
+ export function acceptIf(parser, predicate) {
242
223
  return ((src, ctx) => {
243
224
  const tmpSrc = src.clone();
244
225
  // Cut tmpSrc.string before the nearest unacceptable character.
@@ -253,5 +234,4 @@ function acceptIf(parser, predicate) {
253
234
  return ans;
254
235
  });
255
236
  }
256
- exports.acceptIf = acceptIf;
257
237
  //# sourceMappingURL=util.js.map
@@ -1,4 +1,4 @@
1
- import type { Range } from '../source';
1
+ import type { Range } from '../source/index.js';
2
2
  export interface ColorInfo {
3
3
  range: Range;
4
4
  color: Color;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColorPresentation = exports.ColorFormat = exports.Color = void 0;
4
- var Color;
1
+ export var Color;
5
2
  (function (Color) {
6
3
  Color.NamedColors = new Map([
7
4
  ['aqua', 0x55ffff],
@@ -75,8 +72,8 @@ var Color;
75
72
  return fromIntRGB(r, g, b);
76
73
  }
77
74
  Color.fromCompositeInt = fromCompositeInt;
78
- })(Color = exports.Color || (exports.Color = {}));
79
- var ColorFormat;
75
+ })(Color || (Color = {}));
76
+ export var ColorFormat;
80
77
  (function (ColorFormat) {
81
78
  /**
82
79
  * `1 0.6 0.2 1.0`
@@ -106,8 +103,8 @@ var ColorFormat;
106
103
  * `16620441`
107
104
  */
108
105
  ColorFormat[ColorFormat["CompositeInt"] = 6] = "CompositeInt";
109
- })(ColorFormat = exports.ColorFormat || (exports.ColorFormat = {}));
110
- var ColorPresentation;
106
+ })(ColorFormat || (ColorFormat = {}));
107
+ export var ColorPresentation;
111
108
  (function (ColorPresentation) {
112
109
  function fromColorFormat(format, color, range) {
113
110
  const presentation = colorPresentation(format, color);
@@ -137,5 +134,5 @@ var ColorPresentation;
137
134
  return `${Math.round((color[0] * 255 << 16) + (color[1] * 255 << 8) + color[2] * 255)}`;
138
135
  }
139
136
  }
140
- })(ColorPresentation = exports.ColorPresentation || (exports.ColorPresentation = {}));
137
+ })(ColorPresentation || (ColorPresentation = {}));
141
138
  //# sourceMappingURL=ColorInfoProvider.js.map
@@ -1,8 +1,9 @@
1
- import type { AstNode } from '../node';
2
- import type { ProcessorContext } from '../service';
1
+ import type { DeepReadonly } from '../common/index.js';
2
+ import type { AstNode } from '../node/index.js';
3
+ import type { ProcessorContext } from '../service/index.js';
3
4
  export interface InlayHint {
4
5
  offset: number;
5
6
  text: string;
6
7
  }
7
- export declare type InlayHintProvider<N = AstNode> = (node: N, ctx: ProcessorContext) => readonly InlayHint[];
8
+ export declare type InlayHintProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: ProcessorContext) => readonly InlayHint[];
8
9
  //# sourceMappingURL=InlayHintProvider.d.ts.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=InlayHintProvider.js.map
@@ -1,5 +1,6 @@
1
- import type { AstNode } from '../node';
2
- import type { SignatureHelpProviderContext } from '../service';
1
+ import type { DeepReadonly } from '../common/index.js';
2
+ import type { AstNode } from '../node/index.js';
3
+ import type { SignatureHelpProviderContext } from '../service/index.js';
3
4
  export interface SignatureHelp {
4
5
  signatures: SignatureInfo[];
5
6
  activeSignature: number;
@@ -14,5 +15,5 @@ export interface ParameterInfo {
14
15
  label: [number, number];
15
16
  documentation?: string;
16
17
  }
17
- export declare type SignatureHelpProvider<N = AstNode> = (node: N, ctx: SignatureHelpProviderContext) => SignatureHelp | undefined;
18
+ export declare type SignatureHelpProvider<N extends AstNode = AstNode> = (node: DeepReadonly<N>, ctx: SignatureHelpProviderContext) => SignatureHelp | undefined;
18
19
  //# sourceMappingURL=SignatureHelpProvider.d.ts.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=SignatureHelpProvider.js.map
@@ -0,0 +1,26 @@
1
+ import type { AstNode } from '../../node/index.js';
2
+ import type { BinderContext } from '../../service/index.js';
3
+ declare const IsAsync: unique symbol;
4
+ export declare type Binder<N extends AstNode> = SyncBinder<N> | AsyncBinder<N>;
5
+ export interface SyncBinderInitializer<N extends AstNode> {
6
+ (node: N, ctx: BinderContext): void;
7
+ }
8
+ export interface SyncBinder<N extends AstNode> extends SyncBinderInitializer<N> {
9
+ [IsAsync]?: never;
10
+ }
11
+ export declare const SyncBinder: Readonly<{
12
+ create<N extends AstNode>(binder: SyncBinderInitializer<N>): SyncBinder<N>;
13
+ is(binder: Binder<any>): binder is SyncBinder<any>;
14
+ }>;
15
+ interface AsyncBinderInitializer<N extends AstNode> {
16
+ (node: N, ctx: BinderContext): Promise<void>;
17
+ }
18
+ export interface AsyncBinder<N extends AstNode> extends AsyncBinderInitializer<N> {
19
+ [IsAsync]: true;
20
+ }
21
+ export declare const AsyncBinder: Readonly<{
22
+ create<N extends AstNode>(binder: AsyncBinderInitializer<N>): AsyncBinder<N>;
23
+ is(binder: Binder<any>): binder is AsyncBinder<any>;
24
+ }>;
25
+ export {};
26
+ //# sourceMappingURL=Binder.d.ts.map
@@ -0,0 +1,18 @@
1
+ const IsAsync = Symbol('IsAsyncBinder');
2
+ export const SyncBinder = Object.freeze({
3
+ create(binder) {
4
+ return binder;
5
+ },
6
+ is(binder) {
7
+ return !binder[IsAsync];
8
+ },
9
+ });
10
+ export const AsyncBinder = Object.freeze({
11
+ create(binder) {
12
+ return Object.assign(binder, { [IsAsync]: true });
13
+ },
14
+ is(binder) {
15
+ return binder[IsAsync];
16
+ },
17
+ });
18
+ //# sourceMappingURL=Binder.js.map