@eagleoutice/flowr 2.2.2 → 2.2.3

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 (68) hide show
  1. package/cli/repl/commands/repl-dataflow.js +7 -4
  2. package/cli/repl/commands/repl-parse.js +43 -2
  3. package/cli/repl/print-version.d.ts +1 -0
  4. package/cli/repl/print-version.js +7 -2
  5. package/cli/repl/server/connection.js +10 -8
  6. package/core/pipeline-executor.d.ts +6 -0
  7. package/core/pipeline-executor.js +8 -0
  8. package/core/print/dataflow-printer.js +3 -0
  9. package/core/steps/all/core/01-parse-tree-sitter.d.ts +7 -0
  10. package/core/steps/pipeline/default-pipelines.d.ts +57 -47
  11. package/core/steps/pipeline/default-pipelines.js +23 -2
  12. package/core/steps/pipeline/pipeline.d.ts +1 -1
  13. package/core/steps/pipeline/pipeline.js +1 -1
  14. package/core/steps/pipeline-step.d.ts +1 -3
  15. package/dataflow/environments/resolve-by-name.d.ts +3 -2
  16. package/dataflow/environments/resolve-by-name.js +4 -4
  17. package/dataflow/extractor.d.ts +10 -0
  18. package/dataflow/extractor.js +10 -0
  19. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
  20. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +20 -4
  21. package/documentation/doc-util/doc-dfg.d.ts +5 -3
  22. package/documentation/doc-util/doc-dfg.js +10 -8
  23. package/documentation/doc-util/doc-files.d.ts +1 -1
  24. package/documentation/doc-util/doc-files.js +1 -1
  25. package/documentation/doc-util/doc-normalized-ast.d.ts +2 -1
  26. package/documentation/doc-util/doc-normalized-ast.js +4 -5
  27. package/documentation/doc-util/doc-repl.d.ts +6 -2
  28. package/documentation/doc-util/doc-repl.js +10 -6
  29. package/documentation/doc-util/doc-structure.d.ts +1 -1
  30. package/documentation/doc-util/doc-types.d.ts +7 -5
  31. package/documentation/doc-util/doc-types.js +15 -10
  32. package/documentation/index.d.ts +9 -0
  33. package/documentation/index.js +26 -0
  34. package/documentation/print-capabilities-markdown.js +105 -19
  35. package/documentation/print-core-wiki.d.ts +1 -0
  36. package/documentation/print-core-wiki.js +406 -0
  37. package/documentation/print-dataflow-graph-wiki.js +27 -27
  38. package/documentation/print-interface-wiki.js +1 -1
  39. package/documentation/print-linting-and-testing-wiki.js +26 -8
  40. package/documentation/print-normalized-ast-wiki.js +22 -17
  41. package/documentation/print-query-wiki.js +7 -7
  42. package/documentation/print-search-wiki.js +2 -1
  43. package/package.json +3 -2
  44. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  45. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +1 -1
  46. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -1
  47. package/queries/catalog/search-query/search-query-format.js +1 -1
  48. package/r-bridge/data/data.d.ts +48 -7
  49. package/r-bridge/data/data.js +62 -8
  50. package/r-bridge/data/types.d.ts +7 -1
  51. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
  52. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -5
  53. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +6 -0
  54. package/r-bridge/lang-4.x/ast/parser/json/format.js +6 -0
  55. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +13 -2
  56. package/r-bridge/lang-4.x/ast/parser/json/parser.js +19 -3
  57. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.d.ts +3 -0
  58. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -0
  59. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +6 -1
  60. package/r-bridge/parser.d.ts +10 -0
  61. package/r-bridge/parser.js +26 -2
  62. package/search/flowr-search-builder.d.ts +1 -2
  63. package/search/flowr-search-builder.js +1 -3
  64. package/util/mermaid/dfg.d.ts +3 -0
  65. package/util/mermaid/dfg.js +24 -8
  66. package/util/strings.d.ts +9 -0
  67. package/util/strings.js +14 -0
  68. package/util/version.js +1 -1
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const log_1 = require("../../test/functionality/_helper/log");
4
7
  const doc_code_1 = require("./doc-util/doc-code");
5
8
  const doc_files_1 = require("./doc-util/doc-files");
6
9
  const doc_structure_1 = require("./doc-util/doc-structure");
10
+ const doc_types_1 = require("./doc-util/doc-types");
11
+ const path_1 = __importDefault(require("path"));
7
12
  function getText() {
13
+ const { info } = (0, doc_types_1.getTypesFromFolderAsMermaid)({
14
+ rootFolder: path_1.default.resolve('./test'),
15
+ files: [path_1.default.resolve('./src/dataflow/graph/dataflowgraph-builder.ts')],
16
+ typeName: 'parameter',
17
+ inlineTypes: doc_types_1.mermaidHide
18
+ });
8
19
  return `
9
20
  For the latest code coverage information, see [codecov.io](${doc_files_1.FlowrCodecovRef}),
10
21
  for the latest benchmark results, see the [benchmark results](${doc_files_1.FlowrSiteBaseRef}/wiki/stats/benchmark) wiki page.
@@ -53,7 +64,7 @@ If you want to run the tests without the watch mode, you can use:
53
64
 
54
65
  ${(0, doc_code_1.codeBlock)('shell', 'npm run test -- --no-watch')}
55
66
 
56
- To run all tests, including a coverage report and label summary, run:
67
+ To run all tests, including a coverage report and label summary, run:
57
68
 
58
69
  ${(0, doc_code_1.codeBlock)('shell', 'npm run test-full')}
59
70
 
@@ -64,7 +75,7 @@ It is up to the [ci](#ci-pipeline) to run the tests on different systems to ensu
64
75
 
65
76
  #### Test Structure
66
77
 
67
- All functionality tests are to be located under [test/functionality](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality).
78
+ All functionality tests are to be located under [test/functionality](${doc_files_1.RemoteFlowrFilePathBaseRef}/test/functionality).
68
79
 
69
80
  This folder contains three special and important elements:
70
81
 
@@ -76,19 +87,23 @@ ${(0, doc_structure_1.block)({
76
87
  type: 'WARNING',
77
88
  content: `
78
89
  We name all test files using the \`.test.ts\` suffix and try to run them in parallel.
79
- Whenever this is not possible (e.g., when using \`withShell\`), please use \`describe.sequential\`
90
+ Whenever this is impossible (e.g., when using ${(0, doc_types_1.shortLink)('withShell', info)}), please use _\`describe.sequential\`_
80
91
  to disable parallel execution for the respective test (otherwise, such tests are flaky).
81
92
  `
82
93
  })}
