@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,43 +1,33 @@
1
- /// <reference types="node" />
2
- import EventEmitter from 'events';
3
1
  import type { TextDocument } from 'vscode-languageserver-textdocument';
4
- import type { FileNode } from '../node';
5
- import { AstNode } from '../node';
6
- import type { Color, ColorInfo, ColorToken, InlayHint, SignatureHelp } from '../processor';
7
- import { ColorPresentation } from '../processor';
8
- import { Range } from '../source';
9
- import type { SymbolUsageType } from '../symbol';
10
- import { Downloader } from './Downloader';
11
- import { FileService } from './FileService';
12
- import { Hover } from './Hover';
13
- import { Logger } from './Logger';
14
- import { ProfilerFactory } from './Profiler';
15
- import type { ProjectInitializer } from './Project';
16
- import { Project } from './Project';
17
- import { SymbolLocations } from './SymbolLocations';
2
+ import type { Logger } from '../common/index.js';
3
+ import type { FileNode } from '../node/index.js';
4
+ import { AstNode } from '../node/index.js';
5
+ import type { Color, ColorInfo, ColorToken, InlayHint, SignatureHelp } from '../processor/index.js';
6
+ import { ColorPresentation } from '../processor/index.js';
7
+ import { Range } from '../source/index.js';
8
+ import type { SymbolUsageType } from '../symbol/index.js';
9
+ import { Hover } from './Hover.js';
10
+ import { ProfilerFactory } from './Profiler.js';
11
+ import type { ProjectOptions } from './Project.js';
12
+ import { Project } from './Project.js';
13
+ import { SymbolLocations } from './SymbolLocations.js';
18
14
  interface Options {
19
- cacheRoot: string;
20
- downloader?: Downloader;
21
- fs?: FileService;
22
- initializers?: readonly ProjectInitializer[];
23
15
  isDebugging?: boolean;
24
- logger?: Logger;
16
+ logger: Logger;
25
17
  profilers?: ProfilerFactory;
26
- projectPath: string;
18
+ project: ProjectOptions;
27
19
  }
