@eagleoutice/flowr 2.2.1 → 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 (95) hide show
  1. package/cli/flowr.js +2 -1
  2. package/cli/repl/commands/repl-cfg.js +30 -7
  3. package/cli/repl/commands/repl-dataflow.js +29 -6
  4. package/cli/repl/commands/repl-normalize.js +22 -2
  5. package/cli/repl/commands/repl-parse.js +50 -3
  6. package/cli/repl/core.js +4 -0
  7. package/cli/repl/print-version.d.ts +1 -0
  8. package/cli/repl/print-version.js +7 -2
  9. package/cli/repl/server/connection.js +11 -9
  10. package/cli/script-core/statistics-helper-core.js +1 -1
  11. package/config.js +8 -1
  12. package/core/pipeline-executor.d.ts +6 -0
  13. package/core/pipeline-executor.js +8 -0
  14. package/core/print/dataflow-printer.js +3 -0
  15. package/core/steps/all/core/01-parse-tree-sitter.d.ts +7 -0
  16. package/core/steps/pipeline/default-pipelines.d.ts +57 -47
  17. package/core/steps/pipeline/default-pipelines.js +23 -2
  18. package/core/steps/pipeline/pipeline.d.ts +1 -1
  19. package/core/steps/pipeline/pipeline.js +1 -1
  20. package/core/steps/pipeline-step.d.ts +1 -3
  21. package/dataflow/environments/resolve-by-name.d.ts +3 -2
  22. package/dataflow/environments/resolve-by-name.js +4 -4
  23. package/dataflow/extractor.d.ts +10 -0
  24. package/dataflow/extractor.js +11 -1
  25. package/dataflow/graph/dataflowgraph-builder.d.ts +11 -10
  26. package/dataflow/graph/dataflowgraph-builder.js +11 -10
  27. package/dataflow/graph/edge.d.ts +1 -1
  28. package/dataflow/graph/edge.js +2 -2
  29. package/dataflow/graph/vertex.d.ts +6 -6
  30. package/dataflow/graph/vertex.js +5 -5
  31. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -5
  32. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -1
  33. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +22 -6
  34. package/documentation/doc-util/doc-cfg.js +2 -2
  35. package/documentation/doc-util/doc-dfg.d.ts +5 -3
  36. package/documentation/doc-util/doc-dfg.js +10 -8
  37. package/documentation/doc-util/doc-files.d.ts +1 -1
  38. package/documentation/doc-util/doc-files.js +1 -1
  39. package/documentation/doc-util/doc-normalized-ast.d.ts +2 -1
  40. package/documentation/doc-util/doc-normalized-ast.js +4 -5
  41. package/documentation/doc-util/doc-repl.d.ts +6 -2
  42. package/documentation/doc-util/doc-repl.js +10 -6
  43. package/documentation/doc-util/doc-structure.d.ts +1 -1
  44. package/documentation/doc-util/doc-types.d.ts +7 -5
  45. package/documentation/doc-util/doc-types.js +17 -12
  46. package/documentation/index.d.ts +9 -0
  47. package/documentation/index.js +26 -0
  48. package/documentation/print-capabilities-markdown.js +105 -19
  49. package/documentation/print-core-wiki.d.ts +1 -0
  50. package/documentation/print-core-wiki.js +406 -0
  51. package/documentation/print-dataflow-graph-wiki.js +27 -27
  52. package/documentation/print-interface-wiki.js +1 -3
  53. package/documentation/print-linting-and-testing-wiki.js +26 -8
  54. package/documentation/print-normalized-ast-wiki.js +22 -17
  55. package/documentation/print-query-wiki.js +37 -7
  56. package/documentation/print-search-wiki.js +2 -1
  57. package/package.json +10 -7
  58. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  59. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  60. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  61. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -1
  62. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +4 -0
  63. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +34 -0
  64. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +72 -0
  65. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +49 -0
  66. package/queries/catalog/search-query/search-query-format.js +1 -1
  67. package/queries/query.d.ts +60 -1
  68. package/queries/query.js +3 -1
  69. package/r-bridge/data/data.d.ts +50 -9
  70. package/r-bridge/data/data.js +64 -10
  71. package/r-bridge/data/types.d.ts +7 -1
  72. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
  73. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -5
  74. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +6 -0
  75. package/r-bridge/lang-4.x/ast/parser/json/format.js +6 -0
  76. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +13 -2
  77. package/r-bridge/lang-4.x/ast/parser/json/parser.js +19 -3
  78. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.d.ts +3 -0
  79. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -0
  80. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +51 -29
  81. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.d.ts +4 -1
  82. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-types.js +3 -0
  83. package/r-bridge/parser.d.ts +10 -0
  84. package/r-bridge/parser.js +26 -2
  85. package/search/flowr-search-builder.d.ts +1 -2
  86. package/search/flowr-search-builder.js +1 -3
  87. package/util/cfg/cfg.d.ts +10 -1
  88. package/util/cfg/cfg.js +56 -2
  89. package/util/mermaid/dfg.d.ts +3 -0
  90. package/util/mermaid/dfg.js +24 -8
  91. package/util/range.d.ts +21 -0
  92. package/util/range.js +3 -0
  93. package/util/strings.d.ts +9 -0
  94. package/util/strings.js +14 -0
  95. package/util/version.js +1 -1