83
94
 
84
95
  #### Writing a Test
85
96
 
86
- Currently, this is heavily dependent on what you want to test (normalization, dataflow, quad-export, ...)
97
+ Currently, this is heavily dependent on what you want to test (normalization, dataflow, quad-export, )
87
98
  and it is probably best to have a look at existing tests in that area to get an idea of what comfort functionality is available.
88
99
 
89
- Generally, tests should be [labeled](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality/_helper/label.ts) according to the *flowR* capabilities they test. The set of currently supported capabilities and their IDs can be found in ${(0, doc_files_1.getFilePathMd)('../r-bridge/data/data.ts')}. The resulting labels are used in the test report that is generated as part of the test output. They group tests by the capabilities they test and allow the report to display how many tests ensure that any given capability is properly supported.
100
+ Generally, tests should be [labeled](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality/_helper/label.ts) according to the *flowR* capabilities they test.
101
+ The set of currently supported capabilities and their IDs can be found in ${(0, doc_files_1.getFilePathMd)('../r-bridge/data/data.ts')}.
102
+ The resulting labels are used in the test report that is generated as part of the test output.
103
+ They group tests by the capabilities they test and allow the report to display how many tests ensure that any given capability is properly supported.
90
104
 
91
- Various helper functions are available to ease in writing tests with common behaviors, like testing for dataflow, slicing or query results. These can be found in [the \`_helper\` subdirectory](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality/_helper).
105
+ Various helper functions are available to ease in writing tests with common behaviors, like testing for dataflow, slicing or query results.
106
+ These can be found in [the \`_helper\` subdirectory](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality/_helper).
92
107
 
93
108
  For example, an [existing test](${doc_files_1.RemoteFlowrFilePathBaseRef}test/functionality/dataflow/processing-of-elements/atomic/dataflow-atomic.test.ts) that tests the dataflow graph of a simple variable looks like this:
94
109
  ${(0, doc_code_1.codeBlock)('typescript', `
@@ -96,11 +111,14 @@ assertDataflow(label('simple variable', ['name-normal']), shell,
96
111
  'x', emptyGraph().use('0', 'x')
97
112
  );
98
113
  `)}
114
+ Have a look at ${(0, doc_types_1.shortLink)('assertDataflow', info)}, ${(0, doc_types_1.shortLink)('label', info)}, and ${(0, doc_types_1.shortLink)('emptyGraph', info)} for more information.
99
115
 
100
116
  When writing dataflow tests, additional settings can be used to reduce the amount of graph data that needs to be pre-written. Notably:
101
117
 
102
- - \`expectIsSubgraph\` indicates that the expected graph is a subgraph, rather than the full graph that the test should generate. The test will then only check if the supplied graph is contained in the result graph, rather than an exact match.
103
- - \`resolveIdsAsCriterion\` indicates that the ids given in the expected (sub)graph should be resolved as [slicing criteria](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion) rather than actual ids. For example, passing \`12@a\` as an id in the expected (sub)graph will cause it to be resolved as the corresponding id.
118
+ - ${(0, doc_types_1.shortLink)('expectIsSubgraph', info)} indicates that the expected graph is a subgraph, rather than the full graph that the test should generate.
119
+ The test will then only check if the supplied graph is contained in the result graph, rather than an exact match.
120
+ - ${(0, doc_types_1.shortLink)('resolveIdsAsCriterion', info)} indicates that the ids given in the expected (sub)graph should be resolved as [slicing criteria](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion) rather than actual ids.
121
+ For example, passing \`12@a\` as an id in the expected (sub)graph will cause it to be resolved as the corresponding id.
104
122
 
105
123
  The following example shows both in use:
106
124
  ${(0, doc_code_1.codeBlock)('typescript', `
@@ -19,21 +19,21 @@ const retriever_1 = require("../r-bridge/retriever");
19
19
  const visitor_1 = require("../r-bridge/lang-4.x/ast/model/processing/visitor");
20
20
  const collect_1 = require("../r-bridge/lang-4.x/ast/model/collect");
21
21
  const normalized_ast_fold_1 = require("../abstract-interpretation/normalized-ast-fold");
22
+ const default_pipelines_1 = require("../core/steps/pipeline/default-pipelines");
22
23
  async function getText(shell) {
23
24
  const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
24
25
  const now = performance.now();
25
26
  const types = (0, doc_types_1.getTypesFromFolderAsMermaid)({
26
- rootFolder: path_1.default.resolve('./src/r-bridge/lang-4.x/ast/model/'),
27
- files: [path_1.default.resolve('./src/abstract-interpretation/normalized-ast-fold.ts'), path_1.default.resolve('./src/core/steps/pipeline/default-pipelines.ts')],
27
+ rootFolder: path_1.default.resolve('./src'),
28
28
  typeName: 'RNode',
29
29
  inlineTypes: doc_types_1.mermaidHide
30
30
  });
31
31
  const elapsed = performance.now() - now;
32
32
  return `${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'normalized ast', rVersion: rversion })}
33
33
 
34
- _flowR_ produces a normalized version of R's abstract syntax tree (AST),
34
+ _flowR_ produces a normalized version of R's abstract syntax tree (AST),
35
35
  offering the following benefits:
36
-
36
+
37
37
  1. abstract away from intricacies of the R parser
38
38
  2. provide a version-independent representation of the program
39
39
  3. decorate the AST with additional information, e.g., parent relations and nesting information
@@ -49,12 +49,10 @@ Each edge is labeled with the type of the parent-child relationship (the "role")
49
49
 
50
50
  ${await (0, doc_normalized_ast_1.printNormalizedAstForCode)(shell, 'x <- 2 * 3 + 1', { showCode: false, prefix: 'flowchart LR\n' })}
51
51
 
52
- &nbsp;
53
-
54
52
  > [!TIP]
55
53
  > If you want to investigate the normalized AST,
56
54
  > you can either use the [Visual Studio Code extension](${doc_files_1.FlowrGithubBaseRef}/vscode-flowr) or the ${(0, doc_cli_option_1.getReplCommand)('normalize*')}
57
- > command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information).
55
+ > command in the REPL (see the [Interface wiki page](${doc_files_1.FlowrWikiBaseRef}/Interface) for more information).
58
56
 
59
57
  Indicative of the normalization is the root expression list node, which is present in every normalized AST.
60
58
  In general, we provide node types for:
@@ -84,7 +82,7 @@ Most notably, the \`info\` field holds the \`id\` of the node, which is used to
84
82
 
85
83
  In summary, we have the following types:
86
84
 
87
- ${(0, doc_structure_1.details)('Normalized AST Node Types', (0, doc_types_1.printHierarchy)({ program: types.program, hierarchy: types.info, root: 'RNode', collapseFromNesting: Number.MAX_VALUE }))}
85
+ ${(0, doc_structure_1.details)('Normalized AST Node Types', (0, doc_types_1.printHierarchy)({ program: types.program, info: types.info, root: 'RNode', collapseFromNesting: Number.MAX_VALUE }))}
88
86
 
89
87
  The following segments intend to give you an overview of how to work with the normalized AST:
90
88
 
@@ -94,7 +92,7 @@ The following segments intend to give you an overview of how to work with the no
94
92
  ## How Get a Normalized AST
95
93
 
96
94
  As explained alongside the [Interface](${doc_files_1.FlowrWikiBaseRef}/Interface#the-pipeline-executor) wiki page, you can use the
97
- \`${pipeline_executor_1.PipelineExecutor.name}\` to get the ${(0, doc_types_1.shortLink)('NormalizedAst', types.info)}. If you are only interested in the normalization,
95
+ ${(0, doc_types_1.shortLink)(pipeline_executor_1.PipelineExecutor.name, types.info)} to get the ${(0, doc_types_1.shortLink)('NormalizedAst', types.info)}. If you are only interested in the normalization,
98
96
  a pipeline like the ${(0, doc_types_1.shortLink)('DEFAULT_NORMALIZE_PIPELINE', types.info)} suffices:
99
97
 
100
98
  ${(0, doc_code_1.codeBlock)('ts', `
@@ -106,7 +104,7 @@ async function getAst(code: string): Promise<RNode> {
106
104
  return result.normalize.ast;
107
105
  }`)}
108
106
 
109
- From the REPL, you can use the ${(0, doc_cli_option_1.getReplCommand)('normalize')} command.
107
+ From the REPL, you can use the ${(0, doc_cli_option_1.getReplCommand)('normalize')} command.
110
108
 
111
109
  ## Traversing the Normalized AST
112
110
 
@@ -114,12 +112,11 @@ We provide two ways to traverse the normalized AST: [Visitors](#visitors) and [F
114
112
 
115
113
  ### Visitors
116
114
 
117
- If you want a simple visitor which traverses the AST, the \`${visitor_1.visitAst.name}\` function from
118
- ${(0, doc_files_1.getFilePathMd)('../r-bridge/lang-4.x/ast/model/processing/visitor.ts')} is a good starting point.
115
+ If you want a simple visitor which traverses the AST, the ${(0, doc_types_1.shortLink)(visitor_1.visitAst.name, types.info)} function is a good starting point.
119
116
  You may specify functions to be called whenever you enter and exit a node during the traversal, and any
120
117
  computation is to be done by side effects.
121
118
  For example, if you want to collect all the \`id\`s present within a normalized (sub-)ast,
122
- as it is done by the ${collect_1.collectAllIds.name} function, you can use the following visitor:
119
+ as it is done by the ${(0, doc_types_1.shortLink)(collect_1.collectAllIds.name, types.info)} function, you can use the following visitor:
123
120
 
124
121
  ${(0, doc_code_1.codeBlock)('ts', `
125
122
  const ids = new Set<NodeId>();
@@ -131,12 +128,12 @@ return ids;
131
128
 
132
129
  ### Folds
133
130
 
134
- We formulate a fold with the base class \`${normalized_ast_fold_1.DefaultNormalizedAstFold.name}\` in ${(0, doc_files_1.getFilePathMd)('../abstract-interpretation/normalized-ast-fold.ts')}.
131
+ We formulate a fold with the base class ${(0, doc_types_1.shortLink)(normalized_ast_fold_1.DefaultNormalizedAstFold.name, types.info)} in ${(0, doc_files_1.getFilePathMd)('../abstract-interpretation/normalized-ast-fold.ts')}.
135
132
  Using this class, you can create your own fold behavior by overwriting the default methods.
136
133
  By default, the class provides a monoid abstraction using the _empty_ from the constructor and the _concat_ method.
137
134
 
138
135
 
139
- ${(0, doc_types_1.printHierarchy)({ program: types.program, hierarchy: types.info, root: 'DefaultNormalizedAstFold' })}
136
+ ${(0, doc_types_1.printHierarchy)({ program: types.program, info: types.info, root: 'DefaultNormalizedAstFold' })}
140
137
 
141
138
  Now, of course, we could provide hundreds of examples here, but we use tests to verify that the fold behaves as expected
142
139
  and happily point to them at ${(0, doc_files_1.getFilePathMd)('../../test/functionality/r-bridge/normalize-ast-fold.test.ts')}.
@@ -173,8 +170,8 @@ class MyMathFold<Info> extends ${normalized_ast_fold_1.DefaultNormalizedAstFold.
173
170
  }
174
171
  `)}