28
- export declare class Service extends EventEmitter {
29
- readonly downloader: Downloader;
30
- readonly fs: FileService;
20
+ export declare class Service {
31
21
  readonly isDebugging: boolean;
32
22
  readonly logger: Logger;
33
23
  readonly profilers: ProfilerFactory;
34
24
  readonly project: Project;
35
- constructor({ cacheRoot, downloader, fs, initializers, isDebugging, logger, profilers, projectPath, }: Options);
25
+ constructor({ isDebugging, logger, profilers, project, }: Options);
36
26
  private debug;
37
27
  colorize(node: FileNode<AstNode>, doc: TextDocument, range?: Range): readonly ColorToken[];
38
28
  getColorInfo(node: FileNode<AstNode>, doc: TextDocument): ColorInfo[];
39
29
  getColorPresentation(file: FileNode<AstNode>, doc: TextDocument, range: Range, color: Color): ColorPresentation[];
40
- complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../processor").CompletionItem[];
30
+ complete(node: FileNode<AstNode>, doc: TextDocument, offset: number, triggerCharacter?: string): import("../processor/index.js").CompletionItem[];
41
31
  dataHackPubify(initialism: string): string;
42
32
  format(node: FileNode<AstNode>, doc: TextDocument, tabSize: number, insertSpaces: boolean): string;
43
33
  getHover(file: FileNode<AstNode>, doc: TextDocument, offset: number): Hover | undefined;
@@ -1,33 +1,28 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Service = void 0;
7
- const events_1 = __importDefault(require("events"));
8
- const node_1 = require("../node");
9
- const processor_1 = require("../processor");
10
- const source_1 = require("../source");
11
- const symbol_1 = require("../symbol");
12
- const Context_1 = require("./Context");
13
- const Downloader_1 = require("./Downloader");
14
- const FileService_1 = require("./FileService");
15
- const fileUtil_1 = require("./fileUtil");
16
- const Hover_1 = require("./Hover");
17
- const Logger_1 = require("./Logger");
18
- const Profiler_1 = require("./Profiler");
19
- const Project_1 = require("./Project");
20
- const SymbolLocations_1 = require("./SymbolLocations");
1
+ import { AstNode } from '../node/index.js';
2
+ import { ColorPresentation, completer, traversePreOrder } from '../processor/index.js';
3
+ import { Range } from '../source/index.js';
4
+ import { SymbolUsageTypes } from '../symbol/index.js';
5
+ import { ColorizerContext, CompleterContext, FormatterContext, ProcessorContext, SignatureHelpProviderContext } from './Context.js';
6
+ import { fileUtil } from './fileUtil.js';
7
+ import { Hover } from './Hover.js';
8
+ import { ProfilerFactory } from './Profiler.js';
9
+ import { Project } from './Project.js';
10
+ import { SymbolLocations } from './SymbolLocations.js';
21
11
  /* istanbul ignore next */
22
- class Service extends events_1.default {
23
- constructor({ cacheRoot, downloader, fs = FileService_1.FileService.create(cacheRoot), initializers = [], isDebugging = false, logger = Logger_1.Logger.create(), profilers = Profiler_1.ProfilerFactory.noop(), projectPath, }) {
24
- super();
25
- this.downloader = (downloader ?? (downloader = new Downloader_1.Downloader(cacheRoot, logger)));
26
- this.fs = fs;
12
+ export class Service {
13
+ isDebugging;
14
+ logger;
15
+ profilers;
16
+ project;
17
+ constructor({ isDebugging = false, logger, profilers = ProfilerFactory.noop(), project, }) {
27
18
  this.isDebugging = isDebugging;
28
19
  this.logger = logger;
29
20
  this.profilers = profilers;
30
- this.project = new Project_1.Project({ cacheRoot, downloader, fs, initializers, logger, profilers, projectPath });
21
+ this.project = new Project({
22
+ logger,
23
+ profilers,
24
+ ...project,
25
+ });
31
26
  }
32
27
  debug(message) {
33
28
  if (this.isDebugging) {
@@ -38,7 +33,7 @@ class Service extends events_1.default {
38
33
  try {
39
34
  this.debug(`Colorizing '${doc.uri}' # ${doc.version}`);
40
35
  const colorizer = this.project.meta.getColorizer(node.type);
41
- return colorizer(node, Context_1.ColorizerContext.create(this.project, { doc, range }));
36
+ return colorizer(node, ColorizerContext.create(this.project, { doc, range }));
42
37
  }
43
38
  catch (e) {
44
39
  this.logger.error(`[Service] [colorize] Failed for “${doc.uri}” #${doc.version}`, e);
@@ -49,7 +44,7 @@ class Service extends events_1.default {
49
44
  try {
50
45
  this.debug(`Getting color info for '${doc.uri}' # ${doc.version}`);
51
46
  const ans = [];
52
- (0, processor_1.traversePreOrder)(node, _ => true, node => node.color, node => ans.push({
47
+ traversePreOrder(node, _ => true, node => node.color, node => ans.push({
53
48
  color: Array.isArray(node.color) ? node.color : node.color.value,
54
49
  range: Array.isArray(node.color) ? node.range : (node.color.range ?? node.range),
55
50
  }));
@@ -62,13 +57,13 @@ class Service extends events_1.default {
62
57
  }
63
58
  getColorPresentation(file, doc, range, color) {
64
59
  try {
65
- this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${source_1.Range.toString(range)}`);
66
- let node = node_1.AstNode.findDeepestChild({ node: file, needle: range.start });
60
+ this.debug(`Getting color presentation for '${doc.uri}' # ${doc.version} @ ${Range.toString(range)}`);
61
+ let node = AstNode.findDeepestChild({ node: file, needle: range.start });
67
62
  while (node) {
68
63
  const nodeColor = node.color;
69
64
  if (nodeColor && !Array.isArray(nodeColor)) {
70
65
  const colorRange = nodeColor.range ?? node.range;
71
- return nodeColor.format.map(format => processor_1.ColorPresentation.fromColorFormat(format, color, colorRange));
66
+ return nodeColor.format.map(format => ColorPresentation.fromColorFormat(format, color, colorRange));
72
67
  }
73
68
  node = node.parent;
74
69
  }
@@ -83,7 +78,7 @@ class Service extends events_1.default {
83
78
  this.debug(`Getting completion for '${doc.uri}' # ${doc.version} @ ${offset}`);
84
79
  const shouldComplete = this.project.meta.shouldComplete(doc.languageId, triggerCharacter);
85
80
  if (shouldComplete) {
86
- return processor_1.completer.file(node, Context_1.CompleterContext.create(this.project, { doc, offset, triggerCharacter }));
81
+ return completer.file(node, CompleterContext.create(this.project, { doc, offset, triggerCharacter }));
87
82
  }
88
83
  }
89
84
  catch (e) {
@@ -112,7 +107,7 @@ class Service extends events_1.default {
112
107
  try {
113
108
  this.debug(`Formatting '${doc.uri}' # ${doc.version}`);
114
109
  const formatter = this.project.meta.getFormatter(node.type);
115
- return formatter(node, Context_1.FormatterContext.create(this.project, { doc, tabSize, insertSpaces }));
110
+ return formatter(node, FormatterContext.create(this.project, { doc, tabSize, insertSpaces }));
116
111
  }
117
112
  catch (e) {
118
113
  this.logger.error(`[Service] [format] Failed for “${doc.uri}” #${doc.version}`, e);
@@ -122,15 +117,15 @@ class Service extends events_1.default {
122
117
  getHover(file, doc, offset) {
123
118
  try {
124
119
  this.debug(`Getting hover for '${doc.uri}' # ${doc.version} @ ${offset}`);
125
- let node = node_1.AstNode.findDeepestChild({ node: file, needle: offset });
120
+ let node = AstNode.findDeepestChild({ node: file, needle: offset });
126
121
  while (node) {
127
122
  const symbol = this.project.symbols.resolveAlias(node.symbol);
128
123
  if (symbol) {
129
124
  const hover = `\`\`\`typescript\n(${symbol.category}${symbol.subcategory ? `/${symbol.subcategory}` : ''}) ${symbol.identifier}\n\`\`\`` + (symbol.desc ? `\n******\n${symbol.desc}` : '');
130
- return Hover_1.Hover.create(node.range, hover);
125
+ return Hover.create(node.range, hover);
131
126
  }
132
127
  if (node.hover) {
133
- return Hover_1.Hover.create(node.range, node.hover);
128
+ return Hover.create(node.range, node.hover);
134
129
  }
135
130
  node = node.parent;
136
131
  }
@@ -145,7 +140,7 @@ class Service extends events_1.default {
145
140
  // TODO: `range` argument is not used.
146
141
  this.debug(`Getting inlay hints for '${doc.uri}' # ${doc.version}`);
147
142
  const ans = [];
148
- const ctx = Context_1.ProcessorContext.create(this.project, { doc });
143
+ const ctx = ProcessorContext.create(this.project, { doc });
149
144
  for (const provider of this.project.meta.inlayHintProviders) {
150
145
  ans.push(...provider(node, ctx));
151
146
  }
@@ -159,7 +154,7 @@ class Service extends events_1.default {
159
154
  getSignatureHelp(node, doc, offset) {
160
155
  try {
161
156
  this.debug(`Getting signature help for '${doc.uri}' # ${doc.version} @ ${offset}`);
162
- const ctx = Context_1.SignatureHelpProviderContext.create(this.project, { doc, offset });
157
+ const ctx = SignatureHelpProviderContext.create(this.project, { doc, offset });
163
158
  for (const provider of this.project.meta.signatureHelpProviders) {
164
159
  const result = provider(node, ctx);
165
160
  if (result) {
@@ -178,10 +173,10 @@ class Service extends events_1.default {
178
173
  *
179
174
  * @returns Symbol locations of the selected symbol at `offset`, or `undefined` if there's no symbol at `offset`.
180
175
  */
181
- async getSymbolLocations(file, doc, offset, searchedUsages = symbol_1.SymbolUsageTypes, currentFileOnly = false) {
176
+ async getSymbolLocations(file, doc, offset, searchedUsages = SymbolUsageTypes, currentFileOnly = false) {
182
177
  try {
183
178
  this.debug(`Getting symbol locations of usage '${searchedUsages.join(',')}' for '${doc.uri}' # ${doc.version} @ ${offset} with currentFileOnly=${currentFileOnly}`);
184
- let node = node_1.AstNode.findDeepestChild({ node: file, needle: offset });
179
+ let node = AstNode.findDeepestChild({ node: file, needle: offset });
185
180
  while (node) {
186
181
  const symbol = this.project.symbols.resolveAlias(node.symbol);
187
182
  if (symbol) {
@@ -195,14 +190,14 @@ class Service extends events_1.default {
195
190
  }
196
191
  const locations = [];
197
192
  for (const loc of rawLocations) {
198
- const mappedUri = fileUtil_1.fileUtil.isFileUri(loc.uri)
193
+ const mappedUri = fileUtil.isFileUri(loc.uri)
199
194
  ? loc.uri
200
195
  : await this.project.fs.mapToDisk(loc.uri);
201
196
  if (mappedUri) {
202
197
  locations.push({ ...loc, uri: mappedUri });
203
198
  }
204
199
  }
205
- return SymbolLocations_1.SymbolLocations.create(node.range, locations.length ? locations : undefined);
200
+ return SymbolLocations.create(node.range, locations.length ? locations : undefined);
206
201
  }
207
202
  node = node.parent;
208
203
  }
@@ -213,5 +208,4 @@ class Service extends events_1.default {
213
208
  return undefined;
214
209
  }
215
210
  }
216
- exports.Service = Service;
217
211
  //# sourceMappingURL=Service.js.map
@@ -1,6 +1,6 @@
1
- import type { RangeLike } from '../source';
2
- import { Range } from '../source';
3
- import type { SymbolLocation } from '../symbol';
1
+ import type { RangeLike } from '../source/index.js';
2
+ import { Range } from '../source/index.js';
3
+ import type { SymbolLocation } from '../symbol/index.js';
4
4
  export interface SymbolLocations {
5
5
  /**
6
6
  * The range of the currently selected symbol.
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SymbolLocations = void 0;
4
- const source_1 = require("../source");
5
- var SymbolLocations;
1
+ import { Range } from '../source/index.js';
2
+ export var SymbolLocations;
6
3
  (function (SymbolLocations) {
7
4
  /* istanbul ignore next */
8
5
  function create(range, locations) {
9
6
  return {
10
- range: source_1.Range.get(range),
7
+ range: Range.get(range),
11
8
  locations,
12
9
  };
13
10
  }
14
11
  SymbolLocations.create = create;
15
- })(SymbolLocations = exports.SymbolLocations || (exports.SymbolLocations = {}));
12
+ })(SymbolLocations || (SymbolLocations = {}));
16
13
  //# sourceMappingURL=SymbolLocations.js.map
@@ -1,4 +1,4 @@
1
- import type { SymbolUtil } from '../symbol';
1
+ import type { SymbolUtil } from '../symbol/index.js';
2
2
  export declare type SymbolRegistrar = (this: void, symbols: SymbolUtil, ctx: SymbolRegistrarContext) => void;
3
3
  export interface SymbolRegistrarContext {
4
4
  }
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=SymbolRegistrar.js.map
@@ -0,0 +1,5 @@
1
+ import type { UriBinderContext } from './Context.js';
2
+ export declare type UriBinder = (uris: readonly string[], ctx: UriBinderContext) => void;
3
+ export declare type UriSorterRegistration = (this: void, a: string, b: string, next: UriSorter) => number;
4
+ export declare type UriSorter = (this: void, a: string, b: string) => number;
5
+ //# sourceMappingURL=UriProcessor.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=UriProcessor.js.map
@@ -1,12 +1,6 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { URL as Uri } from 'url';
1
+ import type { Externals, FsLocation } from '../common/index.js';
4
2
  export declare type RootUriString = `${string}/`;
5
3
  export declare type FileExtension = `.${string}`;
6
- /**
7
- * A string file path, string file URI, or a file URI object.
8
- */
9
- export declare type PathLike = string | Uri;
10
4
  export declare namespace fileUtil {
11
5
  /**
12
6
  * @param rootUris The root URIs. Each URI in this array must end with a slash (`/`).
@@ -45,25 +39,13 @@ export declare namespace fileUtil {
45
39
  * @returns The part from the last `/` to the end of the URI.
46
40
  */
47
41
  function basename(uri: string): string;
48
- /**
49
- * @param fileUri A file URI.
50
- * @returns The corresponding file path of the `fileUri` in platform-specific format.
51
- * @throws If the URI is not a file schema URI.
52
- */
53
- function fileUriToPath(fileUri: string): string;
54
- /**
55
- * @param path A file path.
56
- * @returns The corresponding file URI of the `path`.
57
- */
58
- function pathToFileUri(path: string): string;
59
- function normalize(uri: string): string;
60
- function getParentOfFile(path: PathLike): PathLike;
42
+ function getParentOfFile(externals: Externals, path: FsLocation): FsLocation;
61
43
  /**
62
44
  * @throws
63
45
  *
64
46
  * @param mode Default to `0o777` (`rwxrwxrwx`)
65
47
  */
66
- function ensureDir(path: PathLike, mode?: number): Promise<void>;
48
+ function ensureDir(externals: Externals, path: FsLocation, mode?: number): Promise<void>;
67
49
  /**
68
50
  * @throws
69
51
  *
@@ -71,11 +53,11 @@ export declare namespace fileUtil {
71
53
  *
72
54
  * @param mode Default to `0o777` (`rwxrwxrwx`)
73
55
  */
74
- function ensureParentOfFile(path: PathLike, mode?: number): Promise<void>;
75
- function chmod(path: PathLike, mode: number): Promise<void>;
76
- function ensureWritable(path: PathLike): Promise<void>;
77
- function markReadOnly(path: PathLike): Promise<void>;
78
- function readFile(path: PathLike): Promise<Buffer>;
56
+ function ensureParentOfFile(externals: Externals, path: FsLocation, mode?: number): Promise<void>;
57
+ function chmod(externals: Externals, path: FsLocation, mode: number): Promise<void>;
58
+ function ensureWritable(externals: Externals, path: FsLocation): Promise<void>;
59
+ function markReadOnly(externals: Externals, path: FsLocation): Promise<void>;
60
+ function readFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
79
61
  /**
80
62
  * @throws
81
63
  *
@@ -88,44 +70,32 @@ export declare namespace fileUtil {
88
70
  * * Mode: `0o666` (`rw-rw-rw-`)
89
71
  * * Flag: `w`
90
72
  */
91
- function writeFile(path: PathLike, data: Buffer | string, mode?: number): Promise<void>;
73
+ function writeFile(externals: Externals, path: FsLocation, data: Uint8Array | string, mode?: number): Promise<void>;
92
74
  /**
93
75
  * @throws
94
76
  */
95
- function readJson<T = any>(path: PathLike): Promise<T>;
77
+ function readJson(externals: Externals, path: FsLocation): Promise<unknown>;
96
78
  /**
97
79
  * @throws
98
80
  *
99
81
  * @see {@link writeFile}
100
82
  */
101
- function writeJson(path: PathLike, data: any): Promise<void>;
83
+ function writeJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
102
84
  /**
103
85
  * @throws
104
86
  */
105
- function readGzippedFile(path: PathLike): Promise<Buffer>;
87
+ function readGzippedFile(externals: Externals, path: FsLocation): Promise<Uint8Array>;
106
88
  /**
107
89
  * @throws
108
90
  */
109
- function writeGzippedFile(path: PathLike, buffer: Buffer | string): Promise<void>;
91
+ function writeGzippedFile(externals: Externals, path: FsLocation, buffer: Uint8Array | string): Promise<void>;
110
92
  /**
111
93
  * @throws
112
94
  */
113
- function readGzippedJson<T = any>(path: PathLike): Promise<T>;
95
+ function readGzippedJson(externals: Externals, path: FsLocation): Promise<unknown>;
114
96
  /**
115
97
  * @throws
116
98
  */
117
- function writeGzippedJson(path: PathLike, data: any): Promise<void>;
118
- /**
119
- * Show the file/directory in the platform-specific explorer program.
120
- *
121
- * Should not be called with unsanitized user-input path due to the possibility of
122
- * arbitrary code execution.
123
- *
124
- * @returns The `stdout` from the spawned child process.
125
- */
126
- function showFile(path: string): Promise<{
127
- stdout: string;
128
- stderr: string;
129
- }>;
99
+ function writeGzippedJson(externals: Externals, path: FsLocation, data: any): Promise<void>;
130
100
  }
131
101
  //# sourceMappingURL=fileUtil.d.ts.map