@@ -167,7 +167,7 @@ function executeCallContextQueries({ dataflow: { graph }, ast }, queries) {
167
167
  const { promotedQueries, requiresCfg } = promoteQueryCallNames(queries);
168
168
  let cfg = undefined;
169
169
  if (requiresCfg) {
170
- cfg = (0, cfg_1.extractCFG)(ast);
170
+ cfg = (0, cfg_1.extractCFG)(ast, graph);
171
171
  }
172
172
  const queriesWhichWantAliases = promotedQueries.filter(q => q.includeAliases);
173
173
  for (const [nodeId, info] of graph.vertices(true)) {
@@ -1,3 +1,3 @@
1
1
  import type { BasicQueryData } from '../../base-query-format';
2
2
  import type { HappensBeforeQuery, HappensBeforeQueryResult } from './happens-before-query-format';
3
- export declare function executeHappensBefore({ ast }: BasicQueryData, queries: readonly HappensBeforeQuery[]): HappensBeforeQueryResult;
3
+ export declare function executeHappensBefore({ ast, dataflow }: BasicQueryData, queries: readonly HappensBeforeQuery[]): HappensBeforeQueryResult;
@@ -6,10 +6,10 @@ const log_1 = require("../../../util/log");
6
6
  const cfg_1 = require("../../../util/cfg/cfg");
7
7
  const happens_before_1 = require("../../../util/cfg/happens-before");
8
8
  const parse_1 = require("../../../slicing/criterion/parse");
9
- function executeHappensBefore({ ast }, queries) {
9
+ function executeHappensBefore({ ast, dataflow }, queries) {
10
10
  const start = Date.now();
11
11
  const results = {};
12
- const cfg = (0, cfg_1.extractCFG)(ast);
12
+ const cfg = (0, cfg_1.extractCFG)(ast, dataflow.graph);
13
13
  for (const query of queries) {
14
14
  const { a, b } = query;
15
15
  const fingerprint = `${a}<${b}`;
@@ -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
@@ -0,0 +1,4 @@
1
+ import type { ResolveValueQuery, ResolveValueQueryResult } from './resolve-value-query-format';
2
+ import type { BasicQueryData } from '../../base-query-format';
3
+ export declare function fingerPrintOfQuery(query: ResolveValueQuery): string;
4
+ export declare function executeResolveValueQuery({ dataflow: { graph, environment }, ast }: BasicQueryData, queries: readonly ResolveValueQuery[]): ResolveValueQueryResult;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fingerPrintOfQuery = fingerPrintOfQuery;
4
+ exports.executeResolveValueQuery = executeResolveValueQuery;
5
+ const log_1 = require("../../../util/log");
6
+ const parse_1 = require("../../../slicing/criterion/parse");
7
+ const resolve_by_name_1 = require("../../../dataflow/environments/resolve-by-name");
8
+ const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
9
+ function fingerPrintOfQuery(query) {
10
+ return JSON.stringify(query);
11
+ }
12
+ function executeResolveValueQuery({ dataflow: { graph, environment }, ast }, queries) {
13
+ const start = Date.now();
14
+ const results = {};
15
+ for (const query of queries) {
16
+ const key = fingerPrintOfQuery(query);
17
+ if (results[key]) {
18
+ log_1.log.warn(`Duplicate Key for resolve-value-query: ${key}, skipping...`);
19
+ }
20
+ const values = query.criteria
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.idMap ?? ast.idMap));
23
+ results[key] = {
24
+ values: [...new Set(values)]
25
+ };
26
+ }
27
+ return {
28
+ '.meta': {
29
+ timing: Date.now() - start
30
+ },
31
+ results
32
+ };
33
+ }
34
+ //# sourceMappingURL=resolve-value-query-executor.js.map
@@ -0,0 +1,72 @@
1
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
+ import type { SlicingCriteria } from '../../../slicing/criterion/parse';
3
+ import Joi from 'joi';
4
+ import { executeResolveValueQuery } from './resolve-value-query-executor';
5
+ export interface ResolveValueQuery extends BaseQueryFormat {
6
+ readonly type: 'resolve-value';
7
+ /** The slicing criteria to use */
8
+ readonly criteria: SlicingCriteria;
9
+ }
10
+ export interface ResolveValueQueryResult extends BaseQueryResult {
11
+ results: Record<string, {
12
+ values: unknown[];
13
+ }>;
14
+ }
15
+ export declare const ResolveValueQueryDefinition: {
16
+ readonly executor: typeof executeResolveValueQuery;
17
+ readonly asciiSummarizer: (formatter: import("../../../util/ansi").OutputFormatter, _processed: import("../../../core/steps/pipeline/pipeline").PipelineOutput<import("../../../core/steps/pipeline/pipeline").Pipeline<{
18
+ readonly name: "parse";
19
+ readonly humanReadableName: "parse with R shell";
20
+ readonly description: "Parse the given R code into an AST";
21
+ readonly processor: (_results: unknown, input: Partial<import("../../../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../../../r-bridge/parser").ParseStepOutput<string>>;
22
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
23
+ readonly printer: {
24
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
25
+ readonly 2: {
26
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
27
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
28
+ };
29
+ readonly 5: ({ parsed }: import("../../../r-bridge/parser").ParseStepOutput<string>, config: import("../../../util/quads").QuadSerializationConfiguration) => string;
30
+ };
31
+ readonly dependencies: readonly [];
32
+ readonly requiredInput: import("../../../r-bridge/parser").ParseRequiredInput<string>;
33
+ } | {
34
+ readonly name: "normalize";
35
+ readonly humanReadableName: "normalize";
36
+ readonly description: "Normalize the AST to flowR's AST";
37
+ readonly processor: (results: {
38
+ parse?: import("../../../r-bridge/parser").ParseStepOutput<string>;
39
+ }, input: Partial<import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../../r-bridge/lang-4.x/ast/model/model").RNode<import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
40
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
41
+ readonly printer: {
42
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
43
+ readonly 2: typeof import("../../../core/print/normalize-printer").normalizedAstToJson;
44
+ readonly 5: typeof import("../../../core/print/normalize-printer").normalizedAstToQuads;
45
+ readonly 3: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaid;
46
+ readonly 4: typeof import("../../../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
47
+ };
48
+ readonly dependencies: readonly ["parse"];
49
+ readonly requiredInput: import("../../../core/steps/all/core/10-normalize").NormalizeRequiredInput;
50
+ } | {
51
+ readonly humanReadableName: "dataflow";
52
+ readonly processor: (results: {
53
+ normalize?: import("../../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
54
+ }, input: {
55
+ request?: import("../../../r-bridge/retriever").RParseRequests;
56
+ parser?: import("../../../r-bridge/parser").Parser<import("../../../r-bridge/parser").KnownParserType>;
57
+ }) => import("../../../dataflow/info").DataflowInformation;
58
+ readonly requiredInput: {};
59
+ readonly name: "dataflow";
60
+ readonly description: "Construct the dataflow graph";
61
+ readonly executed: import("../../../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
62
+ readonly printer: {
63
+ readonly 0: typeof import("../../../core/print/print").internalPrinter;
64
+ readonly 2: typeof import("../../../core/print/dataflow-printer").dataflowGraphToJson;
65
+ readonly 5: typeof import("../../../core/print/dataflow-printer").dataflowGraphToQuads;
66
+ readonly 3: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaid;
67
+ readonly 4: typeof import("../../../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
68
+ };
69
+ readonly dependencies: readonly ["normalize"];
70
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
71
+ readonly schema: Joi.ObjectSchema<any>;
72
+ };
@@ -0,0 +1,49 @@
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.ResolveValueQueryDefinition = void 0;
7
+ const ansi_1 = require("../../../util/ansi");
8
+ const time_1 = require("../../../util/time");
9
+ const joi_1 = __importDefault(require("joi"));
10
+ const resolve_value_query_executor_1 = require("./resolve-value-query-executor");
11
+ function rValueToAscii(value) {
12
+ if (value === null || value === undefined) {
13
+ return 'undefined';
14
+ }
15
+ else if (typeof value === 'string') {
16
+ return value;
17
+ }
18
+ else if (typeof value === 'object') {
19
+ if ('num' in value) {
20
+ return value.num.toString();
21
+ }
22
+ else if ('str' in value) {
23
+ return `${value.quotes}${value.str}${value.quotes}`;
24
+ }
25
+ else {
26
+ console.warn('omega lul');
27
+ return JSON.stringify(value);
28
+ }
29
+ }
30
+ return value;
31
+ }
32
+ exports.ResolveValueQueryDefinition = {
33
+ executor: resolve_value_query_executor_1.executeResolveValueQuery,
34
+ asciiSummarizer: (formatter, _processed, queryResults, result) => {
35
+ const out = queryResults;
36
+ result.push(`Query: ${(0, ansi_1.bold)('resolve-value', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
37
+ for (const [fingerprint, obj] of Object.entries(out.results)) {
38
+ const { criteria } = JSON.parse(fingerprint);
39
+ result.push(` ╰ Values for {${criteria.join(', ')}}`);
40
+ result.push(` ╰ ${obj.values.map(v => rValueToAscii(v)).join(', ')}`);
41
+ }
42
+ return true;
43
+ },
44
+ schema: joi_1.default.object({
45
+ type: joi_1.default.string().valid('resolve-value').required().description('The type of the query.'),
46
+ criteria: joi_1.default.array().items(joi_1.default.string()).min(1).required().description('The slicing criteria to use.'),
47
+ }).description('The resolve value query used to get definitions of an identifier')
48
+ };
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
@@ -17,7 +17,8 @@ import type { LocationMapQuery } from './catalog/location-map-query/location-map
17
17
  import type { ConfigQuery } from './catalog/config-query/config-query-format';
18
18
  import type { SearchQuery } from './catalog/search-query/search-query-format';
19
19
  import type { HappensBeforeQuery } from './catalog/happens-before-query/happens-before-query-format';
20
- export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery;
20
+ import type { ResolveValueQuery } from './catalog/resolve-value-query/resolve-value-query-format';
21
+ export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | LineageQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | ResolveValueQuery;
21
22
  export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
22
23
  type: QueryType;
23
24
  };
@@ -568,6 +569,64 @@ export declare const SupportedQueries: {
568
569
  }>>, queryResults: BaseQueryResult, result: string[]) => true;
569
570
  readonly schema: Joi.ObjectSchema<any>;
570
571
  };
572
+ readonly 'resolve-value': {
573
+ readonly executor: typeof import("./catalog/resolve-value-query/resolve-value-query-executor").executeResolveValueQuery;
574
+ readonly asciiSummarizer: (formatter: OutputFormatter, _processed: PipelineOutput<import("../core/steps/pipeline/pipeline").Pipeline<{
575
+ readonly name: "parse";
576
+ readonly humanReadableName: "parse with R shell";
577
+ readonly description: "Parse the given R code into an AST";
578
+ readonly processor: (_results: unknown, input: Partial<import("../r-bridge/parser").ParseRequiredInput<string>>) => Promise<import("../r-bridge/parser").ParseStepOutput<string>>;
579
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
580
+ readonly printer: {
581
+ readonly 0: typeof import("../core/print/print").internalPrinter;
582
+ readonly 2: {
583
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
584
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
585
+ };
586
+ readonly 5: ({ parsed }: import("../r-bridge/parser").ParseStepOutput<string>, config: import("../util/quads").QuadSerializationConfiguration) => string;
587
+ };
588
+ readonly dependencies: readonly [];
589
+ readonly requiredInput: import("../r-bridge/parser").ParseRequiredInput<string>;
590
+ } | {
591
+ readonly name: "normalize";
592
+ readonly humanReadableName: "normalize";
593
+ readonly description: "Normalize the AST to flowR's AST";
594
+ readonly processor: (results: {
595
+ parse?: import("../r-bridge/parser").ParseStepOutput<string>;
596
+ }, input: Partial<import("../core/steps/all/core/10-normalize").NormalizeRequiredInput>) => import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../r-bridge/lang-4.x/ast/model/model").RNode<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>>;
597
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
598
+ readonly printer: {
599
+ readonly 0: typeof import("../core/print/print").internalPrinter;
600
+ readonly 2: typeof import("../core/print/normalize-printer").normalizedAstToJson;
601
+ readonly 5: typeof import("../core/print/normalize-printer").normalizedAstToQuads;
602
+ readonly 3: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaid;
603
+ readonly 4: typeof import("../core/print/normalize-printer").printNormalizedAstToMermaidUrl;
604
+ };
605
+ readonly dependencies: readonly ["parse"];
606
+ readonly requiredInput: import("../core/steps/all/core/10-normalize").NormalizeRequiredInput;
607
+ } | {
608
+ readonly humanReadableName: "dataflow";
609
+ readonly processor: (results: {
610
+ normalize?: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
611
+ }, input: {
612
+ request?: import("../r-bridge/retriever").RParseRequests;
613
+ parser?: import("../r-bridge/parser").Parser<import("../r-bridge/parser").KnownParserType>;
614
+ }) => import("../dataflow/info").DataflowInformation;
615
+ readonly requiredInput: {};
616
+ readonly name: "dataflow";
617
+ readonly description: "Construct the dataflow graph";
618
+ readonly executed: import("../core/steps/pipeline-step").PipelineStepStage.OncePerFile;
619
+ readonly printer: {
620
+ readonly 0: typeof import("../core/print/print").internalPrinter;
621
+ readonly 2: typeof import("../core/print/dataflow-printer").dataflowGraphToJson;
622
+ readonly 5: typeof import("../core/print/dataflow-printer").dataflowGraphToQuads;
623
+ readonly 3: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaid;
624
+ readonly 4: typeof import("../core/print/dataflow-printer").dataflowGraphToMermaidUrl;
625
+ };
626
+ readonly dependencies: readonly ["normalize"];
627
+ }>>, queryResults: BaseQueryResult, result: string[]) => true;
628
+ readonly schema: Joi.ObjectSchema<any>;
629
+ };
571
630
  };
572
631
  export type SupportedQueryTypes = keyof typeof SupportedQueries;
573
632
  export type QueryResult<Type extends Query['type']> = ReturnType<typeof SupportedQueries[Type]['executor']>;
package/queries/query.js CHANGED
@@ -25,6 +25,7 @@ const location_map_query_format_1 = require("./catalog/location-map-query/locati
25
25
  const config_query_format_1 = require("./catalog/config-query/config-query-format");
26
26
  const search_query_format_1 = require("./catalog/search-query/search-query-format");
27
27
  const happens_before_query_format_1 = require("./catalog/happens-before-query/happens-before-query-format");
28
+ const resolve_value_query_format_1 = require("./catalog/resolve-value-query/resolve-value-query-format");
28
29
  exports.SupportedQueries = {
29
30
  'call-context': call_context_query_format_1.CallContextQueryDefinition,
30
31
  'config': config_query_format_1.ConfigQueryDefinition,
@@ -37,7 +38,8 @@ exports.SupportedQueries = {
37
38
  'dependencies': dependencies_query_format_1.DependenciesQueryDefinition,
38
39
  'location-map': location_map_query_format_1.LocationMapQueryDefinition,
39
40
  'search': search_query_format_1.SearchQueryDefinition,
40
- 'happens-before': happens_before_query_format_1.HappensBeforeQueryDefinition
41
+ 'happens-before': happens_before_query_format_1.HappensBeforeQueryDefinition,
42
+ 'resolve-value': resolve_value_query_format_1.ResolveValueQueryDefinition
41
43
  };
42
44
  function executeQueriesOfSameType(data, ...queries) {
43
45
  (0, assert_1.guard)(queries.length > 0, 'At least one query must be provided');
@@ -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";
@@ -190,8 +216,8 @@ export declare const flowrCapabilities: {
190
216
  readonly supported: "fully";
191
217
  readonly description: "_Detect calls like `x[]`, `x[2,,42]`, ..._";
192
218
  }, {
193
- readonly name: "Subsetting";
194
- readonly id: "subsetting";
219
+ readonly name: "Subsetting (Multiple Indices)";
220
+ readonly id: "subsetting-multiple";
195
221
  readonly supported: "fully";
196
222
  readonly description: "_Detect calls like `x[i > 3]`, `x[c(1,3)]`, ..._";
197
223
  }];
@@ -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
  },
@@ -237,8 +282,8 @@ exports.flowrCapabilities = {
237
282
  description: '_Detect calls like `x[]`, `x[2,,42]`, ..._'
238
283
  },
239
284
  {
240
- name: 'Subsetting',
241
- id: 'subsetting',
285
+ name: 'Subsetting (Multiple Indices)',
286
+ id: 'subsetting-multiple',
242
287
  supported: 'fully',
243
288
  description: '_Detect calls like `x[i > 3]`, `x[c(1,3)]`, ..._'
244
289
  }
@@ -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;
@@ -36,6 +36,12 @@ export interface NamedJsonEntry {
36
36
  name: RawRType;
37
37
  content: JsonEntry;
38
38
  }
39
+ /**
40
+ * Takes the raw {@link RShell} output and extracts the csv information contained
41
+ */
39
42
  export declare function prepareParsedData(data: string): CsvEntry[];
43
+ /**
44
+ * Takes the CSV-Entries and maps them to the old json format for compatibility.
45
+ */
40
46
  export declare function convertPreparedParsedData(roots: readonly CsvEntry[]): JsonEntry;
41
47
  export {};