175
172
 
176
- Now, we can use the \`${pipeline_executor_1.PipelineExecutor.name}\` to get the normalized AST and apply the fold:
177
-
173
+ Now, we can use the ${(0, doc_types_1.shortLink)(pipeline_executor_1.PipelineExecutor.name, types.info)} to get the normalized AST and apply the fold:
174
+
178
175
  ${(0, doc_code_1.codeBlock)('ts', `
179
176
  const shell = new ${shell_1.RShell.name}();
180
177
  const ast = (await new ${pipeline_executor_1.PipelineExecutor.name}(DEFAULT_NORMALIZE_PIPELINE, {
@@ -185,6 +182,14 @@ const result = new MyMathFold().fold(ast);
185
182
  console.log(result); // -> 7
186
183
  `)}
187
184
 
185
+ ${(0, doc_structure_1.block)({
186
+ type: 'NOTE',
187
+ content: `
188
+ If you want to retrieve the normalized AST with the [Tree-Sitter Engine](${doc_files_1.FlowrWikiBaseRef}/Engines),
189
+ you may use the ${(0, doc_types_1.shortLink)('TREE_SITTER_NORMALIZE_PIPELINE', types.info)} or directly rely on one of the
190
+ helper functions like ${(0, doc_types_1.shortLink)(default_pipelines_1.createNormalizePipeline.name, types.info)}.
191
+ `
192
+ })}
188
193
  `;
189
194
  }
190
195
  /** if we run this script, we want a Markdown representation of the capabilities */
@@ -59,9 +59,9 @@ Besides this, we provide the following ways to automatically categorize and link
59
59
  It's also possible to filter the results based on the following properties:
60
60
 
61
61
  1. **File** (\`fileFilter\`): This allows you to filter the results based on the file in which the call is located. This can be useful if you are only interested in calls in, e.g., specific folders.
62
- The \`fileFilter\` property is an object made up of two properties:
63
- - **Filter** (\`filter\`): A regular expression that a node's file attribute must match to be considered.
64
- - **Include Undefined Files** (\`includeUndefinedFiles\`): If \`fileFilter\` is set, but a node's file attribute is not present, should we include it in the results? Defaults to \`true\`.
62
+ The \`fileFilter\` property is an object made up of two properties:
63
+ - **Filter** (\`filter\`): A regular expression that a node's file attribute must match to be considered.
64
+ - **Include Undefined Files** (\`includeUndefinedFiles\`): If \`fileFilter\` is set, but a node's file attribute is not present, should we include it in the results? Defaults to \`true\`.
65
65
 
66
66
  Re-using the example code from above, the following query attaches all calls to \`mean\` to the kind \`visualize\` and the subkind \`text\`,
67
67
  all calls that start with \`read_\` to the kind \`input\` but only if they are not locally overwritten, and the subkind \`csv-file\`, and links all calls to \`points\` to the last call to \`plot\`:
@@ -164,7 +164,7 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
164
164
  }], { showCode: false })}
165
165
 
166
166
  In this simple scenario, the _lineage_ is equivalent to the slice (and in-fact the complete code).
167
- In general the lineage is smaller and makes no executability guarantees.
167
+ In general the lineage is smaller and makes no guarantees on executability.
168
168
  It is just a quick and neither complete nor sound way to get information on where the variable originates from.
169
169
 
170
170
  This query replaces the old [\`request-lineage\`](${doc_files_1.FlowrWikiBaseRef}/Interface#message-request-lineage) message.
@@ -368,7 +368,7 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
368
368
  criteria: ['3@x']
369
369
  }], { showCode: false })}
370
370
 
371
- In general you may be uninterested in seeing the reconstructed version and want to save some computation time, for this,
371
+ In general, you may be uninterested in seeing the reconstructed version and want to save some computation time, for this,
372
372
  you can use the \`noReconstruction\` flag.
373
373
 
374
374
  ${(0, doc_structure_1.details)('No Reconstruction Example', await (0, doc_query_1.showQuery)(shell, exampleCode, [{
@@ -449,7 +449,7 @@ ${await (0, doc_query_1.showQuery)(shell, longerCode, [{
449
449
  });
450
450
  const exampleCode = 'x + 1\nx * 2';
451
451
  return `
452
- A query like the ${(0, doc_query_1.linkToQueryOfName)('id-map')} query can return a really big result, especially for larger scripts.
452
+ A query like the ${(0, doc_query_1.linkToQueryOfName)('id-map')} query can return a huge result, especially for larger scripts.
453
453
  If you are not interested in all of the information contained within the full map, you can use the location map query to get a simple mapping of ids to their location in the source file.
454
454
 
455
455
  Consider you have the following code:
@@ -489,7 +489,7 @@ Queries are JSON arrays of query objects, each of which uses a \`type\` property
489
489
  In general, we separate two types of queries:
490
490
 
491
491
  1. **Active Queries**: Are exactly what you would expect from a query (e.g., the ${(0, doc_query_1.linkToQueryOfName)('call-context')}). They fetch information from the dataflow graph.
492
- 2. **Virtual Queries**: Are used to structure your queries (e.g., the ${(0, doc_query_1.linkToQueryOfName)('compound')}).
492
+ 2. **Virtual Queries**: Are used to structure your queries (e.g., the ${(0, doc_query_1.linkToQueryOfName)('compound')}).
493
493
 
494
494
  We separate these from a concept perspective.
495
495
  For now, we support the following **active** queries (which we will refer to simply as a \`query\`):
@@ -12,6 +12,7 @@ const flowr_search_builder_1 = require("../search/flowr-search-builder");
12
12
  const vertex_1 = require("../dataflow/graph/vertex");
13
13
  const doc_types_1 = require("./doc-util/doc-types");
14
14
  const path_1 = __importDefault(require("path"));
15
+ const flowr_search_executor_1 = require("../search/flowr-search-executor");
15
16
  async function getText(shell) {
16
17
  const rversion = (await shell.usedRVersion())?.format() ?? 'unknown';
17
18
  const types = (0, doc_types_1.getTypesFromFolderAsMermaid)({
@@ -24,7 +25,7 @@ async function getText(shell) {
24
25
  This page briefly summarizes flowR's search API which provides a set of functions to search for nodes in the [Dataflow Graph](${doc_files_1.FlowrWikiBaseRef}/Dataflow%20Graph) and the
25
26
  [Normalized AST](${doc_files_1.FlowrWikiBaseRef}/Normalized%20AST) of a given R code (the search will always consider both, with respect to your search query).
26
27
  Please see the [Interface](${doc_files_1.FlowrWikiBaseRef}/Interface) wiki page for more information on how to access this API.
27
- Within code, you can execute a search using the ${(0, doc_types_1.shortLink)('runSearch', types.info)} function.
28
+ Within code, you can execute a search using the ${(0, doc_types_1.shortLink)(flowr_search_executor_1.runSearch.name, types.info)} function.
28
29
 
29
30
  For an initial motivation, let's have a look at the following example:
30
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "wiki:df-graph": "ts-node src/documentation/print-dataflow-graph-wiki.ts",
29
29
  "wiki:normalized-ast": "ts-node src/documentation/print-normalized-ast-wiki.ts",
30
30
  "wiki:query-api": "ts-node src/documentation/print-query-wiki.ts",
31
+ "wiki:core": "ts-node src/documentation/print-core-wiki.ts",
31
32
  "wiki:engines": "ts-node src/documentation/print-engines-wiki.ts",
32
33
  "wiki:search-api": "ts-node src/documentation/print-search-wiki.ts",
33
34
  "wiki:linting-and-testing": "ts-node src/documentation/print-linting-and-testing-wiki.ts",
@@ -196,7 +197,7 @@
196
197
  "@types/ws": "^8.5.10",
197
198
  "@typescript-eslint/eslint-plugin": "^7.8.0",
198
199
  "@vitest/coverage-v8": "^2.1.4",
199
- "esbuild": "^0.23.1",
200
+ "esbuild": "^0.25.0",
200
201
  "eslint": "^8.57.1",
201
202
  "license-checker": "^25.0.1",
202
203
  "npm-run-all": "^4.1.5",
@@ -22,6 +22,6 @@ exports.HappensBeforeQueryDefinition = {
22
22
  type: joi_1.default.string().valid('happens-before').required().description('The type of the query.'),
23
23
  a: joi_1.default.string().required().description('The first slicing criterion.'),
24
24
  b: joi_1.default.string().required().description('The second slicing criterion.')
25
- }).description('The id map query retrieves the id map from the normalized AST.')
25
+ }).description('Happens-Before tracks whether a always happens before b.')
26
26
  };
27
27
  //# sourceMappingURL=happens-before-query-format.js.map
@@ -19,7 +19,7 @@ function executeResolveValueQuery({ dataflow: { graph, environment }, ast }, que
19
19
  }
20
20
  const values = query.criteria
21
21
  .map(criteria => (0, node_id_1.recoverName)((0, parse_1.slicingCriterionToId)(criteria, ast.idMap), ast.idMap))
22
- .flatMap(ident => (0, resolve_by_name_1.resolveToValues)(ident, environment, graph));
22
+ .flatMap(ident => (0, resolve_by_name_1.resolveToValues)(ident, environment, graph.idMap ?? ast.idMap));
23
23
  results[key] = {
24
24
  values: [...new Set(values)]
25
25
  };
@@ -44,6 +44,6 @@ exports.ResolveValueQueryDefinition = {
44
44
  schema: joi_1.default.object({
45
45
  type: joi_1.default.string().valid('resolve-value').required().description('The type of the query.'),
46
46
  criteria: joi_1.default.array().items(joi_1.default.string()).min(1).required().description('The slicing criteria to use.'),
47
- }).description('Resolve Value query used to get definitions of an identifier')
47
+ }).description('The resolve value query used to get definitions of an identifier')
48
48
  };
49
49
  //# sourceMappingURL=resolve-value-query-format.js.map
@@ -24,6 +24,6 @@ exports.SearchQueryDefinition = {
24
24
  schema: joi_1.default.object({
25
25
  type: joi_1.default.string().valid('search').required().description('The type of the query.'),
26
26
  search: joi_1.default.object().required().description('The search query to execute.')
27
- }).description('The id map query retrieves the id map from the normalized AST.')
27
+ }).description('The search query searches the normalized AST and dataflow graph for nodes that match the given search query.')
28
28
  };
29
29
  //# sourceMappingURL=search-query-format.js.map
@@ -1,10 +1,12 @@
1
1
  export declare const flowrCapabilities: {
2
2
  readonly name: "Capabilities of flowR";
3
3
  readonly description: "This is an evolving representation of what started with #636 to formulate capabilities in a structured format.";
4
- readonly version: "0.0.1";
4
+ readonly version: "0.0.2";
5
5
  readonly capabilities: readonly [{
6
6
  readonly name: "Names and Identifiers";
7
7
  readonly id: "names-and-identifiers";
8
+ readonly description: "The recognition of syntactical and non-syntactical names, including their resolutions to corresponding definitions.";
9
+ readonly example: (parser: import("../parser").KnownParser) => Promise<string>;
8
10
  readonly capabilities: readonly [{
9
11
  readonly name: "Form";
10
12
  readonly id: "form";
@@ -12,17 +14,41 @@ export declare const flowrCapabilities: {
12
14
  readonly name: "Normal";
13
15
  readonly id: "name-normal";
14
16
  readonly supported: "fully";
15
- readonly description: "_Recognize constructs like `a`, `plot`, ..._";
17
+ readonly description: "_Recognize symbol uses like `a`, `plot`, ..._ (i.e., \"normal variables or function calls\").";
18
+ readonly url: [{
19
+ readonly name: string;
20
+ readonly href: "https://adv-r.hadley.nz/names-values.html#binding-basics";
21
+ }, {
22
+ readonly name: string;
23
+ readonly href: "https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Identifiers-1";
24
+ }];
16
25
  }, {
17
26
  readonly name: "Quoted";
18
27
  readonly id: "name-quoted";
19
28
  readonly supported: "fully";
20
- readonly description: "_Recognize `\"a\"`, `'plot'`, ..._";
29
+ readonly description: "_Recognize `\"a\"`, `'plot'`, ..._ In general, R allows to envelop names in quotations to allow for special characters such as spaces in variable names. However, this only works in the context of definitions. To access these names as variables, one has to either use function such as `get` or escape the name with backticks.";
30
+ readonly url: [{
31
+ readonly name: string;
32
+ readonly href: "https://adv-r.hadley.nz/names-values.html#non-syntactic";
33
+ }];
21
34
  }, {
22
35
  readonly name: "Escaped";
23
36
  readonly id: "name-escaped";
24
37
  readonly supported: "fully";
25
38
  readonly description: "_Recognize `` `a` ``, `` `plot` ``, ..._";
39
+ readonly url: [{
40
+ readonly name: string;
41
+ readonly href: "https://adv-r.hadley.nz/names-values.html#non-syntactic";
42
+ }];
43
+ }, {
44
+ readonly name: "Created";
45
+ readonly id: "name-created";
46
+ readonly supported: "partially";
47
+ readonly description: "_Recognize functions which resolve strings as identifiers, such as `get`, ..._";
48
+ readonly url: [{
49
+ readonly name: "flowr#633";
50
+ readonly href: string;
51
+ }];
26
52
  }];
27
53
  }, {
28
54
  readonly name: "Resolution";
@@ -538,25 +564,40 @@ export declare const flowrCapabilities: {
538
564
  readonly capabilities: readonly [{
539
565
  readonly name: "S3";
540
566
  readonly id: "oop-s3";
541
- readonly note: "https://adv-r.hadley.nz/s3.html";
567
+ readonly url: [{
568
+ readonly name: string;
569
+ readonly href: "https://adv-r.hadley.nz/s3.html";
570
+ }];
542
571
  readonly supported: "not";
543
572
  readonly description: "_Handle S3 classes and methods as one unit (with attributes etc.). Including Dispatch and Inheritance._ We do not support typing currently and do not handle objects of these classes \"as units.\"";
544
573
  }, {
545
574
  readonly name: "S4";
546
575
  readonly id: "oop-s4";
547
- readonly note: "https://adv-r.hadley.nz/s4.html";
576
+ readonly url: [{
577
+ readonly name: string;
578
+ readonly href: "https://adv-r.hadley.nz/s4.html";
579
+ }];
548
580
  readonly supported: "not";
549
581
  readonly description: "_Handle S4 classes and methods as one unit. Including Dispatch and Inheritance_ We do not support typing currently and do not handle objects of these classes \"as units.\"";
550
582
  }, {
551
583
  readonly name: "R6";
552
584
  readonly id: "oop-r6";
553
- readonly note: "https://adv-r.hadley.nz/r6.html";
585
+ readonly url: [{
586
+ readonly name: string;
587
+ readonly href: "https://adv-r.hadley.nz/r6.html";
588
+ }];
554
589
  readonly supported: "not";
555
590
  readonly description: "_Handle R6 classes and methods as one unit. Including Dispatch and Inheritance, as well as its Reference Semantics, Access Control, Finalizers, and Introspection._ We do not support typing currently and do not handle objects of these classes \"as units.\"";
556
591
  }, {
557
592
  readonly name: "R7/S7";
558
593
  readonly id: "r7-s7";
559
- readonly note: "https://www.r-bloggers.com/2022/12/what-is-r7-a-new-oop-system-for-r/, https://cran.r-project.org/web/packages/S7/index.html";
594
+ readonly url: [{
595
+ readonly name: "R7";
596
+ readonly href: "https://www.r-bloggers.com/2022/12/what-is-r7-a-new-oop-system-for-r/";
597
+ }, {
598
+ readonly name: "S7";
599
+ readonly href: "https://cran.r-project.org/web/packages/S7/index.html";
600
+ }];
560
601
  readonly supported: "not";
561
602
  readonly description: "_Handle R7 classes and methods as one unit. Including Dispatch and Inheritance, as well as its Reference Semantics, Validators, ..._ We do not support typing currently and do not handle objects of these classes \"as units.\"";
562
603
  }];
@@ -1,14 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrCapabilities = void 0;
4
+ const doc_files_1 = require("../../documentation/doc-util/doc-files");
5
+ const doc_code_1 = require("../../documentation/doc-util/doc-code");
6
+ const doc_dfg_1 = require("../../documentation/doc-util/doc-dfg");
7
+ const Joiner = '/';
8
+ const AdvancedR = (subname) => 'Advanced R' + Joiner + subname;
9
+ const RLang = (subname) => 'R Definition' + Joiner + subname;
10
+ const Issue = (num) => `${doc_files_1.FlowrGithubBaseRef}/flowr/issues/${num}`;
11
+ const LinkTo = (id, label = id) => `[${label}](#${id})`;
4
12
  exports.flowrCapabilities = {
5
13
  name: 'Capabilities of flowR',
6
14
  description: 'This is an evolving representation of what started with #636 to formulate capabilities in a structured format.',
7
- version: '0.0.1',
15
+ version: '0.0.2',
8
16
  capabilities: [
9
17
  {
10
18
  name: 'Names and Identifiers',
11
19
  id: 'names-and-identifiers',
20
+ description: 'The recognition of syntactical and non-syntactical names, including their resolutions to corresponding definitions.',
21
+ example: async (parser) => {
22
+ const code = '"f" <- function(x) { get("x") } \n`y x` <- 2\nprint(`y x` + f(3))';
23
+ return `
24
+ Consider the following R code:
25
+ ${(0, doc_code_1.codeBlock)('r', code)}
26
+ Identifiers of interest are:
27
+
28
+ - The symbols \`x\` (${LinkTo('name-normal')}), \`f\` (${LinkTo('name-quoted')}), and \`\` \`y x\` \`\` (${LinkTo('name-escaped')}).
29
+ - The function calls \`<-\`, \`function\`, \`{\`, \`get\`, \`+\`, and \`print\` (${LinkTo('function-calls')}, all given with ${LinkTo('name-normal')}).
30
+ Especially \`{\` is identified as a ${LinkTo('grouping')} of the ${LinkTo('function-definitions', 'function-definitions\'')} body.
31
+ - The quoted name created by a function call \`get\` (${LinkTo('name-created')}).
32
+
33
+ Besides the parameter \`x\`, which is resolved in its ${LinkTo('lexicographic-scope')}, the other identifiers are resolved in the ${LinkTo('global-scope')}.
34
+
35
+ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
36
+ `;
37
+ },
12
38
  capabilities: [
13
39
  {
14
40
  name: 'Form',
@@ -18,19 +44,38 @@ exports.flowrCapabilities = {
18
44
  name: 'Normal',
19
45
  id: 'name-normal',
20
46
  supported: 'fully',
21
- description: '_Recognize constructs like `a`, `plot`, ..._'
47
+ description: '_Recognize symbol uses like `a`, `plot`, ..._ (i.e., "normal variables or function calls").',
48
+ url: [
49
+ { name: AdvancedR('Bindings'), href: 'https://adv-r.hadley.nz/names-values.html#binding-basics' },
50
+ { name: RLang('Identifiers'), href: 'https://cran.r-project.org/doc/manuals/r-release/R-lang.html#Identifiers-1' }
51
+ ]
22
52
  },
23
53
  {
24
54
  name: 'Quoted',
25
55
  id: 'name-quoted',
26
56
  supported: 'fully',
27
- description: "_Recognize `\"a\"`, `'plot'`, ..._"
57
+ description: "_Recognize `\"a\"`, `'plot'`, ..._ In general, R allows to envelop names in quotations to allow for special characters such as spaces in variable names. However, this only works in the context of definitions. To access these names as variables, one has to either use function such as `get` or escape the name with backticks.",
58
+ url: [
59
+ { name: AdvancedR('Non-Syntactic Names'), href: 'https://adv-r.hadley.nz/names-values.html#non-syntactic' }
60
+ ]
28
61
  },
29
62
  {
30
63
  name: 'Escaped',
31
64
  id: 'name-escaped',
32
65
  supported: 'fully',
33
- description: '_Recognize `` `a` ``, `` `plot` ``, ..._'
66
+ description: '_Recognize `` `a` ``, `` `plot` ``, ..._',
67
+ url: [
68
+ { name: AdvancedR('Non-Syntactic Names'), href: 'https://adv-r.hadley.nz/names-values.html#non-syntactic' }
69
+ ]
70
+ },
71
+ {
72
+ name: 'Created',
73
+ id: 'name-created',
74
+ supported: 'partially',
75
+ description: '_Recognize functions which resolve strings as identifiers, such as `get`, ..._',
76
+ url: [
77
+ { name: 'flowr#633', href: Issue(633) }
78
+ ]
34
79
  }
35
80
  ]
36
81
  },
@@ -671,28 +716,37 @@ exports.flowrCapabilities = {
671
716
  {
672
717
  name: 'S3',
673
718
  id: 'oop-s3',
674
- note: 'https://adv-r.hadley.nz/s3.html',
719
+ url: [
720
+ { name: AdvancedR('S3'), href: 'https://adv-r.hadley.nz/s3.html' }
721
+ ],
675
722
  supported: 'not',
676
723
  description: '_Handle S3 classes and methods as one unit (with attributes etc.). Including Dispatch and Inheritance._ We do not support typing currently and do not handle objects of these classes "as units."'
677
724
  },
678
725
  {
679
726
  name: 'S4',
680
727
  id: 'oop-s4',
681
- note: 'https://adv-r.hadley.nz/s4.html',
728
+ url: [
729
+ { name: AdvancedR('S4'), href: 'https://adv-r.hadley.nz/s4.html' }
730
+ ],
682
731
  supported: 'not',
683
732
  description: '_Handle S4 classes and methods as one unit. Including Dispatch and Inheritance_ We do not support typing currently and do not handle objects of these classes "as units."'
684
733
  },
685
734
  {
686
735
  name: 'R6',
687
736
  id: 'oop-r6',
688
- note: 'https://adv-r.hadley.nz/r6.html',
737
+ url: [
738
+ { name: AdvancedR('R6'), href: 'https://adv-r.hadley.nz/r6.html' }
739
+ ],
689
740
  supported: 'not',
690
741
  description: '_Handle R6 classes and methods as one unit. Including Dispatch and Inheritance, as well as its Reference Semantics, Access Control, Finalizers, and Introspection._ We do not support typing currently and do not handle objects of these classes "as units."'
691
742
  },
692
743
  {
693
744
  name: 'R7/S7',
694
745
  id: 'r7-s7',
695
- note: 'https://www.r-bloggers.com/2022/12/what-is-r7-a-new-oop-system-for-r/, https://cran.r-project.org/web/packages/S7/index.html',
746
+ url: [
747
+ { name: 'R7', href: 'https://www.r-bloggers.com/2022/12/what-is-r7-a-new-oop-system-for-r/' },
748
+ { name: 'S7', href: 'https://cran.r-project.org/web/packages/S7/index.html' }
749
+ ],
696
750
  supported: 'not',
697
751
  description: '_Handle R7 classes and methods as one unit. Including Dispatch and Inheritance, as well as its Reference Semantics, Validators, ..._ We do not support typing currently and do not handle objects of these classes "as units."'
698
752
  }
@@ -1,3 +1,4 @@
1
+ import type { KnownParser } from '../parser';
1
2
  declare const enum RequiredFeature {
2
3
  /** https://github.com/flowr-analysis/flowr/labels/typing */
3
4
  Typing = 0,
@@ -15,7 +16,12 @@ export interface FlowrCapability {
15
16
  /** A list of features that are required for the capability, extend at need. */
16
17
  readonly needs?: RequiredFeature[];
17
18
  readonly description?: string;
18
- readonly note?: string;
19
+ readonly example?: string | ((parser: KnownParser) => Promise<string>);
20
+ /** A list of URLs that provide additional information about the capability */
21
+ readonly url?: {
22
+ name: string;
23
+ href: string;
24
+ }[];
19
25
  /** The level of support for the capability, undefined if it is a meta-capability that does not need such an attribute */
20
26
  readonly supported?: 'not' | 'partially' | 'fully';
21
27
  readonly capabilities?: readonly FlowrCapability[];
@@ -74,6 +74,8 @@ export interface NormalizedAst<OtherInfo = ParentInformation, Node = RNode<Other
74
74
  idMap: AstIdMap<OtherInfo>;
75
75
  /** The root of the AST with parent information */
76
76
  ast: Node;
77
+ /** marks whether the AST contains potential syntax errors */
78
+ hasError?: boolean;
77
79
  }
78
80
  export interface NormalizedAstDecorationConfiguration<OtherInfo> {
79
81
  /** The id generator: must generate a unique id für each passed node */
@@ -27,10 +27,7 @@ function recoverName(id, idMap) {
27
27
  */
28
28
  function recoverContent(id, graph) {
29
29
  const vertex = graph.getVertex(id);
30
- if (vertex === undefined) {
31
- return undefined;
32
- }
33
- if (vertex.tag === vertex_1.VertexType.FunctionCall && vertex.name) {
30
+ if (vertex && vertex.tag === vertex_1.VertexType.FunctionCall && vertex.name) {
34
31
  return vertex.name;
35
32
  }
36
33
  const node = graph.idMap?.get(id);
@@ -38,7 +35,7 @@ function recoverContent(id, graph) {
38
35
  return undefined;
39
36
  }
40
37
  const lexeme = node.lexeme ?? node.info.fullLexeme ?? '';
41
- if (vertex.tag === vertex_1.VertexType.Use) {
38
+ if (vertex?.tag === vertex_1.VertexType.Use) {
42
39
  return (0, retriever_1.removeRQuotes)(lexeme);
43
40
  }
44
41
  return lexeme;