@eagleoutice/flowr 2.2.5 → 2.2.7

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.
@@ -8,15 +8,18 @@ const query_1 = require("./query");
8
8
  const html_hover_over_1 = require("../util/html-hover-over");
9
9
  const time_1 = require("../util/time");
10
10
  const built_in_1 = require("../dataflow/environments/built-in");
11
- function nodeString(id, formatter, processed) {
11
+ function nodeString(nodeId, formatter, processed) {
12
+ const isObj = typeof nodeId === 'object' && nodeId !== null && 'id' in nodeId;
13
+ const id = isObj ? nodeId.id : nodeId;
14
+ const info = isObj ? nodeId.info : undefined;
12
15
  if (id === built_in_1.BuiltIn) {
13
- return (0, ansi_1.italic)('built-in', formatter);
16
+ return (0, ansi_1.italic)('built-in', formatter) + (info ? ` (${JSON.stringify(info)})` : '');
14
17
  }
15
18
  const node = processed.normalize.idMap.get(id);
16
19
  if (node === undefined) {
17
- return `UNKNOWN: ${id}`;
20
+ return `UNKNOWN: ${id} (info: ${JSON.stringify(info)})`;
18
21
  }
19
- return `${(0, ansi_1.italic)('`' + (node.lexeme ?? node.info.fullLexeme ?? 'UNKNOWN') + '`', formatter)} (L.${node.location?.[0]})`;
22
+ return `${(0, ansi_1.italic)('`' + (node.lexeme ?? node.info.fullLexeme ?? 'UNKNOWN') + '`', formatter)} (L.${node.location?.[0]}${info ? ', ' + JSON.stringify(info) : ''})`;
20
23
  }
21
24
  function asciiCallContextSubHit(formatter, results, processed) {
22
25
  const result = [];
@@ -10,7 +10,12 @@ export declare class TreeSitterExecutor implements SyncParser<Parser.Tree> {
10
10
  readonly name = "tree-sitter";
11
11
  readonly parser: Parser;
12
12
  private static language;
13
- static initTreeSitter(): Promise<void>;
13
+ /**
14
+ * Initializes the underlying tree-sitter parser. This only needs to be called once globally.
15
+ * @param overrideWasmPath - The path to the tree-sitter-r wasm file, which takes precedence over the config and default paths if set.
16
+ * @param overrideTreeSitterWasmPath - The path to the tree-sitter wasm file, which takes precedence over the config and default paths if set.
17
+ */
18
+ static initTreeSitter(overrideWasmPath?: string, overrideTreeSitterWasmPath?: string): Promise<void>;
14
19
  constructor();
15
20
  rVersion(): Promise<string | 'unknown' | 'none'>;
16
21
  treeSitterVersion(): number;
@@ -7,8 +7,10 @@ exports.TreeSitterExecutor = exports.DEFAULT_TREE_SITTER_WASM_PATH = exports.DEF
7
7
  const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const config_1 = require("../../../config");
10
+ const log_1 = require("../../../util/log");
10
11
  exports.DEFAULT_TREE_SITTER_R_WASM_PATH = `${__dirname}/tree-sitter-r.wasm`;
11
12
  exports.DEFAULT_TREE_SITTER_WASM_PATH = `${__dirname}/tree-sitter.wasm`;
13
+ const wasmLog = log_1.log.getSubLogger({ name: 'tree-sitter-wasm' });
12
14
  /**
13
15
  * Synchronous and (way) faster alternative to the {@link RShell} using tree-sitter.
14
16
  */
@@ -16,9 +18,13 @@ class TreeSitterExecutor {
16
18
  name = 'tree-sitter';
17
19
  parser;
18
20
  static language;
19
- static async initTreeSitter() {
20
- const config = (0, config_1.getEngineConfig)('tree-sitter');
21
- const treeSitterWasmPath = config?.treeSitterWasmPath ?? exports.DEFAULT_TREE_SITTER_WASM_PATH;
21
+ /**
22
+ * Initializes the underlying tree-sitter parser. This only needs to be called once globally.
23
+ * @param overrideWasmPath - The path to the tree-sitter-r wasm file, which takes precedence over the config and default paths if set.
24
+ * @param overrideTreeSitterWasmPath - The path to the tree-sitter wasm file, which takes precedence over the config and default paths if set.
25
+ */
26
+ static async initTreeSitter(overrideWasmPath, overrideTreeSitterWasmPath) {
27
+ const treeSitterWasmPath = overrideTreeSitterWasmPath ?? (0, config_1.getEngineConfig)('tree-sitter')?.treeSitterWasmPath ?? exports.DEFAULT_TREE_SITTER_WASM_PATH;
22
28
  // noinspection JSUnusedGlobalSymbols - this is used by emscripten, see https://emscripten.org/docs/api_reference/module.html
23
29
  await web_tree_sitter_1.default.init({
24
30
  locateFile: (path, prefix) => {
@@ -27,9 +33,12 @@ class TreeSitterExecutor {
27
33
  return treeSitterWasmPath;
28
34
  }
29
35
  return prefix + path;
30
- }
36
+ },
37
+ onAbort: (s) => wasmLog.error(`Tree-sitter wasm aborted: ${s}`),
38
+ print: (s) => wasmLog.debug(s),
39
+ printErr: (s) => wasmLog.error(s)
31
40
  });
32
- const wasmPath = config?.wasmPath ?? exports.DEFAULT_TREE_SITTER_R_WASM_PATH;
41
+ const wasmPath = overrideWasmPath ?? (0, config_1.getEngineConfig)('tree-sitter')?.wasmPath ?? exports.DEFAULT_TREE_SITTER_R_WASM_PATH;
33
42
  TreeSitterExecutor.language = await web_tree_sitter_1.default.Language.load(wasmPath);
34
43
  }
35
44
  constructor() {
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = flowrVersion;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.2.5';
6
+ const version = '2.2.7';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }